Closed litaldavar closed 2 years ago
Maybe you can try yolov5-p2 https://github.com/ultralytics/yolov5/blob/master/models/hub/yolov5-p2.yaml
Didn't work. still can't detect anything
@litaldavar ๐ Hello! Thanks for asking about improving YOLOv5 ๐ training results. Detecting small objects is a default use case.
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.
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.
--weights
argument. Models download automatically from the latest YOLOv5 release.
python train.py --data custom.yaml --weights yolov5s.pt
yolov5m.pt
yolov5l.pt
yolov5x.pt
custom_pretrained.pt
--weights ''
argument:
python train.py --data custom.yaml --weights '' --cfg yolov5s.yaml
yolov5m.yaml
yolov5l.yaml
yolov5x.yaml
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.
--img 640
, though due to the high amount of small objects in the dataset it can benefit from training at higher resolutions such as --img 1280
. If there are many small objects then custom datasets will benefit from training at native or higher resolution. Best inference results are obtained at the same --img
as the training was run at, i.e. if you train at --img 1280
you should also test and detect at --img 1280
.--batch-size
that your hardware allows for. Small batch sizes produce poor batchnorm statistics and should be avoided.hyp['obj']
will help reduce overfitting in those specific loss components. For an automated method of optimizing these hyperparameters, see our Hyperparameter Evolution Tutorial.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!
Usually when it comes to small object detection training and inferencing with high resolution works.You can try models that was trained on high resolutions like s6,m6 etc. Also I would recommend you to take a look at tensorflow's Help Protect the Great Barrier Reef competition on Kaggle where objects are so small that they are barely detectable.As far as I know top solutions are yolov5 with high resolution training and inferencing.I think taking a look at some notebooks and discussions may help.
The minimum area of boundingboxes is set with a threshold, please look at utils > augmentations.py > def box_candidates area_thr parameter & change it accordingly, this will ensure good training and interferece on small objects
๐ 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 โญ!
Hi Gleen๏ผwhat's up!! n Happy belated 41st birthday! Wishing you a very lucky year!
Tell me please, you said, ใBackground images are images with no objectsใ
"Background images. ใBackground images are images with no objectsใ that are added to a dataset to reduce False Positives (FP). We recommend about 0-10% background images to help reduce FPs (COCO has 1000 background images for reference, 1% of the total). No labels are required for background images."
is mean "Is it an image without objects?" Or, "Is it an image part that does not contain an object?"
And "Is it an image without objects?"ใใๆญฃใใๅ ดๅใ can yolov5 data text be learned in blank?
@ybonzou thank you! A background image just contains no objects from the dataset you are training. So for example if you train on people, a background image is any image that has no people.
Hi Mr.Glenn, thank you for your reply!!
dear sir, Borrowing from this question, I would like to know whether images with empty labels are classified as background images or not.
Secondly, after data augmented, will the original image also be treated as the training image?
like this data augmentation tips๏ผ
perspective: 0.0 # image perspective (+/- fraction), range 0-0.001 flipud: 0.0 # image flip up-down (probability) fliplr: 0.5 # image flip left-right (probability) mosaic: 1.0 # image mosaic (probability) mixup: 0.0 # image mixup (probability)
@Cong-Wan ๐ Hello! Thanks for asking about image augmentation. YOLOv5 ๐ applies online imagespace and colorspace augmentations in the trainloader (but not the val_loader) to present a new and unique augmented Mosaic (original image + 3 random images) each time an image is loaded for training. Images are never presented twice in the same way.
The hyperparameters used to define these augmentations are in your hyperparameter file (default data/hyp.scratch.yaml
) defined when training:
python train.py --hyp hyp.scratch-low.yaml
You can view the effect of your augmentation policy in your train_batch*.jpg images once training starts. These images will be in your train logging directory, typically yolov5/runs/train/exp
:
train_batch0.jpg
shows train batch 0 mosaics and labels:
YOLOv5 ๐ is now fully integrated with Albumentations, a popular open-source image augmentation package. Now you can train the world's best Vision AI models even better with custom Albumentations ๐!
PR https://github.com/ultralytics/yolov5/pull/3882 implements this integration, which will automatically apply Albumentations transforms during YOLOv5 training if albumentations>=1.0.3
is installed in your environment. See https://github.com/ultralytics/yolov5/pull/3882 for full details.
Example train_batch0.jpg
on COCO128 dataset with Blur, MedianBlur and ToGray. See the YOLOv5 Notebooks to reproduce:
Good luck ๐ and let us know if you have any other questions!
@Cong-Wan ๐ Hello! Thanks for asking about image augmentation. YOLOv5 ๐ applies online imagespace and colorspace augmentations in the trainloader (but not the val_loader) to present a new and unique augmented Mosaic (original image + 3 random images) each time an image is loaded for training. Images are never presented twice in the same way.
Augmentation Hyperparameters
The hyperparameters used to define these augmentations are in your hyperparameter file (default ) defined when training:
data/hyp.scratch.yaml
python train.py --hyp hyp.scratch-low.yaml
Augmentation Previews
You can view the effect of your augmentation policy in your train_batch*.jpg images once training starts. These images will be in your train logging directory, typically :
yolov5/runs/train/exp
train_batch0.jpg
shows train batch 0 mosaics and labels:YOLOv5 Albumentations Integration
YOLOv5 ๐ is now fully integrated with Albumentations, a popular open-source image augmentation package. Now you can train the world's best Vision AI models even better with custom Albumentations ๐!
PR #3882 implements this integration, which will automatically apply Albumentations transforms during YOLOv5 training if is installed in your environment. See #3882 for full details.
albumentations>=1.0.3
Example on COCO128 dataset with Blur, MedianBlur and ToGray. See the YOLOv5 Notebooks to reproduce:
train_batch0.jpg
Good luck ๐ and let us know if you have any other questions!
Dear glenn,
Good morning ,sir! Thank you for your answer!
I have two other questions for you๐.
First, how do I save all train_batch*.jpg?
Next, a image have itself label, but the label (*.txt) file is empty, will yolov5 use it as a background image?
Looking forward to your reply!
BR,
@litaldavar train_batch*.jpg are created automatically in your runs/train/exp directory on train start.
Yes you can just add background images to your dataset without needing any label txt file.
Search before asking
Question
Hello
I'm trying to train a dataset with images of small beetles. after training I tried to detect a small beetle but got not detected Is there any way to use the model to train on small objects?
Thanks
Additional
No response