Skip to content
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

Update CoreML model conversion to do pixel scaling as well #321

Merged
merged 2 commits into from
Jul 8, 2020

Conversation

dlawrences
Copy link
Contributor

@dlawrences dlawrences commented Jul 8, 2020

Hi

As agreed in #133 , in order to do proper inference with a model converted to CoreML, one has to also pass pixel scaling (if there is any done).

In detect.py, there is this specified:

img /= 255.0  # 0 - 255 to 0.0 - 1.0

I have updated the CoreML model conversion step to do this as well.

Cheers

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Improved CoreML model export with scaling in Ultralytics YOLOv5.

📊 Key Changes

  • Updated the CoreML export process to apply pixel scaling during conversion.
  • Explicitly set the image input scale to 1/255.0 with a zero bias.

🎯 Purpose & Impact

  • Ensures the CoreML model processes input images with the same scaling as used in YOLOv5's detect.py.
  • 📈 This change leads to more consistent performance between CoreML models and their original YOLOv5 counterparts.
  • Helps users deploy models to iOS devices with correct preprocessing parameters automatically set.

@glenn-jocher
Copy link
Member

@dlawrences great, thanks for spotting this!

@glenn-jocher glenn-jocher merged commit cd66092 into ultralytics:master Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants