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

ONNX model enforcing a specific input size? #1388

Closed
Roulbac opened this issue Jul 14, 2020 · 10 comments
Closed

ONNX model enforcing a specific input size? #1388

Roulbac opened this issue Jul 14, 2020 · 10 comments
Labels

Comments

@Roulbac
Copy link
Contributor

Roulbac commented Jul 14, 2020

Hi,

I am looking to export the yolov3 model as an ONNX, though it looks like code in this repository is enforcing a specific size when exporting as ONNX (320x192).

imgsz = (320, 192) if ONNX_EXPORT else opt.img_size # (320, 192) or (416, 256) or (608, 352) for (height, width)

Is there a specific reason for that? Am I still able to use the ONNX export if I change the code to allow for a different size?

@glenn-jocher
Copy link
Member

glenn-jocher commented Jul 14, 2020

@Roulbac recommend YOLOv5 repo for export: https://docs.ultralytics.com/yolov5/tutorials/model_export

@Roulbac
Copy link
Contributor Author

Roulbac commented Jul 14, 2020

Thanks for the quick reply!
I just spent quite a bit of time training a yolov3 model and it doesn't seem to be compatible with the yolov5 repo though.
I'll most likely make a script to export the yolov3 and make a PR here if I succeed. If you have some tips that can help with that I'll gladly take them!

@glenn-jocher
Copy link
Member

glenn-jocher commented Jul 14, 2020

@Roulbac no, it is not compatible. I would recommend you train a yolov5 model, but you can also train a yolov3 model on the v5 repo. You can use this command on the v5 repo:
python train.py --cfg yolov3-spp.yaml

And then you simply run export.py to export.

@caikw0602
Copy link

HI,
Thank you for your amazing work. I am training my own dataset based on your yolov3 family models. However, I failed to transfer .pt of yolov3-spp to .onnx by using 'models/export.py' in yolov5 project. Do I need to set 'ONNX_EXPORT=True' in the yolov3-spp training process? Look forward to your reply. Please give me some help. Many thanks to you.

@glenn-jocher
Copy link
Member

@caikw0602 this repo is not interoperable with yolov5, they are completely seperate and share no models.

@caikw0602
Copy link

Thank you for your reply. Then, how can I transfer .pt of yolov3-spp to .onnx please.

@glenn-jocher
Copy link
Member

Go to yolov5 repo. There's an export tutorial.

@caikw0602
Copy link

caikw0602 commented Jul 16, 2020

I have transferred your yolov5.pt to .onnx sucessfully. I wanna know how to transfer yolov3.pt to .onnx.

@Roulbac
Copy link
Contributor Author

Roulbac commented Jul 20, 2020

@caikw0602 what glenn is suggesting is that you retrain your yolov3 using the yolov5 github repository.
If you don't want to do that, then maybe convert to darknet using this repo and convert from darknet to onnx using something like https://github.com/Tianxiaomo/pytorch-YOLOv4/blob/master/demo_darknet2onnx.py
The darknet conversion is in the readme.md of this repo.
Good luck!

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants