Custom Yolov5 on Deepstream 6.0

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) Jetson
• DeepStream Version 6.0
• JetPack Version (valid for Jetson only) 4.6
• TensorRT Version 8
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)

• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

We have had the most success in running the off-the-shelf Yolov5-small (the one trained on the Coco dataset) on an AGX Xavier that has JetPack 4.6 and Deepstream 6.0. I will call this model yolov5-small-coco for our future reference. We are using GitHub - marcoslucianops/DeepStream-Yolo: NVIDIA DeepStream SDK 6.0 configuration for YOLO models.

Next we tried to run a custom trained YoloV5-small model in the same environment. The model was trained using PyTorch and I trained on 7 classes on thermal images. I will call this model yolov5-small-thermal for our future reference. Other than the number of classes and the type of image, the basic config for yolov5-small is the same as in GitHub - ultralytics/yolov5: YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite. We generated the weights and config files for the new custom model and modified the config files in Deepstream-Yolo to match our new model. While the inference runs without errors and has a similar throughput as the yolov5-small-coco, we see a warning that may signal a bigger problem – “warning configured classes = 7 but network detects 80”. The accuracy of the model is also not very good, and it seems to pick the last class-label in the labels file more often than the other class labels. Note that the repo Deepstream-Yolo does not provide an option to explicitly set the number of classes in the code.

Has anyone experienced a similar issue?

Thank you!

In the file config_infer_primary_yoloV5.txt there is a config called num-detected-classes that is set to 80 in the YoloV5 default. Set that to the number of labels you have, here 7.

It might help to delete your engine file model_b1_gpu0_fp32.engine and make deepstream rebuild it to ensure it was built with the right number of detected classes and appropriate labels.

1 Like

Thank you so much! That really helped.

1 Like

No problem, glad it helped. Can you tell me if you saw an increase in performance after this change?

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