import tensorflow as tf import torch import tf2onnx, onnx2torch BATCH_SIZE = 32 DEVICE = "cuda" spec = (tf.TensorSpec((BATCH_SIZE, 3, 224, 224), tf.float32, name="input"),) onnx_model, _ = tf2onnx.convert.from_keras(tf_model, input_signature=spec) converted_model = onnx2torch.convert(onnx_model)