-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mismatch between ultralytics v4.0 predictions and model created from update_module_state_from_ultralytics #114
Comments
Hi @Tomakko Thanks for reporting this bugs. There is a similar bug about this in #92, you can check it for more details. And Currently I can’t ensure the time to complete this, but I promise to complete this as soon as possible, and any contributions are welcome here. EDIT: the updated notebook is at here. |
Hi @zhiqwang, in the previous discussions it was reported that the outputs look good in general, just that there are some minor differences. However, in my case, the bbox coordinates are substantially different. Is the approach under point 2. in my original post above, still the way to go with the master branch of yolov5-rt-stack or do i need to revert to v0.2? Just for compeleteeness, i am feeding in an example image as follows:
|
I have also tried loading the model this way:
However, with this workflow the outputs are completely different compared to the ultralytics model, including the scores. |
Hi @Tomakko You can just use the master branch, we will upload an example tutorial to show what happened while updating weights of Ultralytics/YOLOv5 to yolort. |
Hi @zhiqwang, really looking forward to it! I am currently on your master branch. |
Hi, @Tomakko You can check this notebook: https://github.com/zhiqwang/yolov5-rt-stack/blob/master/notebooks/how-to-align-with-ultralytics-yolov5.ipynb, the only trick here is the different image pre-processing operations, we use the same process in this notebook to ensure that the results of the two inferences are consistent. And the ultralytics/yolov5#3054 (comment) is a good resource about the different dataloaders (pre-precessing) in ultralytics's YOLOv5. I believe this notebook will solve your problem, and as such I'm closing this issue. Feel free to file a new issue if you have further questions. |
Hi @zhiqwang, thank you ver ymuch for the notebook. You are awesome :) It works fine for me with the pretrained model, however it unfortunently does not work for me with a custom trained ultralytics v4.0 model with 10 classes. I only modified your code with respect to loading the image ( from local disk via cv2) and loading the ultralytics model with 10 classes. The ultralytics models prediction look fine when plottet on the image. I have zipped together the notebook, i am using, the set of weights and an example image for your: https://1drv.ms/u/s!Airq-8SFFd5omVcMjMRvASO_5Ucr?e=zAFocW. One more thing i noticed is that the centers of the boxes are equal between yolort and ultraltics, only the ultralytics boxes are much larger. Might there some problem with the anchors when we only have 10 classes? |
Finally found the issue! The ultralytics training script autoenvolves the anchors per default at the beginning of the training script. They are different from what you defined fix in |
Hi @Tomakko Very glad to hear that you've found the source of this problem, and we're welcome to support the feature of autoenvolved anchors. |
@Root970103 Maybe you can try this tutorial https://tvm.apache.org/docs/tutorials/frontend/deploy_object_detection_pytorch.html#sphx-glr-tutorials-frontend-deploy-object-detection-pytorch-py first, we follow its operators in our development. |
Thanks to @zhiqwang, I ignored the version of Pytorch and torchvision. It is noted in the tutorial. https://github.com/zhiqwang/yolov5-rt-stack/blob/master/notebooks/export-relay-inference-tvm.ipynb
Now the tvm model can be export correctly. |
🐛 Bug
Hi! :)
Im am currently training a model in ultralytics v4.0 and want to compile in to TVM with the intermediate step through yolov5 rt. I am comparing the outputs of the ultralytics v4.0 and the model created from update_module_state_from_ultralytics for the same image.
To Reproduce (REQUIRED)
Steps to reproduce the behavior:
Somehow the class and scores seems to be the same (at least for the first two bboxes), but the bboxes itself have different coordinates. Do you have an idea where the mismatch lies? As far as i can see, ultralytics does not do any other post processing than the non_max_suppression. Do you have a test script where you tested and compared outputs of update_module_state_from_ultralytics?
Thanks!
The text was updated successfully, but these errors were encountered: