ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.69k stars 16.33k forks source link

detection problem #5833

Closed sctrueew closed 2 years ago

sctrueew commented 2 years ago

Search before asking

Question

Hi everyone,

I've trained a model with yolov5m and I have a problem with some classes which are linear. for example: label => pred

Almost detection is 50% for the orange class but above 90% for the other classes.

Where is my problem? image

Thanks in advance

Additional

No response

github-actions[bot] commented 2 years ago

👋 Hello @sctrueew, 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 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/yolov5
$ cd yolov5
$ 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), 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

@sctrueew 👋 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/](https://github.com/ultralytics/yolov5/issues/2844#issuecomment-851338384)

Zengyf-CVer commented 2 years ago

@sctrueew The number of instances in your orange category is relatively small.

sctrueew commented 2 years ago

@Zengyf-CVer Hi,

No, I have many instances about orange class than other classes.

number of instances for all classes:

classid_numOfInstance 1008_2911 <==========> orange class 1009_633 1010_2741 1011_4976 1012_701 1013_136 1014_267 1015_2 1016_546 1017_340 1018_672 1019_663 1020_745 1022_628 1023_198 1024_137 1025_35 1026_13 1027_6 1028_56 1029_329 1030_488 1031_2092 1032_1

Zengyf-CVer commented 2 years ago

@sctrueew In the training set and validation set, does the number of instances of your orange class meet 8:2?

sctrueew commented 2 years ago

@Zengyf-CVer

I used the training set for the valid set. I have 2911 instances for the orange class.

image

two of the classes are strange. Did overfitting occur?

Zengyf-CVer commented 2 years ago

@sctrueew You'd better separate, 7:3 or 8:2 or 9:1. Except for the normal operation of the test program, do not use 1:1 for experiments.

sctrueew commented 2 years ago

@sctrueew Thanks. I always used 1:1 for yolov4 and I thought that I can use it for this repo.

Zengyf-CVer commented 2 years ago

@sctrueew You can try the 8:2 instance division first to see if it works.

sctrueew commented 2 years ago

@Zengyf-CVer Hi,

I've trained again and my result is:

Class Images Labels P R mAP@.5 mAP@.5:.95: 100%|██████████| 11/11 [00:09<00:00, 1.19it/s]
all 500 2926 0.877 0.89 0.921 0.7 Orange 500 254 0.877 0.472 0.573 0.394

sctrueew commented 2 years ago

@glenn-jocher Hi,

Could you please tell me, where the problem is?

Thanks

glenn-jocher commented 2 years ago

@sctrueew I have nothing to add beyond https://github.com/ultralytics/yolov5/issues/5833#issuecomment-982942590

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 ⭐!