marcoslucianops / DeepStream-Yolo

NVIDIA DeepStream SDK 7.0 / 6.4 / 6.3 / 6.2 / 6.1.1 / 6.1 / 6.0.1 / 6.0 / 5.1 implementation for YOLO models
MIT License
1.39k stars 344 forks source link

the engine can only predict one class #451

Open ChangXinze opened 10 months ago

ChangXinze commented 10 months ago

I compiled and ran "/opt/nvidia/deepstream/deepstream-6.1/sources/apps/sample_apps/deepstream-test3" with the model "yolov8n.pt" converted to ONNX. I used the video "sample_1080p_h264.mp4" for testing. I noticed that only the "Person" class is being recognized, while other classes such as "car" are failing to be recognized. When I use "yolov8n.pt" directly, it can recognize more than one class. Additionally, when I convert my custom model to onnx, it also only recognizes one class, with other classes failing.

My "Deepstream-Yolo" is the latest version, and both the "ultralytics" source code and the pip-installed version are up to date. However, I remember that this was working correctly in versions from two months ago.I don't remember the exact version at that time.

The above translation is from GPT.

my envs: ubuntu 20.04 deepstream 6.1.1 cuda11.7 python3.8 yolov8 dgpu:3070ti Laptop

The ONNX-generated engine file was successfully created, and the results are as shown in the following image.

yolo

Below are the prediction results provided by YOLO itself.

pt

2023-09-12 11-45-07屏幕截图

ChangXinze commented 10 months ago

I changed head to f630b10, it worked

marcoslucianops commented 10 months ago

Did you update the ONNX model with the new exporter and generated the engine file again?

dsconnol-impactai commented 9 months ago

Our organization had the exact same issue. We tried both a custom model built from YOLOv8n and YOLOv8x. Can also confirm rolling back to https://github.com/marcoslucianops/DeepStream-Yolo/commit/f630b10a8088398251bca7f2f50064b57fab06bb corrected the issue. I'm not sure what you mean by "update the ONNX model with the new exporter and generate the file again"

Our process was implemented as part of a Docker build (we also tested outside the build process). Our process was: 1) Clone git repository with up to date master branch 2) Copy weights.pt from trained YOLOv8 model into DeepStream-Yolo folder 3) Copy utils/export_yoloV8.py into DeepStream-Yolo folder 4) Run python3 export_yoloV8.py -w weights.pt --dynamic -s $HEIGHT $WIDTH 5) Compile nvdsinfer_custom_impl_Yolo plugin 6) Delete pre-existing engine files 7) Run previously working deepstream inference pipeline (rebuild engine file using newly compiled plugin and exported weights.onnx and labels.txt).

For now, we're proceeding forward with the working commit. We're hoping to get the other commits next week to see if we can isolate the issue.

marcoslucianops commented 9 months ago

I found the error, it was one miss change I did in the exporter file. I will update the repo.

dsconnol-impactai commented 9 months ago

Awesome! Thanks so much.

marcoslucianops commented 9 months ago

Please try again with the updated export_yoloV8.py file.

dsconnol-impactai commented 9 months ago

We can confirm that the fix works correctly. Thanks for your help!

raghavendraramya commented 9 months ago

I see the same issue with YoloV5, it detects only one class (Person). Is it the same bug in the Yolov5 ONNX script as well? Thank you!