Thank you for your answer.
In fact, my ONNX model is generated with INT64 weights, and the ONNX parser tries to cast them down to INT32. A warning message related to this conversion is shown when I run the program “sample.py”.
However, I’m afraid that the errors have more to do with the input shape.
In this sense, I have modified the source code of the program which makes the prediction, but it is still not working.
I attach the modified program, and the Google Colaboratory notebook I wrote for generating the ONNX file model (as a PDF file). This notebook trains the MNIST model and exports it to ONNX format.
In the Colab notebook, the statement that performs the conversion of the saved model to ONNX format is:
proc = subprocess.run('python -m tf2onnx.convert --saved-model MNIST_Keras ’
‘–output MNIST_Keras.onnx --opset 12’.split(),
capture_output=True)
I don’t know if the statement should be completed with more parameters in order to generate the ONNX model with INT32 weights and to solve the errors related with the input shape.
Finally, I also show the error messages:
josemari@nano:~/Documents/Py/MNIST_ONNX$ python3 sample.py -d data
WARNING: data/mnist does not exist. Trying data instead.
Parsing ONNX file and building engine…
[TensorRT] WARNING: onnx2trt_utils.cpp:220: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[TensorRT] ERROR: Network has dynamic or shape inputs, but no optimization profile has been defined.
[TensorRT] ERROR: Network validation failed.
Engine creation failed. Exiting…
josemari@nano:~/Documents/Py/MNIST_ONNX$
That’s all. I look forward to your answer. Thank you.
sample.py (4.6 KB)
tf2onnx_MNIST.ipynb.pdf (95.8 KB)