yolov7 icon indicating copy to clipboard operation
yolov7 copied to clipboard

Model output is empty when exporting to ONNX with end2end

Open methier-CPR opened this issue 2 years ago • 4 comments

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.

methier-CPR avatar Jul 29 '22 16:07 methier-CPR

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?

AlexeyAB avatar Jul 29 '22 18:07 AlexeyAB

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.

methier-CPR avatar Jul 29 '22 19:07 methier-CPR

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

AlexeyAB avatar Jul 29 '22 19:07 AlexeyAB

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.

methier-CPR avatar Aug 02 '22 13:08 methier-CPR

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

sapjunior avatar Aug 24 '22 07:08 sapjunior