cyrusbehr / YOLOv8-TensorRT-CPP

YOLOv8 TensorRT C++ Implementation
MIT License
568 stars 70 forks source link

Custom trained model support #40

Closed junho2000 closed 10 months ago

junho2000 commented 11 months ago

Hi thank you for sharing your great work!

i am just curious that can i run executables with my custom trained model? my model has 12 class, not like coco dataset.

i export my best(yolov8n).pt model to onnx and then i run the detect_object_video then output is x,y, width, height are all 0 but only there is class name.

except for this everything works well!

eeuwevandijk commented 10 months ago

Which version of OpenCV (C++) do you use? I had several issues with Yolo C++ and ended up with a specific version of OpenCV: v4.7.0 (OpenCV v4.8+ did not work on my system: Jetson Orin AGX)

junho2000 commented 10 months ago

I am working on my laptop 4060 mobile ubuntu20.04, i installed OpenCV 4.8.0

cyrusbehr commented 10 months ago

Please send the model @eeuwevandijk

junho2000 commented 10 months ago

https://drive.google.com/file/d/13fV2zgIZAsq6ubgGY1CbQld6RmQIe3s_/view?usp=sharing this is my model(best.pt)

cyrusbehr commented 10 months ago

@eeuwevandijk OpenCV is not the issue here, I used version 4.8 and it worked fine for me with this model.

cyrusbehr commented 10 months ago

@junho2000

Your model does not have 12 classes like you mention, it has 9 classes:

image

That being said, my code does not read the classes automatically from the model. You need to manually specify them. You have two options.

1) Specify the classes using the --class-names command line argument. So it would look like this: ./detect_object_image --model ./best.onnx --input ~/Desktop/sign.png --class-names crosswalk-sign highway-enterance-sign highway-exit-sign no-entry-road-sign one-way-road-sign parking-sign priority-sign round-about-sign stop-sign 2) Modify the class names in the code. You need to make the change here. Replace what's there with your 9 classes.

Once you make the change, the model works fine. Here is a sample output with your model:

sign_annotated

junho2000 commented 10 months ago

@junho2000

Your model does not have 12 classes like you mention, it has 9 classes:

image

That being said, my code does not read the classes automatically from the model. You need to manually specify them. You have two options.

1) Specify the classes using the --class-names command line argument. So it would look like this: ./detect_object_image --model ./best.onnx --input ~/Desktop/sign.png --class-names crosswalk-sign highway-enterance-sign highway-exit-sign no-entry-road-sign one-way-road-sign parking-sign priority-sign round-about-sign stop-sign

2) Modify the class names in the code. You need to make the change here. Replace what's there with your 9 classes.

Once you make the change, the model works fine. Here is a sample output with your model:

sign_annotated

Thank you so much..!

junho2000 commented 10 months ago

Hi i tried both method (specify class name at CLI and revise yolov8.h class name) but still nothing detected, same happen

have you did extra thing to work fine?

cyrusbehr commented 10 months ago

What platform are you using? If you are running on a jetson, please check out the jetson branch.

junho2000 commented 10 months ago

i am using on my laptop with geforce 4060 mobile