ultralytics / yolov5

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

Low precision and mAP on custom data #3617

Closed FaizahMushtaq closed 3 years ago

FaizahMushtaq commented 3 years ago

❔Question

Hello @glenn-jocher, I'm training yolov5 for my custom dataset consist of two classes Normal and depressed, the images are basically spectrograms, when I trained it for 4k images, 2k belonging to each class I achieved mAP_0.5 0.996 with 300 epochs from scratch. Now training same data with 7k images 3500 Normal and 3900 depressed the mAP is 0.52 and precision remains 0.5 even after 600 epochs and 1000. It increases till 0.54 but at end result is 0.52 and precision remains constant . Can you please help me to find out what's going wrong? Here are training images de and training e

github-actions[bot] commented 3 years ago

πŸ‘‹ Hello @FaizahMushtaq, 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://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

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), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 3 years ago

@FaizahMushtaq πŸ‘‹ Hello! Thanks for asking about improving 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/

FaizahMushtaq commented 3 years ago

I have followed all the steps, but still there is no improvement ,tried with 6k dataset the mAP and precision still 0.52.

7kyolov5

Screenshot 2021-06-16 120121

GrimReaperSam commented 3 years ago

Are you solving a classification problem with a detection model?

FaizahMushtaq commented 3 years ago

@GrimReaperSam Yes

GrimReaperSam commented 3 years ago

You shouldn't! You should just use a classification model to do that. A lot of your training effort is wasted on identifying objectness and bounds when they are not relevant to you.

FaizahMushtaq commented 3 years ago

But it was giving mAP 0.996 now after 1 epoch the recall becomes 1 and precision, mAP remain constant what is reason behind it?

GrimReaperSam commented 3 years ago

You give too little information to figure this out..

FaizahMushtaq commented 3 years ago

@GrimReaperSam I'm using yolov5s with all default parameters batch size 16, img size 416 and for 300 epochs, the data set consist of 7000 images, 4900 for training 2450 belong to each normal and depressed class. 1400 for validation . image

Then after 1 epochs, the recall reaches 1 and mAP and precsion 0.5, this behaviour remain constant till all epochs completed even I run it for 1000 epochs.

image I tried for 4000 images but same results recall is 1 even at start

image

ChinaRush commented 3 years ago

your train_loss is shaking,maybe you can adjust your learning rate or batch-size? or there may be something wrong of your data

github-actions[bot] commented 3 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 ⭐!