-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
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 export Path to str() #12177
ONNX export Path to str() #12177
Conversation
Signed-off-by: Luis Filipe Araujo de Souza <58831491+Doquey@users.noreply.github.com>
Signed-off-by: Luis Filipe Araujo de Souza <58831491+Doquey@users.noreply.github.com>
Transformed the f variable into a string on the export onnx. This bug was making it impossible to export any models in .onnx, since it was making the typehint not accept the users input as it is specified in the functions documentation Signed-off-by: Luis Filipe Araujo de Souza <58831491+Doquey@users.noreply.github.com>
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 Hello @Doquey, thank you for submitting a YOLOv5 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:
- ✅ Verify your PR is up-to-date with
ultralytics/yolov5
master
branch. If your PR is behind you can update your code by clicking the 'Update branch' button or by runninggit pull
andgit merge master
locally. - ✅ Verify all YOLOv5 Continuous Integration (CI) checks are passing.
- ✅ Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee
Its a very simple fix to a annoying bug that was happening when I was trying to export my yolov5m.pt model into a .onnx model. ONNX: export failure ❌ 0.0s: Function torch.onnx.utils.export() parameter f="PosixPath('best.onnx')" violates type hint typing.Union[str, _io.BytesIO], as <protocol "pathlib.PosixPath"> "PosixPath('best.onnx')" not str or <class "_io.BytesIO">. The only thing I did was go into the function that was trying to export the model in .onnx and add a str() to the f variable before pasing it to the onnx.utils.export() function |
@Doquey thank you for bringing this bug to our attention and for providing a simple fix. We appreciate your contribution! We understand how frustrating it can be when encountering errors like this during the model export process. Your fix of converting the We value your input and appreciate your effort in helping us improve YOLOv5. Your contribution will help ensure a smoother experience for all users. Thank you once again for your contribution to the YOLOv5 project. |
* Update export.py Signed-off-by: Luis Filipe Araujo de Souza <58831491+Doquey@users.noreply.github.com> * Update export.py Signed-off-by: Luis Filipe Araujo de Souza <58831491+Doquey@users.noreply.github.com> * Update export.py Transformed the f variable into a string on the export onnx. This bug was making it impossible to export any models in .onnx, since it was making the typehint not accept the users input as it is specified in the functions documentation Signed-off-by: Luis Filipe Araujo de Souza <58831491+Doquey@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Luis Filipe Araujo de Souza <58831491+Doquey@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
🤖 Generated by Copilot at 929bc87
Summary
🐛🔧📝
Fix a bug in
export.py
that caused a TypeError when exporting models to ONNX format. Convert thef
variable to a string before passing it totorch.onnx.export
.Walkthrough
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Enhanced export compatibility for ONNX files in 'ultralytics/yolov5'.
📊 Key Changes
.onnx
file name during export.🎯 Purpose & Impact