ultralytics / yolov5

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

Large Image, Small object detection help #4668

Closed Kickjaw closed 2 years ago

Kickjaw commented 3 years ago

Hello,

I am looking for help optimizing my CFG file to train my model. I will be running this on a RTX 3090 with 24GB of ram.

My base images are around 4500x4500 pixels. The objects that I am looking to detect are 40x40 pixels and all are fairly uniform in shape. There will be 3 classes to detect in each image and each image can contain anywhere from 300-1000 objects to detect. The accuracy of the count is the top priority so I would like to avoid tiling the image.

My current thought is to try to have the input into the network be as large as possible to maintain as much resolution on the detection of the small objects.

Any suggestions are welcomed. Let me know what I can provide to help figure this issue out.

Additional context

iceisfun commented 3 years ago

I would focus on the x class models and making sure you have enough training data including background data and all labels being correct.

What have you tried so far and what results did you get?

How many images were in your training and background?

Edit

Don't be tempted to over train your model at first unless you have many images in your dataset

priyabratknoldus commented 3 years ago

WhatsApp Image 2021-09-05 at 2 55 12 PM

HI @iceisfun IN this image it is only predicting healthy wheat grains.. ideally it should predict the broken and helathy and 4 others I believe because

I have trained on 4 classes .

how can it be possible to predict lets suppose one image has 4 classes then how it could predict that ?

glenn-jocher commented 3 years ago

@priyabratknoldus 👋 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/

fcakyon commented 3 years ago

@Kickjaw you can perform sliced inference using yolov5 with SAHI package: https://github.com/obss/sahi

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