AlessandroMondin / YOLOV5m

A personal implementation of YOLOv5 (v6.0)
47 stars 11 forks source link

YOLOv5 v6.0 train issues #1

Open bekhzod-olimov opened 1 year ago

bekhzod-olimov commented 1 year ago

Hi! First of all, thank you very much for your effort in explaining such a complex and complicated YOLOv5 architecture! I have tried to reproduce your results reported in your repo but faced several problems as below:

  1. The FLIR dataset from RoboFlow has different structure in comparsion with the one provided in the repo: train/images/... train/labels/... instead of images/train/, labels/train/// I fixed this and recreated the datasets as it was in the repo but the results were not good. Do you think it is because the datasets were different? I noticed that there are various versions of the FLIR dataset in the RoboFlow, could you please let me know which one did you use for the experiments?
  2. When I tried to see whether the data is being inputted properly and visualized images with the corresponding bounding boxes from validation dataset (using dataset.py) I got the following output images. They do not seem to be decent, so I wanted to know how the input images were visualized in your train process.

test_0 0

  1. I cannot find the pretrained checkpoint for v6.0 in the official github repo of ultralytics maybe this version is not supported anymore since there was a newer version released (v7.0). Would you mind to inform me where to get the pretrained file for v6.0?

I will be looking forward to hearing from you soon!

AlessandroMondin commented 1 year ago

Hello! I would suggest to debug the getitem() to double check. And maybe also check that you’re selecting the correct box_format parameter. The FLIR version that I used only had person and car classes (all I remember). Make sure you download them with coco format (labels in txt files). And regarding YOLOv5 weights, if they are not available on Ultralytics/YOLOv5 hub I don’t really know.

bekhzod-olimov commented 1 year ago

@AlessandroMondin, thank you very much for your reply! As you mentioned, debugging getitem function solved the problem. It was due to box_format. By default, box_format is "coco" and changing it to "yolo" worked pretty well. Unfortunately, I was unable to find weights (for v6.0) in the Ultralytics hub and without the pretrained weights the model's performance is quite poor.

AlessandroMondin commented 1 year ago

I think they might be these

bekhzod-olimov commented 1 year ago

@AlessandroMondin I am afraid these weights are for v8 (below ones for v7). When I tried these weights it threw an error as below.

image

I though it is because architecture you explained is YOLOV5 v6.0 and the later versions have different architecture; so they do not match (as error comes from torch.serialization.py as can be seen in the image). Btw, I have tried to copy the checkpoint to the root folder where train.py located (and changed torch.load path), still the same error.

bekhzod-olimov commented 1 year ago

@AlessandroMondin , there was the same issue in here. I guess I need to git clone Ultralytics/YOLOv5 to the folder where the train script is located.

AlessandroMondin commented 1 year ago

Did you convert Ultralytics weights to my architecture with https://github.com/AlessandroMondin/YOLOV5m/blob/main/ultralytics_files/state_dict_loading.py? You need to uncomment it but this files loads Ultralytics weights to my architecture

bekhzod-olimov commented 1 year ago

@AlessandroMondin Uncommenting did not result in any change; the code keeps raising the same error (no module named 'models'). I am wondering whether you had cloned Ultralytics/YOLOv5 repo to the folder you wrote the code?

Sayed-Jobaer commented 1 year ago

@AlessandroMondin Could you please describe everything step by step on how to run your code? It will be more helpful if you provide a command line too.

bekhzod-olimov commented 1 year ago

@Sayed-Jobaer if you want to train an object detection model on your custom dataset, I recommend you to use RoboFlow. If you want to train the model from scratch then @AlessandroMondin wrote an excellent blog, where you can find a step-by-step network and train explanation.

AlessandroMondin commented 10 months ago

https://github.com/ultralytics/yolov5/releases/tag/v6.0 ... it is the YOLOv5M checkpoint 😄

Mahsatajik commented 10 months ago

@AlessandroMondin I am afraid these weights are for v8 (below ones for v7). When I tried these weights it threw an error as below.

image

I though it is because architecture you explained is YOLOV5 v6.0 and the later versions have different architecture; so they do not match (as error comes from torch.serialization.py as can be seen in the image). Btw, I have tried to copy the checkpoint to the root folder where train.py located (and changed torch.load path), still the same error.

"I encountered the same error. Could you please help me resolve this issue?"

AlessandroMondin commented 10 months ago

I would suggest to attempt to find such weights in their repo.. I will try to check if I still have them locally but I do not guarantee it :) Besides that, another approach could be to load YOLOV5mV7 by setting strict=False in torch.load

xjyisok commented 6 months ago

Dear author I train your model from scratch but the performence is quite poor,the map0.5 is only 0.01 when fitting.The loss I use is Yolo_Loss,and I use rect_train.So can you explain why this happen. Hope your answer