Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YOLOv5 v6.0 train issues #1

Open
bekhzod-olimov opened this issue Apr 20, 2023 · 13 comments
Open

YOLOv5 v6.0 train issues #1

bekhzod-olimov opened this issue Apr 20, 2023 · 13 comments

Comments

@bekhzod-olimov
Copy link

bekhzod-olimov commented Apr 20, 2023

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
Copy link
Owner

AlessandroMondin commented Apr 20, 2023

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
Copy link
Author

@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
Copy link
Owner

AlessandroMondin commented Apr 20, 2023

I think they might be these

@bekhzod-olimov
Copy link
Author

@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
Copy link
Author

@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
Copy link
Owner

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
Copy link
Author

@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
Copy link

@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
Copy link
Author

@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
Copy link
Owner

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

@Mahsatajik
Copy link

@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
Copy link
Owner

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
Copy link

xjyisok commented Apr 15, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants