yolo-ios-app icon indicating copy to clipboard operation
yolo-ios-app copied to clipboard

The model converted to coreml format always shows confidence 100

Open menghengmen opened this issue 8 months ago • 4 comments

Python code

from ultralytics import YOLO

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

menghengmen avatar Mar 25 '25 12:03 menghengmen

👋 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! 🚀

UltralyticsAssistant avatar Mar 25 '25 12:03 UltralyticsAssistant

@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.

pderrenger avatar Mar 25 '25 23:03 pderrenger

@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") }

menghengmen avatar Mar 26 '25 01:03 menghengmen

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! 🚀

pderrenger avatar Mar 27 '25 03:03 pderrenger

@menghengmen It has been reported that NMS breaks on certain combinations of macOS and coremltools versions. Could you please update these to the latest versions and try again?

john-rocky avatar May 31 '25 01:05 john-rocky