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)
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
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.