pythontensorflowonnxtensorflow-hubtf2onnx

Convert a model from tf_hub to onnx using tf2onnx


I downloaded a model from tensorflow hub, and then tried to convert it into onnx using tf2onnx (https://github.com/onnx/tensorflow-onnx).

However the model does not seem to work properly after conversion.

When I look at the onnx file that is generated using Netron, the input layer has dimensions float32[unk__4256,unk__4257,unk__4258,3]. I believe this is due to the dynamic dimensions of the input model. However, as far as I know, this should not necessarily be an issue.

Is there any way to override the dynamic shape of the model and force it to have a particular one during conversion?

I looked around and saw that other people had similar unknown input/output layers with other models, but it seemed to work anyway.

Thanks in advance for your help!


Solution

  • I found an option to override the shape of the input layer. The command should be:

    python -m tf2onnx.convert --saved-model model_path --output model.onnx --opset 17 --inputs 'input_0:0[16,100,100,3]'
    

    where input_0 is the name of my input layer.

    Hope this is helpful to someone else