Hi,
I'm trying to convert my trained model (custom data) from ONNX to CoreML using onnx-coreml (latest git version), however I get the following error:
...
170/208: Converting Node Type Concat
171/208: Converting Node Type Reshape
Traceback (most recent call last):
File "convert_onnx_coreml.py", line 14, in <module>
custom_conversion_functions = {})
File "/folder/coremlenv/lib/python2.7/site-packages/onnx_coreml/converter.py", line 469, in convert
_convert_node(builder, node, graph, err)
File "/folder/coremlenv/lib/python2.7/site-packages/onnx_coreml/_operators.py", line 1927, in _convert_node
return converter_fn(builder, node, graph, err)
File "/folder/coremlenv/lib/python2.7/site-packages/onnx_coreml/_operators.py", line 509, in _convert_reshape
"CoreML only supports Reshape layer when the target shape is static and known apriori")
File "/folder/coremlenv/lib/python2.7/site-packages/onnx_coreml/_error_utils.py", line 71, in missing_initializer
format(node.op_type, node.inputs[0], node.outputs[0], err_message)
ValueError: Missing initializer error in op of type Reshape, with input name = 334, output name = 352. Error message: CoreML only supports Reshape layer when the target shape is static and known apriori
Has anyone had an issue with this as well? Am I missing an option when I call the convert function (so far I only change the option add_custom_layers to True from the default values. Or is there another tool to convert the model?
Thanks!
Hello, thank you for your interest in our work! This is an automated response. Please note that most technical problems are due to:
git clone version of this repository we can not debug it. Before going further run this code and ensure your issue persists:sudo rm -rf yolov3 # remove exising repo
git clone https://github.com/ultralytics/yolov3 && cd yolov3 # git clone latest
python3 detect.py # verify detection
python3 train.py # verify training (a few batches only)
# CODE TO REPRODUCE YOUR ISSUE HERE
train_batch0.jpg and test_batch0.jpg for a sanity check of training and testing data.If none of these apply to you, we suggest you close this issue and raise a new one using the Bug Report template, providing screenshots and minimum viable code to reproduce your issue. Thank you!
I'm using the default repo: I have coremltools>=2.0 and onnx_coreml installed. The code I try to use for convertion is this:
import onnx
from onnx_coreml import convert
model = onnx.load("converted.onnx")
convert(model,
mode=None,
image_input_names=['input1'],
preprocessing_args={},
image_output_names=['output1', 'output2'],
deprocessing_args={},
class_labels=None,
predicted_feature_name=None,
add_custom_layers = True,
custom_conversion_functions = {})
If add_custom_layers is set to false, I get this error:
Traceback (most recent call last):
File "convert_onnx_coreml.py", line 15, in <module>
custom_conversion_functions = {})
File "/home/dock/.conda/envs/tennisapp_py/lib/python3.7/site-packages/onnx_coreml/converter.py", line 459, in convert
_check_unsupported_ops(graph.nodes)
File "/home/dock/.conda/envs/tennisapp_py/lib/python3.7/site-packages/onnx_coreml/converter.py", line 145, in _check_unsupported_ops
','.join(unsupported_op_types)))
NotImplementedError: Unsupported ONNX ops of type: Shape,Gather
I'm using the v6 release of https://github.com/ultralytics/yolov3 to export the onnx file.
Any ideas?
@lp55 were you ever able to resolve this? I'm seeing the same error.
This issue is stale because it has been open 30 days with no activity. Remove Stale label or comment or this will be closed in 5 days.
@lp55 do you solve the issue? same error with yolact network for segmentation task. looking forward to your reply
Hi, I never did solve this. While this repo says "YOLOv3 in PyTorch > ONNX > CoreML > iOS" on the title it didn't work and it provides no documentation on how it should be done to convert the weights to CoreML. I gave up on this repo and went to Tensorflow -> CoreML route. I would prefer to use pytorch, but in the end I needed something that worked, and this didn't.
Hi, I never did solve this. While this repo says "YOLOv3 in PyTorch > ONNX > CoreML > iOS" on the title it didn't work and it provides no documentation on how it should be done to convert the weights to CoreML. I gave up on this repo and went to Tensorflow -> CoreML route. I would prefer to use pytorch, but in the end I needed something that worked, and this didn't.
I try to install onnx-coreml by source code(coreml developer suggest ), but it did't work too.
Do you have some dynamic op in your network? it might be the cause
I was able to solve this, and successfully get yolo to run on an iPad in realtime. It was complicated to get everything working. I'm writing a blogpost that I hope to release soon detailing what I did. Will update you with the link when I publish it.
I was able to solve this, and successfully get yolo to run on an iPad in realtime. It was complicated to get everything working. I'm writing a blogpost that I hope to release soon detailing what I did. Will update you with the link when I publish it.
Hi @pannaf. Were you able to convert Yolo3 to CoreML? If yes can you please share the workload? Thanks! :)
@pannaf Thanks for sharing the information here. I am also wondering how to do this? Do you succeed to convert the model?
Thanks
Most helpful comment
I was able to solve this, and successfully get yolo to run on an iPad in realtime. It was complicated to get everything working. I'm writing a blogpost that I hope to release soon detailing what I did. Will update you with the link when I publish it.