0

Is it possible to install tf2onnx, e.g. using conda to convert TF models programmatically in Python. Such as:

from tf2onnx import convert
convert(model_dir)

2 Answers 2

1

Yes it is possible. You can do a pip install also and to convert your model in ONNX format please refer to the following example: https://github.com/onnx/tutorials/blob/master/tutorials/TensorflowToOnnx-1.ipynb

Sign up to request clarification or add additional context in comments.

Comments

0

This is how I did it:

  import tf2onnx
  import onnx
  input_signature = (tf.TensorSpec((None, IMG_SIZE_H, IMG_SIZE_W, NUM_CHANNELS), tf.float32, name="image_input"),)
  onnx_model, _ = tf2onnx.convert.from_keras(model,input_signature)
  onnx.save(onnx_model, "model.onnx")

Not sure why you need the input_signature defined if the tf2onnx command-line is able to decode it from the saved model.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.