detecting your own Datasets

Hello,I am Andy. I stay in Taiwan. I am a student. I want to ask a question. I used this website:https://github.com/dusty-nv/jetson-inference/blob/master/docs/pytorch-collect.md to train my new image file on googlenet. The label.txt are car,doormax,doormid,doormin.When I detect car ,it displayed class #9. How can I solve it?

Hi,

Do you feed your label file as an input argument into imagenet-camera.py?

imagenet-camera.py ... --labels=$DATASET/labels.txt

Thanks.

I inputed the terminal line:DATASET=/home/andy/hev/jetson-inference/python/training/classification. Then,I inputed: imagenet-camera.py … --labels=$DATASET/labels.txt --camera=/dev/video0. Because my camera is usb camera. But the label is wrong. It should display car.

Also,before I had trained:

python train.py --model-dir=GoogleNet-ILSVRC12-subset /home/andy/hev/jetson-inference/python/training/classification

python onnx_export.py --model-dir=GoogleNet-ILSVRC12-subset

DATASET=/home/andy/hev/jetson-inference/python/training/classification

Then,I inputed:

imagenet-camera --model=GoogleNet-ILSVRC12-subset/resnet18.onnx --input_blob=input_0 --output_blob=output_0 --labels=$DATASET/labels.txt --camera=/dev/video0

It should display car.But the label is wrong.

Hi Andy, recommend that you start with the imagenet-console program first on a test image from your dataset, to make sure that your model is working appropriately. Since it is saying “class #9”, it appears that it isn’t loading the labels file, or that the model has more classes than the labels file.

Is your dataset the GoogleNet-ILSVRC12-subset? Because that has more than the 4 classes you listed above (car,doormax,doormid,doormin)

Can you share the directory structure of your dataset? I ask because it is not typically stored directly in jetson-inference/python/training/classification directly, and also because of the references in your script to GoogleNet-ILSVRC12-subset which are different than the 4 classes you listed.

The dataset should have ‘train’ and ‘val’ subdirectories, with directories for each class under those (which should be alphabetized). Like this:

~/datasets/my-dataset
    > train
         - car
         - doormax
         - doormid
         - doormin
     > val
         - car
         - doormax
         - doormid
         - doormin

Please share the terminal log from when you run imagenet-console program, so we can check the inputs/outputs of the network. It would appear that now, there are more than 4 outputs if it is classifying as class #9.

Also, have you been able to train and run the Cat/Dog or Plants model from the tutorial ok?

I inputed the line:

          imagenet-console ... --labels=$DATASET/labels.txt 

The result is below picture.

And I inputed the line:

 ./imagenet-console 15112019-155105.jpg output_1.jpg

This picture is in /home/andy/hev/jetson-inference/python/training/classification/train/car.

The result is below picture.

my dataset is

/home/andy/hev/jetson-inference/python/training/classification

> train
     - car
     - doormax
     - doormid
     - doormin
> test
     - car
     - doormax
     - doormid
     - doormin
> val
     - car
     - doormax
     - doormid
     - doormin

And I use a virtual environment.

I remembered I changed GoogleNet-ILSVRC12-subset’s labels.txt.
The labels(car,doormax,doormid,doormin) are all in GoogleNet-ILSVRC12-subset folder.

I inputed the line:

imagenet-console --model=GoogleNet-ILSVRC12-subset/resnet18.onnx --input_blob=input_0 --output_blob=output_0 --labels=$DATASET/labels.txt 15112019-155047.jpg output_1.jpg

This picture’s label should display car,but it displays the Class #9.

I trained Cat/Dog model. It is not problem.
cat.jpg
dog.jpg

Please provide the terminal log from running this. The model that you are loading must have more than the 4 classes. Maybe the files got mixed up with the GoogleNet-ILSVRC12-subset during training?

you said:

Please provide the terminal log from running this. The model that you are loading must have more than the 4 classes. Maybe the files got mixed up with the GoogleNet-ILSVRC12-subset during training?

OK, so in ‘Screenshot from 2019-11-20 22-30-20.png’, it shows that your model actually has 18 classes - not 4.

I would double-check that when you trained the model, you provided the training script with the correct location of your dataset. Somehow the PyTorch training script is finding 18 classes. When you first run the training script, it will print out all the classes it finds (on the line '=> dataset classes: ')

If you continue to have problems, please provide the console log of your training session.

So can I delete GoogleNet Network to reload this network? Then,the label txt are car,doormax,doormid,doormin.And I retrained the network.

Thank you help.

I would make fresh directories for your dataset and new network to avoid any confusion with the GoogleNet-ILSVRC12-subset. Store your dataset in it’s own directory instead of /python/training/classification

Thank you.I solved this problem,because my dataset stored in /home/andy/hev/jetson-inference/python/training/classification/mydataset/car.

I am using the imagenet-camera.py demo script to try to train my dataset. I have 3 objects which are background, perrier and milk. I can detect the background, but when I place the milk in front of the camera, it detects the object as milk, if I place the perrier, it is detected as milk. Do I need to define the label in order in someplace when I use imagenet-camera.py, Can you give us some clue how to resolve this issue?

script I run: imagenet-camera.py --model=perrier/resnet18.onnx --camera=/dev/video0 --width=640 --height=360 --input_blob=input_0 --output_blob=output_0 --labels=/media/paul/XSSD/XProject/myobjects/labels.txt

label.txt is as following

background
perrier
milk

image file dataset is as following

here is the script I use to train the model:
python train.py --model-dir=perrier /media/paul/XSSD/XProject/myobjects

Hi @kwok.paul, the labels should be in alphabetical order. This is because PyTorch gets the class names of your dataset from it’s directory structure, which is also sorted alphabetically when it is read by the OS.

So if you change your labels.txt file to below I think it should be corrected:

background
milk
perrier