I solved it myself.
I was able to convert the model distributed on TensorFlow Hub to ONNX format by using the following flow:
### Save as tflite format
# -->> for movenet
import tensorflow as tf
import tensorflow_hub as hub
model = tf.keras.Sequential(
[
hub.KerasLayer(
"https://www.kaggle.com/models/google/movenet/TensorFlow2/multipose-lightning/1",
trainable=False,
signature="serving_default",
signature_outputs_as_dict=True,
),
]
)
model.build([1, 256, 256, 3])
model.summary()
model.save("movenet-multipose-lightning")
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)
### Convert to ONNX format
$ python -m tf2onnx.convert --tflite converted_model.tflite --output converted_model_nchw_output.onnx --inputs-as-nchw serving_default_keras_layer_input:0
absl-py==2.2.1
astunparse==1.6.3
cachetools==5.5.2
certifi==2025.1.31
charset-normalizer==3.4.1
coloredlogs==15.0.1
flatbuffers==1.12
gast==0.4.0
google-auth==2.38.0
google-auth-oauthlib==0.4.6
google-pasta==0.2.0
grpcio==1.71.0
h5py==3.13.0
humanfriendly==10.0
idna==3.10
keras==2.9.0
Keras-Preprocessing==1.1.2
libclang==18.1.1
Markdown==3.7
MarkupSafe==3.0.2
mpmath==1.3.0
numpy==1.26.4
oauthlib==3.2.2
onnx==1.14.1
onnx-graphsurgeon==0.5.7
onnx2tf==1.26.9
onnxruntime==1.21.0
opt_einsum==3.4.0
packaging==24.2
protobuf==3.20.3
psutil==7.0.0
pyasn1==0.6.1
pyasn1_modules==0.4.2
requests==2.32.3
requests-oauthlib==2.0.0
rsa==4.9
six==1.17.0
sng4onnx==1.0.4
sympy==1.13.3
tensorboard==2.9.0
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tensorflow==2.9.0
tensorflow-estimator==2.9.0
tensorflow-hub==0.16.1
tensorflow-io-gcs-filesystem==0.37.1
tensorflow-neuron==1.0
termcolor==3.0.0
tf-keras==2.14.1
tf2onnx==1.13.0
typing_extensions==4.13.0
urllib3==2.3.0
Werkzeug==3.1.3
wrapt==1.17.2
The answer to how to fix batch_size is in the answer to the following question:
Solved : How can I save a model with input shape (1, None, None, 3) with None fixed to 256?