Imagenet fails to load expected number of class descriptions

I am training the resnet-18 model on a 4 new classes. I followed the steps here https://github.com/dusty-nv/jetson-inference/blob/master/docs/pytorch-collect.md. The issue is that after completing all steps and attempting to run imagenet-console with this command “imagenet-console --model=RoadDetection/resnet18.onnx --input_blob=input_0 --output_blob=output_0 --labels=$DATASET/labels.txt $DATASET/P1130932.JPG tested.JPG” I get the following errors:
imageNet – loaded 4 class info entries
imageNet – didn’t load expected number of class descriptions (4 of 1)
imageNet – failed to load synset class descriptions (4 / 4 of 1)

Searching online does not help as nobody else seems to have had this particular issue. Any help that can be provided is appreciated.

Hi gstewart9727, it would seem that the model only has one output class. Are you sure that it was trained on 4 classes?

Hi dusty, I am positive I trained it on 4 classes. But funny enough I have actually managed to resolve the issue.
When I first started working on the project I trained it on one class to try and see how it worked. I later trained it on 4 classes with the same name. I believe there is some file that is created when the model is trained which contains class descriptions, but this file is not updated on subsequent training sessions.
So to resolve this I deleted the file in “jetson-inference/python/training/imagenet/” and then re-trained the model.
It now seems to be working properly, thank-you for your time.

Aha, ok cool - glad you got it working.

So the training script saves the model with the highest accuracy to best_model.pth, which is what the onnx_export.py script exports by default. It doesn’t contain the class descriptions (those are only contained in the text file which the training script never touches/uses), however in theory it could be possible that this best_model.pth checkpoint was left over from the previous run. Or maybe the 4-class run hadn’t been exported to ONNX that time.