The retrained ssd_mobilenetv1 does not detect anything and the labels.txt file is not found

hi, i retrained and exported my model for ssd mobilenet v1, however when i start it, it does not detect anything.

I have been training it for 30 epochs and set the threshold = .1, but it did not work;this is the python script i used:

import cv2
import jetson.inference
import jetson.utils

net = jetson.inference.detectNet(‘ssd-mobilenet-v1’,[’–model=/home/user/Downloads/jetson-inference/python/training/detection/ssd/models/model_test/ssd-mobilenet.onnx’,’–input_blob=input_0’,’–output-cvg=scores’,’–output-bbox=boxes’,’–labels=/home/user/Downloads/jetson-inference/python/training/detection/ssd/models/model_test/labels.txt’],threshold = .1)

#net = jetson.inference.detectNet(‘ssd-mobilenet-v1’,threshold = .5)

cam = jetson.utils.gstCamera(640, 480,’/dev/video0’)
display = jetson.utils.glDisplay()

while display.IsOpen():
img, width, height = cam.CaptureRGBA()
detections = net.Detect(img, width, height)
display.RenderOnce(img, width, height)

given the error, I tried to test the model from run_ssd_example.py,I realized that it does not correctly detect the labels.txt file,I am attaching a photo in which everything is displayed.

i tried to rename the file many times and i searched for a solution on the internet but i could not find anything, could someone help me, thanks!

PS:I’m not sure how relevant this is, but the folder can only be changed as root

Can you try deleting the .engine file in your model’s directory, then re-running your Python detectNet program?

From your screenshot, it looks like you were trying to run run_ssd_example.py with the detectnet arguments. The way you would run it would be similar to:

# substitute path to the PyTorch .pth checkpoint with lowest loss below
python3 run_ssd_example.py mb1-ssd models/model_test/mb1-ssd-Epoch-27-Loss-5.31.pth models/model_test/labels.txt path/to/test_image.jpg

Note that run_ssd_example.py uses a .pth checkpoint, not the exported ONNX model. And you should select your .pth checkpoint that has the lowest loss (looks like it’s the one from Epoch 27). This script is useful for checking if the PyTorch model itself is capable of detecting objects, before it gets exported to ONNX and run with detectnet program.

This is normal if you are using the container. You can use sudo to modify the folder or the chown utility to change permissions of the folder.

hi @dusty_nv ,i removed the .engine file and it didn’t work; so i tried to test the pytorch model as you suggested and this is the output i got:

Inference time: 30.89335584640503
Found 0 objects. The output image is run_ssd_example_output.jpg

I also checked the photo and it doesn’t seem to detect anything

Would you know how i can move now, i am trying to use a dataset of a few photos just to understand how it works, do you think i should add more photos or should i continue training?

Hi @utente1480, how many images are in your dataset? Typically there are a few hundred at least.

hello @dusty_nv , about 130,now i’m trying to train them for 400 epochs