Skip to content

The model converted to coreml format always shows confidence 100 #87

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

Open
menghengmen opened this issue Mar 25, 2025 · 4 comments
Open
Labels
bug Something isn't working exports Model exports (ONNX, TensorRT, TFLite, etc.)

Comments

@menghengmen
Copy link

Python code

from ultralytics import YOLO

model = YOLO("yolo11n.pt")
model.export(format="coreml", nms=True, imgsz=640)

@UltralyticsAssistant UltralyticsAssistant added bug Something isn't working exports Model exports (ONNX, TensorRT, TFLite, etc.) labels Mar 25, 2025
@UltralyticsAssistant
Copy link
Member

👋 Hello @menghengmen, thank you for submitting a ultralytics/yolo-ios-app 🚀 Issue. To help us address your concern efficiently, please ensure you've provided the following information:

  1. For bug reports:

    • A clear and concise description of the bug
    • A minimum reproducible example MRE that demonstrates the issue
    • Your environment details (OS, Python version, package versions)
    • Expected behavior vs. actual behavior
    • Any error messages or logs related to the issue
  2. For feature requests:

    • A clear and concise description of the proposed feature
    • The problem this feature would solve
    • Any alternative solutions you've considered
  3. For questions:

    • Provide as much context as possible about your question
    • Include any research you've already done on the topic
    • Specify which parts of the documentation, if any, you've already consulted

In your case, it would be helpful to know:

  • The steps you followed after exporting the model to CoreML format
  • The exact CoreML output you're seeing that suggests a confidence of 100%
  • Any modifications or additional steps you performed after conversion

Please make sure you've searched existing issues to avoid duplicates. If you need to add any additional information, please comment on this issue. 😊

An Ultralytics engineer will review and assist you soon. Thank you for helping us improve! 🚀

@pderrenger
Copy link
Member

@menghengmen thanks for reporting this! To help us investigate, could you:

  1. Confirm you're using the latest ultralytics package (pip install -U ultralytics)
  2. Share the exact code you're using to run inference with the CoreML model?
  3. Verify if this occurs specifically when using nms=True vs nms=False?

The CoreML export with NMS adds non-maximum suppression layers which might affect confidence score handling. For reference, see the CoreML export documentation section on NMS integration.

@menghengmen
Copy link
Author

@menghengmen感谢您报告此事!为了帮助我们调查,您可以:

  1. 确认你正在使用最新的ultralytics软件包(`
Image

`)

  1. 分享您用于使用 CoreML 模型运行推理的确切代码?
  2. 验证使用nms=Truevs时是否专门发生这种情况nms=False

使用 NMS 的 CoreML 导出添加了非最大抑制层,这可能会影响置信度分数处理。有关参考,请参阅有关 NMS 集成的 CoreML 导出文档部分
2.code is use yolo-ios-app repositories

3.when use nms = False ,load the mlmodel will crash at this // Retrieve class labels directly from the CoreML model's class labels, if available.
guard let classLabels = mlRobotModel.modelDescription.classLabels as? [String] else {
fatalError("Class labels are missing from the model description")
}

@pderrenger
Copy link
Member

Thanks for sharing the details! For the CoreML nms=False crash, ensure your model includes class labels by exporting with names specified:

model.export(format="coreml", nms=False, names=['class1', 'class2', ...])

When using nms=True, confidence scores are normalized during NMS processing. For implementation details, see the CoreML model metadata requirements in our docs. Let us know if you need more specific guidance! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working exports Model exports (ONNX, TensorRT, TFLite, etc.)
Projects
None yet
Development

No branches or pull requests

3 participants