ultralytics icon indicating copy to clipboard operation
ultralytics copied to clipboard

Core ML nms=True' is not available for end2end models. Forcing 'nms=False'.

Open philipperemy opened this issue 1 year ago β€’ 6 comments

Search before asking

  • [X] I have searched the Ultralytics YOLO issues and found no similar bug report.

Ultralytics YOLO Component

Model Export

Bug

Ultralytics 8.3.3 πŸš€ Python-3.11.6 torch-2.4.0 CPU (Apple M1 Max) YOLOv10m summary (fused): 369 layers, 16,451,542 parameters, 0 gradients, 63.4 GFLOPs

PyTorch: starting from '/Users/premy/PycharmProjects/weeds-onions/models/hemp-yolov10-medium-20240708/weights.pt' with input shape (1, 3, 1024, 1024) BCHW and output shape(s) (1, 300, 6) (32.0 MB)

CoreML: starting export with coremltools 8.0... CoreML: WARNING ⚠️ 'nms=True' is not available for end2end models. Forcing 'nms=False'.

Does someone know why? It's a YOLO v10 medium model for object detection with just one class.

Does it mean all YOLO v10 can't be exported?

Environment

Python 3.11 Mac OS

Minimal Reproducible Example

model = YOLO(weights)
model_dir = model.export(format='mlpackage', nms=True)  # creates 'yolo11n.mlpackage'

Additional

No response

Are you willing to submit a PR?

  • [ ] Yes I'd like to help by submitting a PR!

philipperemy avatar Oct 15 '24 06:10 philipperemy

YOLOv10 doesn't use NMS.

Y-T-G avatar Oct 15 '24 06:10 Y-T-G

πŸ‘‹ Hello @philipperemy, thank you for reaching out and using Ultralytics πŸš€!

For your query regarding the Core ML export issue where 'nms=True' is not available for end2end models, it sounds like a concern with the integration between Core ML tools and YOLO. This is an automated response to guide you through some initial steps while an Ultralytics engineer also looks into your issue soon.

If this is a πŸ› Bug Report, thank you for already providing a minimum reproducible example. It's helpful for diagnosing the problem more efficiently.

Here are some suggestions while we investigate:

  1. Ensure you’re running the latest version of the ultralytics package and dependencies. You can upgrade with:

    pip install -U ultralytics
    
  2. Double-check that you're using an appropriate environment. YOLO models should be run in environments that adhere to all requirements. It's also a good idea to test in different environments, such as Google Colab or a verified Docker setup.

  3. Explore further documentation:

    • For exporting models, take a look at our export guide.
    • For understanding non-maximum suppression in exports, this Core ML section might be useful.

Join our community channels for real-time discussions and support:

Feel free to follow up or provide additional details as necessary. Your patience is appreciated while we work on finding a resolution!

UltralyticsAssistant avatar Oct 15 '24 06:10 UltralyticsAssistant

@Y-T-G okay gotcha but do you know how can I get the preview with MacOS? I was using NMS with yolo v8 before for that. Otherwise the preview is not available and the model is unusable.

image

philipperemy avatar Oct 15 '24 06:10 philipperemy

That's probably a CoreML issue. The model should still work if it works in ultralytics

Y-T-G avatar Oct 15 '24 07:10 Y-T-G

yes it does work seamlessly with ultralytics. The issue is the export to Core ML. I will leave it open for this reason.

philipperemy avatar Oct 15 '24 07:10 philipperemy

You can run the Core ML model in ultralytics too. If it works, then there isn't an issue with export.

Y-T-G avatar Oct 15 '24 07:10 Y-T-G

It appears that the ONNX conversion might have the same issue.

In the screenshot, the left side shows the ONNX model without the nms=True option, while the right side includes the nms=True option. The results seem to have the same architecture. Screenshot 2024-11-03 at 0 35 57

DenDen047 avatar Nov 02 '24 22:11 DenDen047

@DenDen047 ONNX export in ultralytics doesn't support nms=True. Only arguments listed in the table for the format is supported.

https://docs.ultralytics.com/modes/export/#export-formats

Y-T-G avatar Nov 02 '24 23:11 Y-T-G

Well, long story short, you'll have to implement the NMS yourself with Swift because it is no longer supported. It used to be up to Yolo v8 (if my memory is correct).

philipperemy avatar Nov 04 '24 05:11 philipperemy

Thank you for your input. Implementing NMS in Swift is indeed a viable solution for handling post-processing in Core ML models. If you need further assistance, feel free to ask.

glenn-jocher avatar Nov 04 '24 15:11 glenn-jocher

πŸ‘‹ Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

  • Docs: https://docs.ultralytics.com
  • HUB: https://hub.ultralytics.com
  • Community: https://community.ultralytics.com

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 YOLO πŸš€ and Vision AI ⭐

github-actions[bot] avatar Dec 05 '24 00:12 github-actions[bot]

Well ideally it should be part of the ultralytics framework.

philipperemy avatar Dec 05 '24 07:12 philipperemy

Thank you for the suggestion. While NMS functionality for exported models is not currently integrated, it remains a feature request for potential future development. Contributions via PRs are always welcome!

glenn-jocher avatar Dec 06 '24 06:12 glenn-jocher

nms is supported for CoreMLTools. YOLOv10 doesn't use or need NMS, so it doesn't export with nms. YOLO11 is similar to YOLOv8 and also uses NMS.

Y-T-G avatar Dec 10 '24 23:12 Y-T-G

For preview, maybe try exporting with format="mlmodel"

Y-T-G avatar Dec 10 '24 23:12 Y-T-G

πŸ‘‹ Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

  • Docs: https://docs.ultralytics.com
  • HUB: https://hub.ultralytics.com
  • Community: https://community.ultralytics.com

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 YOLO πŸš€ and Vision AI ⭐

github-actions[bot] avatar Jan 10 '25 00:01 github-actions[bot]