ultralytics / yolov5

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

filter small object #6238

Closed alicera closed 2 years ago

alicera commented 2 years ago

Search before asking

Question

Do you have the method to filter the small object (w < 25 pixel) when training ?

Additional

No response

glenn-jocher commented 2 years ago

@alicera label candidate criteria are applied to filter out unsuitable labels during training here: https://github.com/ultralytics/yolov5/blob/6865d19a92d8c160c7fc3c92256627dadce1cd1e/utils/augmentations.py#L272-L277

The current settings reject boxes with widths or heights < 2 pixels.

alicera commented 2 years ago

Do you think about the wh_thr value shoulud be ? I try to set to 30, but the mAP get lower than wh_thr=2 .

In fact, I want to solve the case of small head class. For example, I have person and head class. When person is close to black object, it will be detect and the result is head. image

glenn-jocher commented 2 years ago

@alicera 👋 Hello! Thanks for asking about improving YOLOv5 🚀 training results. wh_thr=2 is the width-height lower threshold for candidate labels. Anything smaller than 2 pixels will be rejected.

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!