ultralytics / yolov5

YOLOv5 šŸš€ in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.56k stars 16.31k forks source link

Too much Data? More data = Worse Results? #7612

Closed callmesora closed 2 years ago

callmesora commented 2 years ago

Search before asking

Question

Can a I have too much Data?

I was training yolov5m with pre-trained weights on the BDD100K Data set. This Dataset has 100k Images.

image

They Seem to be a bit unbalanced in terms of number of instances.

I've ran the multi-GPU training program and obtained very poor results. Due to the huge ammount of images I could't use the --cache flag. So each epoc took a huge amout of time.

And besides the huge amount of time I also got terrible results I'm not sure why the mAP didn't even reach 1%. And kept getting worse . It took 50 Hours to run around 20 Epochs

image

I later tried to use only a sub section of the Dataset with 10K images and I got much better results and managed to cache the images, so training went a lot faster. And I also had better results. I have no Idea why

image

So In Recap my question(s) are:

Additional

No response

github-actions[bot] commented 2 years ago

šŸ‘‹ Hello @callmesora, thank you for your interest in YOLOv5 šŸš€! Please visit our ā­ļø Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a šŸ› Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ā“ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on macOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 2 years ago

@callmesora šŸ‘‹ Hello! Thanks for asking about improving YOLOv5 šŸš€ training results.

Most of the time good results can be obtained with no changes to the models or training settings, provided your dataset is sufficiently large and well labelled. If at first you don't get good results, there are steps you might be able to take to improve, but we always recommend users first train with all default settings before considering any changes. This helps establish a performance baseline and spot areas for improvement.

If you have questions about your training results we recommend you provide the maximum amount of information possible if you expect a helpful response, including results plots (train losses, val losses, P, R, mAP), PR curve, confusion matrix, training mosaics, test results and dataset statistics images such as labels.png. All of these are located in your project/name directory, typically yolov5/runs/train/exp.

We've put together a full guide for users looking to get the best results on their YOLOv5 trainings below.

Dataset

COCO Analysis

Model Selection

Larger models like YOLOv5x and YOLOv5x6 will produce better results in nearly all cases, but have more parameters, require more CUDA memory to train, and are slower to run. For mobile deployments we recommend YOLOv5s/m, for cloud deployments we recommend YOLOv5l/x. See our README table for a full comparison of all models.

YOLOv5 Models

Training Settings

Before modifying anything, first train with default settings to establish a performance baseline. A full list of train.py settings can be found in the train.py argparser.

Further Reading

If you'd like to know more a good place to start is Karpathy's 'Recipe for Training Neural Networks', which has great ideas for training that apply broadly across all ML domains: http://karpathy.github.io/2019/04/25/recipe/

Good luck šŸ€ and let us know if you have any other questions!

glenn-jocher commented 2 years ago

@callmesora šŸ‘‹ Hello! Thanks for asking about training speed issues. YOLOv5 šŸš€ can be trained on CPU (slowest), single-GPU, or multi-GPU (fastest). If you would like to increase your training speed some options are:

Good luck šŸ€ and let us know if you have any other questions!

callmesora commented 2 years ago

Hello, I've tried and ajusted all of those previously. I'm traning on multiple GPU as well. (I'm unsure if this is an automated message , I assume so), regardless. Thanks for the valuable inputs but I've tried changing those values but my questions still remain, if any of you could help me It would be lovely!

yyring000 commented 2 years ago

Hi, did you solve this problem, i also got this problem, I use YOLOV5S to detect pedestrains in BDD100K dataset, but the output map, p, r, all are very low. If you can give some advice? thank you!!!

MartinPedersenpp commented 2 years ago

What is the format of the BDD100K Data set annotations and how are they converted? If you want to detect pedestrians, the pretrained Yolov5 models are trained on the coco dataset, which includes plenty of pictures of persons, which might as well be pedestrians. I hope this helps

glenn-jocher commented 2 years ago

@callmesora please submit a PR with a BDD100K.yaml to help other users get started training on this dataset. If we have this yaml and can train on the dataset we can help determine what mAP to expect on the dataset.

Please see our āœ… Contributing Guide to get started.

callmesora commented 2 years ago

Hey, I will send you all the scripts and techniques I used to convert and prepare the Dataset. In the meantime I

  1. Reduced the size of the Dataset to 10k Images
  2. Filter the under represented classes according to Glenn recomendation (10k Instances minimum).
  3. I Converged Car Bus Truck and Motorcycle classes into one class "car" since the last 3 were severely under represented
  4. I Dropped some of the labels such as "other person" "other vehicle" "train"
  5. I noticed the model was overfitting on Objectness with the default hyper parameters so I dropped it's gain and added more augmentations.

All this trippled my mAP (from step 2-5). I will provide as soon as possible a git repo and a PR with the yaml I used and a guide to pre process the Data and the scripts I used.

If someone doesn't want to wait here's how I did it: Tried to use BDD100K official bdd-to-coco conversion and from coco to YOLOV5 with scripts I found online but No luck, I kept getting some labels messed up or some errors I couldn't solve.

Then I found another aproach I used fifty one library to pre process the BDD100K into the YOLOV5 PyTorch format and used the Validation set since it had 10k Images.

These 10K images luckly fit the Roboflow Maximum free images per dataset so I used it to merge and drop some of the labels (yes you can drop all but pedestrians if you wish!). You can merge and find these when you generate a new "version" of the Dataset in Roboflow, as so: image

I also have a script for dividing the Dataset into train / val folders already in the PyTorch format in case you don't want to be limited by Roboflow 10K images. This pops a new problem I haven't been able to solve. How to merge and drop classes "manually" I have no script for it and haven't found any library that does it for me.

If anyone knows how to drop / merge classes in a YOLOV5 dataset please let me know!

But I still don't know why it perfomed worse with 100K images :/

callmesora commented 2 years ago

Here is the convertion ! @glenn-jocher how should I structure this notebook in a PR? Should I add te notebook to a specific folder then sumbit the PR ? https://github.com/callmesora/BDD100K-to-YOLOV5

glenn-jocher commented 2 years ago

@callmesora thanks for the info! We want to generalize as much as possible, so perhaps your work is not suitable here, as you've customized the dataset?

callmesora commented 2 years ago

No @glenn-jocher , I provide the original one , just in the YOLOv5 format :) (This script also converts it to COCO and YOLOv4 etc) formats so regardless I think it will be helpfull for people specially to compare different YOLOs to v5 and get better benchmarks

Those later changes are not in the Repo, they are made latter in roboflow if the user wants it. I just left more guidelines to help people manipulate the dataset to their will afterwords.

github-actions[bot] commented 2 years ago

šŸ‘‹ Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 šŸš€ resources:

Access additional Ultralytics āš” resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 šŸš€ and Vision AI ā­!

glenn-jocher commented 11 months ago

@callmesora thanks for sharing the notebook! To submit a PR, you could create a new folder such as datasets/conversion_scripts within the YOLOv5 repo, and submit your notebook there. Feel free to mention this in the PR description. This would be very helpful for others to compare different YOLOs and to facilitate better benchmarks. Thank you for your valuable contribution!