ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.19k stars 3.45k forks source link

mAP stuck at ~0.36 #1895

Closed andreideaconu18 closed 2 years ago

andreideaconu18 commented 2 years ago

Search before asking

Question

Hello,

I am training yolov3 on a part of the BDD100K dataset, using the default yolov3 weights. Below are the label number for train and val sets: image

The hyperparamteres are default, the training is done on 416 img size, 16 batch value, 68 epochs (seen as recommended in another issue), using multi-scale and not freezing any layer. The problem is that the map@.5 jumps very quickly to ~0.3 and then increases a little bit towards 0.36-0.37. This behavior was encountered for multiple runs, one with a smaller train dataset, one with different batch value, one without multiscale. Below are the train/val results. image

Also, the concerning thing in the photo above is the val/obj_loss which i don't really know how to interpret or why it happens usually, given the fact that the other curves look as expected.

Could you see a possible issue/solution with/for the things mentioned? Would a higher mAP value be possible having the mentioned label numbers for train and val datasets (and considering the fact that the images are well chosen)?

Thank you.

Additional

No response

github-actions[bot] commented 2 years ago

👋 Hello @andreideaconu18, thank you for your interest in YOLOv3 🚀! 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 Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

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

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

Environments

YOLOv3 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 YOLOv3 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv3 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

@andreideaconu18 👋 Hello! Thanks for asking about improving YOLOv5 🚀 training results. Please consider submitting a BDD100K.yaml to help other users train on this dataset and reproduce your 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!

andreideaconu18 commented 2 years ago

Adding below the confusion matrix, PR curve, labels file and a set o true and predicted labels for a validation batch.

Confusion matrix: image

PR curve: image

Labels: image

Val_batch true: image

Val batch pred: image

Maybe even more than the mAP value that overfits quickly, what i wonder is how would you interpret the increasing val/obj_loss value? Looking at the background FN from the confusion matrix, could this be related to anything else than the fact that the model simply can't identify one of the classes where it should be? And lastly, almost 1% of the labels are < 3 pixels in size. What would you recommend? Not labeling them but keeping the images (thinking that maybe being this small they won't interfere with the training), not using those images or using them the images and the small labels?

Thank you!

glenn-jocher commented 2 years ago

@andreideaconu18 in general your obj val loss are overfitting, so you should try techniques that reduce overfitting, i.e. higher augmentation, reduced hyp obj loss gain etc.

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 YOLOv3 🚀 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 YOLOv3 🚀 and Vision AI ⭐!