pytorch / android-demo-app

PyTorch android examples of usage in applications
1.46k stars 604 forks source link

Exported model has 80 classes, even though exporting a 10 classes model #187

Closed simbertrand closed 2 years ago

simbertrand commented 2 years ago

Hello there,

Thank you for your work, i've been successfully able to use the application with the default coco128 dataset (the one that has 80 classes). Though, I am interested in making it work with a custom model that I made using yolov5. The model has 10 classes, and the inference through the python project works perfectly. I tried doing the same steps as you did (exporting to .plt), and even though there are no errors, when using it in the app, the predictions are weird. image I found while using the debugger that the outputTensor is of the shape [1,25200,85], and looking into the outputs array in the function outputsToNMSPredictions, I could clearly see that there were 80 probabilities for every detected object. (and if I change the value of mOutputColumn back to 85, the application works perfectly, but for the coco128 model...). Capture My guess is that my model is not correctly exported to the .ptl format and somehow it loads a "default" model (coco128) for the export. Though i can see in the debugger that the number of classes is 10 while exporting. Capture2 I am no master of programming and the English language so if there's anything unclear let me know! And yes, I checked that I exported the right file in Android Studio!

Thank you for your help!

goldentimecoolk commented 2 years ago

Hi, I have the same problem. How did you solve it?