import tensorflow as tf, tf2onnx
model = tf.keras.models.load_model("model_transparent_blister_resnet_navy.h5", compile=False)  # or build in code
spec = (tf.TensorSpec([None, 128, 128, 3], tf.float32, name="input"),)
onnx_model, _ = tf2onnx.convert.from_keras(model, input_signature=spec, opset=18)
with open("model_transparent_blister_resnet_navy.onnx","wb") as f: f.write(onnx_model.SerializeToString())