import tf2onnx
import onnx
# Example
inputs = Input( (128, 128, 1) )
# ... create model with inputs and layers
# ... train model
onnx_model, _ = tf2onnx.convert.from_keras(model, [
tf.TensorSpec(
shape=inputs.get_shape(),
# If input values are of type is float32
dtype=tf.float32)
],
# the opset to be used for the ONNX model, default is the latest
opset=13)