WongKinYiu / yolov7

Implementation of paper - YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors
GNU General Public License v3.0
13.02k stars 4.12k forks source link

Model output is empty when exporting to ONNX with end2end #360

Open methier-CPR opened 1 year ago

methier-CPR commented 1 year ago

I'm currently using the latest version of the codebase. I fine-tuned a yolov7 model on a custom dataset starting from the yolov7_training.pt weights. My dataset is a single class so I have the configs set to nc=1. I tested the best.pt checkpoint with a test image using the detect.py script and the prediction was correct. I uploaded the best.pt checkpoint to the YOLOv7onnx.ipynb notebook and exported it with the same NMS settings and when I run inference using onnx on the same test image the output is an empty array. I have also tried reparameterizing it but the output is still empty. If I remove the end2end, the ONNX model outputs the expected (1, 25200, 6) array.

AlexeyAB commented 1 year ago

Do you do it locally or on Google Colab?

Can you successfully convert and run onnx model for yolov7_training.pt model ? https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7_training.pt

Could you provide your model?

methier-CPR commented 1 year ago

I did it on colab. Yes, I tried with the yolov7_training.pt model and it worked. I just tested it again using a lower confidence threshold and I got good detections but they all have a confidence < 0.5. This seems to be the same issue as #305 since I'm using one class. The end2end export seems to be doing the same thing that the other NMS function was doing.

AlexeyAB commented 1 year ago

Yes, this seems to be the reason. Which Conf-thresh value does work well for you?

methier-CPR commented 1 year ago

For my task, 0.7 was giving me good results with the detect.py script but I had to bring it down to about 0.3 to make it work with the end2end export because of the bug.

sapjunior commented 1 year ago

This problem is linked to this issue https://github.com/WongKinYiu/yolov7/issues/528#issuecomment-1224564614