dnth / yolov5-deepsparse-blogpost

By the end of this post, you will learn how to: Train a SOTA YOLOv5 model on your own data. Sparsify the model using SparseML quantization aware training, sparse transfer learning, and one-shot quantization. Export the sparsified model and run it using the DeepSparse engine at insane speeds. P/S: The end result - YOLOv5 on CPU at 180+ FPS using on
https://dicksonneoh.com/portfolio/supercharging_yolov5_180_fps_cpu/
55 stars 13 forks source link

Wrong class name while running annotate.py script #14

Open AgriMechatronic opened 1 year ago

AgriMechatronic commented 1 year ago

Hello, first of all thanks a lot for this repo, I have one question: I am doing my own object detection using your google colab, I load my dataset and train it using your script. But when I run the annotate.py, it is doing detection good but name should not be pistol. When I run model with different script I can see that model is detecting with good class name. But when I run with annotate.py, class name is wrong. Why this happens? Thanks.

dnth commented 1 year ago

When you train the model, what do you have in the .yaml file? For example, here's mine

https://github.com/dnth/yolov5-deepsparse-blogpost/blob/main/yolov5-train/data/pistols.yaml

Agri-Mechatronic commented 1 year ago

Yaml file is similar, instead of pistols in path, I have my weeds directory, and names:[‘Weeds’]

Algorithm is detecting weeds but class name is pistol. When I run trained model with different(not with annotate.py) script with torch engine, class name is correct. I tried to edit pistols.yaml file and train but result was same, I also tried changing yaml file in training script with my own yaml file (data.yaml), I tried to do training without ‘weights’ parameter, and finally I tried to do training with yolov5s.pt as weights parameter(I got it from official yolov5 repository) but results are same. When the training is done, in that directory we can find files and photos about training and validation. In training photos I saw that class name is 0. In validation photos class name is Weeds, so it’s correct. Could be anything wrong with annotate.py script? I can send dataset link from roboflow if you want to try. Thank you.

dnth commented 1 year ago

In that case you might want to change this line

https://github.com/dnth/yolov5-deepsparse-blogpost/blob/dbd4306fb036a7f47b42937196d23bdbc953686a/yolov5-train/deepsparse_utils.py#L577

AgriMechatronic commented 1 year ago

It worked thanks a lot, I have one more question: How can I get the values about bounding box (x,y,w,h) from annotate.py file? I want to get that values and send them via USB. Thank you again.

TDBTECHNO commented 1 year ago

it will come from deepsparse_utils.py on annotate function

Agri-Mechatronic commented 1 year ago

Thanks a lot, I will try it. Do I need a linux system in order to run script locally(in vscode or pycharm,not in google colab)? Thank you.