H5 weights to realtime classifier on jetson

I have an h5 weights file, and I wanted to create a real-time image classifier(not object-detector) on Jetson. I referenced this GitHub page: GitHub - NVIDIA-AI-IOT/tf_to_trt_image_classification: Image classification with NVIDIA TensorRT from TensorFlow models.. However, I was confused as to 1) if it applied to my situation and 2) how it actually worked. I would sincerely appreciate any help!
Thanks

Hi,

It’s recommended to use TensorRT for real-time inference on Nano.

1. First, please convert your model into ONNX format.
You can achieves this by using below keras2onnx directly:

2. Then you can deploy the ONNX model with TensorRT directly.

/usr/src/tensorrt/bin/trtexec --onnx=[your/model]

Thanks,

When I try to convert, I get the follow error. AttributeError: 'KerasTensor' object has no attribute 'graph'
Many other people are also encountering this issue, so I was wondering if you had any other alternatives?
Thanks

For anyone who faces this issue, I referenced this link:python - Why keras2onnx.convert_keras() function keeps getting me error "'KerasTensor' object has no attribute 'graph'" - Stack Overflow.
Also use model.save not model.save_weights. I also used TF 2.3.

Hello @AastaLLL , now when I try to run my onnx model using the command you gave I get the following error.
[04/23/2021-22:51:46] [W] [TRT] 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. [04/23/2021-22:51:48] [E] [TRT] Network has dynamic or shape inputs, but no optimization profile has been defined. [04/23/2021-22:51:48] [E] [TRT] Network validation failed. [04/23/2021-22:51:49] [E] Engine creation failed [04/23/2021-22:51:49] [E] Engine set up failed &&&& FAILED TensorRT.trtexec # /usr/src/tensorrt/bin/trtexec --onnx=save.onnx
Many people point this issue to TensorRT, and not the ONNX model. Do you have any advice for me?
Thanks

Hi,

Could you try the command mentioned in the below comment:

Thanks.

What do I put in the --optShapes=[name].

Hi

The size of your input data.

Thanks.