ultralytics / yolov5

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

How to solve the problem of sample imbalance #4105

Closed zcswdt closed 3 years ago

zcswdt commented 3 years ago

The following are the 12 categories of detection models I trained, but there are very few samples in some categories. How to solve the imbalance problem of categories? image

glenn-jocher commented 3 years ago

@zcswdt well you may want to gather more data for your underrepresented categories, but class imbalance in itself is the norm in ML. I'll post our default training guidelines below that show imbalances across the various common datasets.

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/

zcswdt commented 3 years ago

Larger models like

thank you reply,In the process of evolving hyperparameters, --envole is set to 300 by default, and I train for 10 epochs. Does it mean that it is equivalent to 300 times, each time you have to complete 10 epochs of training?

glenn-jocher commented 3 years ago

@zcswdt yes

zcswdt commented 3 years ago

reply,In the process of evolving hyperparameters, --envole is set to 300 by default, and I train for 10 epochs. Does it mean that it is equivalent to 300 times, each time you have to complete 10 epochs of training?

Isn’t that equivalent to training 3000 epochs, which is a bit time-consuming?

akashAD98 commented 3 years ago

The following are the 12 categories of detection models I trained, but there are very few samples in some categories. How to solve the imbalance problem of categories? image

@zcswdt can you share your script for visualization of dataset ,width & height?

zcswdt commented 3 years ago

ou share your script for visualization of dataset ,wid Did you find anything? Or is a good idea to solve this problem labels_correlogram

akashAD98 commented 3 years ago

Normally in scaled yolov4 we are using Focal_loss & counter_per_class to solve data imbalance problem. I'm not sure about this in yolov5

On Mon, 26 Jul, 2021, 7:53 am zcswdt, @.***> wrote:

ou share your script for visualization of dataset ,wid Did you find anything? Or is a good idea to solve this problem [image: labels_correlogram] https://user-images.githubusercontent.com/43515926/126924541-605423ca-be4a-476b-9003-cb8ed415da3b.jpg

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ultralytics/yolov5/issues/4105#issuecomment-886323632, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO5PB2XVX7AF7LD5LMHU7FLTZTBJLANCNFSM5AZKNZNA .

zcswdt commented 3 years ago

Normally in scaled yolov4 we are using Foca_loss & counter_per_class to solve data imbalance problem. I'm not sure about this in yolov5

Then if you are sure whether yolov5 can do this, please let me know, thank you

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