Skip to content
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

The detect result of pytorch model is different from onnx model. It seems different deep learning framework has different output #6587

Closed
1 of 2 tasks
zoubaihan opened this issue Feb 9, 2022 · 1 comment
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@zoubaihan
Copy link

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

Detection, Export

Bug

Hello, here is a question that confuse me a lot. I download the model yolov5m.onnx and yolov5m.pt , and the test command is as follow:

onnx model tested on COCO:
python detect.py --source /datasets/coco128/images/train2017 --weights /data/zoubaihan/pyproject/yolov5/yolov5m.onnx

One of the image detected by onnx model is as follow:
000000000263

pytorch model tested on COCO:
python detect.py --source /datasets/coco128/images/train2017 --weights /data/zoubaihan/pyproject/yolov5/yolov5m.pt

While the same input image detected by pytorch model is as follow:
000000000263

Jesus! Why the same model and the same weight under different deeplearning framework output different results?

I have also tried to convert some other deep learning models between different deep learning frameworks, but the output results are often different, or even very different. Could you please explain why this is?

I also tried to use export.py to convert model from pytorch to onnx, but their results is also not equal. The command is as follow:
python export.py --weights yolov5m.pt --include onnx

But another confusing problem came out: the file size of the output onnx model is not equal to the onnx model I download from your github. Is the yolov5m.onnx model you put in the release really converted by you by running export.py?

Environment

No response

Minimal Reproducible Example

onnx model tested on COCO:
python detect.py --source /datasets/coco128/images/train2017 --weights /data/zoubaihan/pyproject/yolov5/yolov5m.onnx

pytorch model tested on COCO:
python detect.py --source /datasets/coco128/images/train2017 --weights /data/zoubaihan/pyproject/yolov5/yolov5m.pt

I also tried to use export.py to convert model from pytorch to onnx, but their results is also not equal. The command is as follow:
python export.py --weights yolov5m.pt --include onnx

Additional

I tried the export.py and other convert tools, but all not work well. Their output results are not the same.
Anybody know why?
Here is the collection of model converter:
https://github.com/ysh329/deep-learning-model-convertor

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@zoubaihan zoubaihan added the bug Something isn't working label Feb 9, 2022
@glenn-jocher glenn-jocher added the duplicate This issue or pull request already exists label Feb 9, 2022
@glenn-jocher
Copy link
Member

@zoubaihan closing as duplicate of #6586

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants