-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
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
Change Upsample Layer to support direct export to CoreML #133
Comments
Hello @dlawrences, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook , Docker Image, and Google Cloud Quickstart Guide for example environments. If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you. If this is a custom model or data training question, please note that Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:
For more information please visit https://www.ultralytics.com. |
@dlawrences thanks for the detailed problem breakdown and very clear details. I'm not sure that the .expand() operator is accomplishing the effect you are looking for. To verify your changes to the model, I would not train, I would simply run detect.py for anecdotal evidence, and run test.py for statistical comparison with the default model. In any case, we actually don't have any problem exporting upsample operations. iDetection works great with the current upsample operators. We do have a problem with a new layer in yolov5, the Focus module in the first layer. The stride 2 operations seem to be interpreted fine by onnx, but coreml is applying stride 2 to all dimensions rather than just the intended ones, though the error does not appear at export time, only at runtime on an iOS device. |
Thanks @glenn-jocher Would you be able to share the environment details using which you are able to do full export through ONNX to CoreML and if you are doing any pre-conversion clean-up steps? Really appreciate your feedback. Regards, |
I appreciate you sharing this with the community and your active development. Would you be able to share the environment details that you used when exporting to ONNX and CoreML? Thanks, |
@dlawrences we've updated export.py a bit to better support the 3 export channels (ONNX, TorchScript and CoremL). As we talked about however, these are simple first steps to point users in the right direction, they are not full export pipelines. See https://docs.ultralytics.com/yolov5/tutorials/model_export |
Cheers I had a look - wouldn't you need to specify image scaling as well?
I know you do specify it during inference:
|
Yes, I believe you are correct! Can you submit a PR for this bug fix please? |
Sure. Check out #321 |
@dlawrences |
🚀 Feature
The default Upsample Layer seems to not be supported for CoreML conversion through ONNX. It needs to be changed to a simpler Upsample Layer that fixes the Slice operation.
Motivation
When converting exported ONNX model that has resulted from models/onnx_export.py, the following issue is encountered:
What I also tried so far
Changed default Upsample Layer params
I have also changed the Upsample Layer params from
to
This does not fix the issue above.
Added custom Upsample Layer and replaced model definition
I have defined a custom Upsample Layer:
and updated model definition to:
This does fix the conversion issue above from ONNX to CoreML, however it introduces a different issue which I don't how to fix. The loss on the validation dataset sky rockets, thus the performance quickly goes to zero.
image shows TensorBoard logs of model that uses torch Upsample Layer (bue) and of model that uses custom Upsample Layer defined above (orange)
Any thoughts?
Thanks
The text was updated successfully, but these errors were encountered: