onnx / onnxmltools

ONNXMLTools enables conversion of models to ONNX
https://onnx.ai
Apache License 2.0
992 stars 180 forks source link

Unsupported shape calculation for operator customModel #379

Open brodmo opened 4 years ago

brodmo commented 4 years ago

Hi, I'm trying to convert a sound classification model created with TuriCreate from CoreML to ONXX with the following code:

import coremltools
import onnxmltools

input_coreml_model = 'model.mlmodel'
output_onnx_model = 'model.onnx'
coreml_model = coremltools.utils.load_spec(input_coreml_model)
onnx_model = onnxmltools.convert_coreml(coreml_model)
onnxmltools.utils.save_model(onnx_model, output_onnx_model)

I get ValueError: Unsupported shape calculation for operator customModel on line 7.

jiafatom commented 4 years ago

Can you share the model, please?

brodmo commented 4 years ago

Here you go

jiafatom commented 4 years ago

You need specify the function customModel as a parameter custom_conversion_functions in convert_coreml, otherwise it does not know what customModel is.

brodmo commented 4 years ago

Oh okay, that makes sense I guess. Any idea where this custom shape calculation would typically be specified? I've dug through the source code of Turi Create but to no avail.

jiafatom commented 4 years ago

hmm, there is an example in skl2onnx, see here for example.

brodmo commented 4 years ago

Doing the same thing gives me an IndexError. Maybe the sound classifier is just written in such a way that it can't be converted easily.

mpmontanez commented 4 years ago

I've run into the same issue, but it's unclear to me how the customModel conversion function should be defined. Did you find a solution for this @mbroedel ?

brodmo commented 4 years ago

Nope. But the turicreate sound classification toolkit isn't all that great anyways, so you can build one on your own that has comparable performance with relative ease using Keras and VGGish.

mpmontanez commented 4 years ago

Thanks @mbroedel - I'm trying to use turicreate for a recommender model. At this point, I'm looking into alternative tools as well.