Jetson Nano - Training image classification models

So… I followed the tutorial from Jetson AI Fundamentals from here
I encounter the problem when it comes to the running final command “imagenet --model=models/tools/resnet18.onnx --labels=data/tools/labels.txt --input_blob=input_0 --output_blob=output_0 csi://0.”

Everything seem to work perfectly, no errors, camera starts but I think there is no detection being made. There is no banner in upper-left corner showing name of item with percentage. Although when I type just “imagenet” program starts and camera detects items from the library (GoogleNet I guess).

I am doing every step carefully from tutorial but I have no clue how to solve my problem.

I’ll be grateful for any response.

Hi @sushi5005wot, what are the contents of your labels.txt?

Do you see any classification confidence results being printed out to the terminal? Can you post the terminal log? Thanks.

Hi @dusty_nv, thanks for your reply.

In labels.txt I have just 4 entries - “background, battery, bottle, foam.”

Here’s the terminal log file: terminallog.txt (9.5 KB).

I do not see anything suspicious, when launching cat_dog classification program I do not have problems.

Thank you in advance.

What accuracy did you train your PyTorch model to?

From looking at your log, the only way it would not print out any of the results, are if the confidence values are negative or very small (which typically means the model is invalid or not trained).

Can you try commenting out this line from jetson-inference/c/imageNet.cpp:525?

Then re-run make and sudo make install. It should now print out all the results from the network (these should be positive, where 1.0 = 100% confidence)

Hi @dusty_nv, thanks for your advice.

After commenting the line number 525 from imageNet.cpp object recognition works fine.

But what should I do to set everything up properly without commenting line 525? Mabye I should re-install whole PyTorch?

What kind of confidence values are output by that print statement after you uncomment it? Are they very small?

@dusty_nv well, it depends.

Confidence level for background is ~50%; for objects it is 40-70% (depends on the object.)

Every class has 100 pictures in total and I trained them for 64 epochs, so this should work way better.

That is strange that it has “normal” confidence values, even though you had to comment out that line. Can you try un-commenting it out and running it again? Maybe it was unrelated and the issue was with the model or TensorRT engine…

@dusty_nv it has pretty much the same confidence values, no matter if that line is commented out or not.

OK, and it is still working now even with that line the way it originally way (not commented out)? If so, I bet something else was going on, like for example the TensorRT engine needing refreshed based on your latest PyTorch model.

After uncommenting, upper-left corner statement is still shown, so commenting, then uncommenting solved this issue. That is kinda strange.
I guess I’ll try re-installing TensorRT engine and I will give some feedback then. Would you recommend any other useful tools/steps to build custom robot arm based on Jetson Nano?

Thanks in advance.

By refreshing the TensorRT engine, I meant the *.engine file that is created for your model (it should be in the same directory as your model). If you delete it, it will re-run the model optimizations and create a new *.engine file. I didn’t mean to indicate that you should re-install the TensorRT libraries or JetPack.

There was a cool robotic arm project posted recently using Jetson, check it out here:

1 Like

@dusty_nv alright, thanks for the information. It seem to be a very cool project! I’ll defenitely want to try this out, but it will be challenging.

Do you know if there is any hardware/software for Jetson Nano to communicate via EtherCat?

Hi @sushi5005wot, I’m not familiar with EtherCat - you may want to open a new topic, or try searching the forums. Here is one I found about it: