Closed MjiS closed 2 years ago
maybe the labels array and scores array are not has same length,please check it
Thank you for your reply. I changed the value as calculated by 25200*(num_of_class+5) but I’m still facing the same issue.
private static int mOutputRow = 1310400; // as decided by the YOLOv5 model for input image of size 640*640 private static int mOutputColumn = 52; // left, top, right, bottom, score and 80 class probability
How do you convert the .pt file to .ptl? I tried to convert it using export.py be it doesn't work. This error pops up "PytorchStreamReader failed locating file bytecode.pkl: file not found ()" Mind if you share your export.py with me? Thanks a lot
I used the one given in repo. https://github.com/pytorch/android-demo-app/issues/157 This might help you.
So I solved this issue. You need to change only mOutputColumn value with you number of classes+5. I was changing mOutputRow = 25200 with value calculated by 25200*(num_of_class+5) which caused this issue.
// model output is of size 25200(num_of_class+5) private static int mOutputRow = 25200; // as decided by the YOLOv5 model for input image of size 640640 private static int mOutputColumn = 52; // left, top, right, bottom, score and 80 class probability private static float mThreshold = 0.50f; // score above which a detection is generated //
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:![image](https://user-images.githubusercontent.com/40850864/147658627-3f4a64be-0104-4b6a-880e-35b878216894.png)
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 this repo. works fine. I'm facing this issue when I use my custom model