Convert ML Model using tf2onnx
Hi, I'm trying to add my ML model to the project, but I cant't figure out how to make it compatible with Lens Studio. There's a code snippet that reproduces the problem.
import tensorflow as tf
inputs = tf.keras.layers.Input(
shape=(224, 224, 3),
name="image"
)
x_one = tf.keras.layers.Conv2D(
filters=16,
kernel_size=3,
strides=2,
padding="same",
activation="sigmoid"
)(inputs)
x_two = tf.keras.layers.Conv2D(
filters=32,
kernel_size=3,
strides=2,
padding="same",
activation="sigmoid"
)(x_one)
x_three = tf.keras.layers.Conv2DTranspose(
16,
3,
strides=2,
padding="same",
use_bias=False,
)(x_two)
x_four = tf.keras.layers.Concatenate()([x_one, x_three])
x_five = tf.keras.layers.Conv2DTranspose(
3,
3,
strides=2,
padding="same",
use_bias=False,
)(x_four)
x_six = tf.keras.layers.Concatenate()([inputs, x_five])
model = tf.keras.Model(
inputs=[inputs],
outputs=[x_six],
name="test-model"
)
tf.keras.models.save_model(model, "test-model")
I converted this model to ONNX using tf2onnx and the first error I got is:
The ONNX model's ConvTranspose layer `auto_pad` attribute is a DEPRECATED attribute
Then I tried to delete these attributes and after that I got an error:
ONNX model ConvTranspose layer converter only supports same padding for height and width.
Lastly, I changed the pads atrribute to 1, 1, 1, 1 but I got the error
Shape mismatch in concat layer.
Do you have any suggestions what to do to fix these errors.