Imagenet failed during static processing images with TensorRT - I don't now why/ Please help or explain

I collect my own Classification Dataset of 2 classes, train it on ResNet-18 by ( train a ResNet-18 by PyTorch) successfully: and model_best.pth are in the models directory. After that I convert the model to ONNX and receive resnet18.onnx- OK. But during run static image processing test with imagenet I receive [TRT] error message:
= = = = = = = = = = = = = = = = =
[TRT] binding to input 0 input_0 binding index: 0
[TRT] binding to input 0 input_0 dims (b=1 c=3 h=224 w=224) size=602112
[TRT] binding to output 0 output_0 binding index: 1
[TRT] binding to output 0 output_0 dims (b=1 c=2 h=1 w=1) size=8
[TRT] device GPU, models/compumou_crimper/resnet18.onnx initialized.
[TRT] loaded 4 class labels
[TRT] didn’t load expected number of class descriptions (4 of 2)
[TRT] imageNet – failed to load synset class descriptions (4 / 4 of 2)
[TRT] imageNet – failed to initialize.
jetson.inference – imageNet failed to load built-in network ‘googlenet’
Traceback (most recent call last):
File “/usr/local/bin/”, line 50, in
net = imageNet(, sys.argv)
Exception: jetson.inference – imageNet failed to load network
= = = = = = = = = =
ten days before I run this test with another model without such messages and now I cannot understand what do I do wrong. And why imagenet try to load ‘googlenet’ when I use ResNet-18?
Help me please, folk!

Hi @vkray, can you check your model’s labels.txt file? It would seem that it has 4 classes in the labels.txt instead of 2 like your model expects.

Hi @dusty_nv,  I run imagenet with parameter --labels=$DATASET/labels.txt  when DATASET=data/compumou_crimper

My dataset consist of two classes: "compumou" and "crimper" and (I checked it) labels.txt is:
- - - - - - - - - - - - - - - - - 
- - - - - - - - - - - - - - - - 
=> two classes.

right now I am out of our class with jetson nano, but I check labels.txt ASAP and will inform you.

By the way: I told  "ten days before I run this test with another model " with success,  both static and dynamic. And that case was 4-classes model.

OK, thank you - my guess is the labels.txt has 4 classes in it. I would double-check that the labels.txt being loaded by imagenet program is the one from your model that has 2 classes.

Hi Dusty_NV, According Your advise I’ve (double) checked labels.txt regarding my classes: “compumou” and “crimper” - yes, it contains only two strings: “compumou” and “crimper”. After that i retrain my dataset by, convert the resulting model to ONNX (resnet18.onnx) and start the Live Camera Program = imagenet … /dev/video2. You can see the video on jetson nano for MPEI starter execution.Rxample One. - YouTube -it works !!! (sorry for non-english comment here) ThanXs for the help.

OK great, happy to help - glad you were able to get it working!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.