Open Tasfa opened 2 years ago
coremltools == 4.0 onnxmltools == 1.10.0
The convert code is:
import onnxmltools import coremltools # Load a Core ML model coreml_model = coremltools.utils.load_spec('my.mlmodel') # Convert the Core ML model into ONNX onnx_model = onnxmltools.convert_coreml(coreml_model, target_opset=11) # Save as protobuf onnxmltools.utils.save_model(onnx_model, 'my.onnx')
There is an error when convert coreml model to onnx。
WARNING:root:scikit-learn version 1.0.1 is not supported. Minimum required version: 0.17. Maximum required version: 0.19.2. Disabling scikit-learn conversion API. WARNING:root:TensorFlow version 2.6.0 detected. Last version known to be fully compatible is 2.3.1 . WARNING:root:Keras version 2.6.0 detected. Last version known to be fully compatible of Keras is 2.2.4 . Traceback (most recent call last): File "/Users/xxx/Work/Projects/gitlab/opCounter/mlmodel2onnx.py", line 6, in cML2ONNX onnx_model = onnxmltools.convert_coreml(coreml_model,target_opset=11) File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/onnxmltools/convert/main.py", line 17, in convert_coreml return convert(model, name, initial_types, doc_string, target_opset, targeted_onnx, File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/onnxmltools/convert/coreml/convert.py", line 57, in convert topology = parse_coreml(spec, initial_types, target_opset, custom_conversion_functions, custom_shape_calculators) File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/onnxmltools/convert/coreml/_parse.py", line 463, in parse_coreml topology.compile() File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/onnxconverter_common/topology.py", line 678, in compile self._infer_all_types() File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/onnxconverter_common/topology.py", line 553, in _infer_all_types operator.infer_types() File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/onnxconverter_common/topology.py", line 107, in infer_types get_shape_calculator(self.type)(self) File "/Users/xxx/.pyenv/versions/3.9.6/lib/python3.9/site-packages/onnxmltools/convert/coreml/shape_calculators/neural_network/Concat.py", line 21, in calculate_concat_output_shapes raise RuntimeError('Only dimensions along C-axis can be different') RuntimeError: Only dimensions along C-axis can be different
I had the same problem. Did you solve it?
coremltools == 4.0 onnxmltools == 1.10.0
The convert code is:
There is an error when convert coreml model to onnx。