-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Exported CoreML models are broken #948
Comments
👋 Hello @joebreaux, thank you for raising an issue about the Ultralytics HUB 🚀! We appreciate you taking the time to describe the problem and share example screenshots—it helps us a lot. An Ultralytics engineer will review this soon and provide further assistance. In the meantime, please check out the following HUB Docs for helpful resources that may provide context or solutions:
If this is indeed a 🐛 Bug Report, we kindly request that you provide a Minimum Reproducible Example (MRE) to help us effectively diagnose and resolve the issue. You can refer to our guidelines here for creating an MRE. In this case, it would be helpful to:
We understand that debugging deployment issues can be tricky, but providing these details will allow us to better assist you! 🛠️ Thank you again for your patience and for using Ultralytics HUB. We’ll be in touch! 🔍 |
@joebreaux thank you for providing detailed information and screenshots regarding the issue you're facing with CoreML model exports. Let's address this step-by-step:
If you continue to face issues despite these steps, please let us know with additional details, and we'll assist further. The Ultralytics community is constantly improving workflows, and your feedback is invaluable in resolving such challenges! 😊 |
@pderrenger To eliminate any potential issues from my application itself, I used the preview function within Xcode. This first screenshot is of model27-back.mlmodel which is what i downloaded several months ago. You will notice that its output matches the preview output from within the console. Here is the preview output within the console for model27. You can find this model within my account. Those above screenshots match as you would expect. I then used the console to generate the export (to eliminate any potential issues with my computer). When I export using the console I got model27.mlpackage. Here is the screenshot when its run through preview on Xcode: You should be able to use these same steps to reproduce. Simply export the model27 from my account and then run it using Xcode preview. Here is the image I ran through the model so that you can run the same image: Hopefully this allows you to reproduce. Let me know if you need anything else. |
@joebreaux thank you for the update, I'm attempting to reproduce now. |
@joebreaux CoreML export is working correctly for me on newly exported models (if your model is out of date it may need to be trained again with the latest version of For full NMS functionality make sure you select NMS in the advanced options tab when exporting to CoreML: |
@glenn-jocher I am using Add NMS when exporting. One thing to note, this does not affect every model and export. You will need to export with my specific models to see this behavior. Check model51 on my account. This was trained within the past few days. When exported, it has the same issue as model27. It works in console preview, but fails in Xcode preview - using the image from my last post. However, I have a model trained on a different data set called "seatbelt15". This was also trained within the past week. The export on this model works perfectly fine. That indicates its not something universally affecting all model exports. Can you take a look at my model51 to reproduce and determine why any model trained on that data set has this issue? |
@glenn-jocher We did some additional testing to try and better understand why some trained models have the issue and others dont. The first thing we did was remove a lot of the classes, which worked. These class labels worked without any issue in Xcode preview: We then added the rest of the "speed" labels back and trained. The only different between this one and the one above is that this one had 17 classes and the one above only had 7. This model failed in Xcode preview: We then remapped all of the speed classes to just be a single class called "speed". This model again worked in Xcode preview: I'm not quite sure what to make of this. Perhaps its when we have too many classes? Hopefully this helps you track down the issue. |
Using format=mlmodel resolves the issue. The model is then exported as .mlmodel and works correctly. |
Thank you for following up and confirming that exporting with For now, using If you have any additional findings or patterns that might help isolate the root cause (e.g., specific class counts, label naming conventions, etc.), feel free to share them here. Your detailed testing has already been incredibly helpful in diagnosing this issue! 😊 In the meantime, if you need further assistance or have other questions, don’t hesitate to ask. Thank you again for your patience and for working with us to identify this behavior! |
Search before asking
HUB Component
Models
Bug
After training a model, the exported CoreML version (with NMS) selected does not work correctly when used inside a swift project. Older models I trained and exported to the .mlmodel format worked correctly. However, the newer .mlpackage models do not work correctly.
I have tried exporting as CoreML and exporting as pytorch and then running yolo export model=model51.pt format=coreml imgsz=640 nms=True
The resulting model in both cases fails to perform correctly. The "preview" option within the console does show correct output. Here is an example of the preview output:
Here is an example when the CoreML version is run in a swift project. As you can see its detecting all sorts of things that are not in the image and location of the bounding boxes is all messed up.
If I use a model trained a few months ago that was exported as .mlmodel in the swift app, everything is fine. A good example of this is model27. I have a .mlmodel version I downloaded a few months ago - works fine. I just went and exported that exact model, this time it produced a .mlpackage and the resulting .mlpackage shows the same issue as above.
Environment
No response
Minimal Reproducible Example
No response
Additional
No response
The text was updated successfully, but these errors were encountered: