-
-
Notifications
You must be signed in to change notification settings - Fork 16.6k
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
Trouble exporting to coreml. ONNX & Torchscript export working fine. #5575
Comments
@UnkoC0wbOy if you want to export to coreml you can include it in the list of formats to export to:
See argparser for details: Lines 352 to 354 in 79bca2b
|
@UnkoC0wbOy, Im not sure how CoreML works with an intel mac. Wit my silicon M1 pro I have to use Conda for installing all the dependencies. Good start is here: @glenn-jocher I can export the way you propose, but I when I run the detection: I get following error: It seems that the model output does not have the key coordinates. The result has these following keys: torch version: 1.8.0.post3 |
👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs. Access additional YOLOv5 🚀 resources:
Access additional Ultralytics ⚡ resources:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed! Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐! |
@UnkoC0wbOy @mareczech1982 good news 😃! Your original issue may now be fixed ✅ in PR #6195. This PR adds support for YOLOv5 CoreML inference. !python export.py --weights yolov5s.pt --include coreml # CoreML export
!python detect.py --weights yolov5s.mlmodel # CoreML inference (MacOS-only)
!python val.py --weights yolov5s.mlmodel # CoreML validation (MacOS-only)
model = torch.hub.load('ultralytics/yolov5', 'custom', 'yolov5s.mlmodel') # CoreML PyTorch Hub model To receive this update:
Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀! |
@mareczech1982 hi, have you solved this problem, I met the this error now when I use the .mlmodel to detect, it says the coordinated error. @glenn-jocher could you please help me with it? I found it is ok for yolov5s.pt while failed for yolov3.pt, does this the root cause of my problem? Traceback (most recent call last): Thanks |
@zhaoqier the issue you are experiencing with the CoreML model likely stems from an inconsistency in the model output keys. Specifically, the error message To resolve this issue, you can modify the model's output to ensure it matches the expected format. In the meantime, make sure to use the latest YOLOv5 version from the official GitHub repository to ensure you have the most up-to-date fixes and improvements. If you encounter any further difficulties, feel free to reach out for more assistance. |
Search before asking
YOLOv5 Component
No response
Bug
Environment
Running in Google Colab and on device (2014 Mac mini) having same issue.
YOLOv5 🚀 v6.0-76-g79bca2b torch 1.9.0+cu111 CPU
Minimal Reproducible Example
! git clone https://github.com/ultralytics/yolov5
! cd yolov5
! pip install -r /content/yolov5/requirements.txt
! pip install -U coremltools==5.0 onnx scikit-learn==0.20.0
! pip install torch
! python /content/yolov5/export.py --weights yolov5s.pt --img 640 --batch 1
Additional
Cannot export model to coreml format. Having no issues exporting model to onnx or TorchScript.pt format
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: