I have custom model trained on yolov5s v5 and I converted it to torchscript.ptl using ultralytics export.py with code modification as told here.
When I build on android i get the following error:

image892×265 30.7 KB

error that appears in debugging:
E/AndroidRuntime: FATAL EXCEPTION: Thread-2
Process: org.pytorch.demo.objectdetection, PID: 27891
java.lang.ArrayIndexOutOfBoundsException: length=1310400; index=1310449
at org.pytorch.demo.objectdetection.PrePostProcessor.outputsToNMSPredictions(PrePostProcessor.java:123)
at org.pytorch.demo.objectdetection.MainActivity.run(MainActivity.java:248)
I changed my torch version also, I am still facing the same issue.
yolov5s.torchscript.ptl model file provided in the repo. works fine. I’m facing this issue when I use my custom model.