Closed jamjamjon closed 2 years ago
Hi @Jamjamjamjon ,
Why not just use a classification model to do this task, and would a detection box be particularly helpful for your scenario?
@Jamjamjamjon I think you might be confusing augmentations. Mosaic will join 4 images together and then crop the outside to maintain imgsz. That's it. What you are showing is one image with scale
and translate
augmentation. Scale, translate and mosaic are 3 separate augmentations that are independent of each other and can be modified in your hyp file:
About reducing FPs, you just need more background images and to make sure you train enough that overtraining occurs. A full list of recommendations for improving results is below.
π 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.
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!
@Jamjamjamjon also you can verify your labels by examining your train*.jpg batches generated on training start.
@Jamjamjamjon also you can verify your labels by examining your train*.jpg batches generated on training start.
I found the mistake! I double check the training datasets and found out that there is a Negative sample image has been labeled! I havenβt finish examining all the dataset, I guess there would be several mistakes like like still exist! Thanks for your reply! Have a good day!
π 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 β!
i think you should set translate=0.0
@njustczr thanks for the suggestion! We recommend users first train with all default settings before considering any changes, but adjusting the translate
parameter might be something you could experiment with. Feel free to give it a try and let us know how it goes! If you have any other questions, feel free to ask. Good luck!
Search before asking
Question
Hi, sorry to interrupt you. I met some problem about mosaic skills when training.
here is the thing. I recently have a project which is to detect people who ride a motorcycle, not to detect motor or people individually, but detect them all, as a whole. I've used Darknet YOLOv4 and found the result is not good, so I decided to use YOLOv5 to train it. My datasets has 10,000+ images, which contains 1/5 images has only people or only motorcycle or bycicle as negative samples. Those negative imagesβ label file are empty .txt.
Training results is great but has some strange phenomenon: some image only has people or motorcycle, and the people or motorcycle is detected individually. This is surely not what I want. I have checked the training datasets and the labels is right, but using the trained model to infer the negative sample images in training datasets, some of the images would be detected with only people or motorcycle.
Hyp in training is using med.yaml. Mosaic =1.0 .
Then I check the load_mosaic() function and found out some segments in img4 generated by 4 images after mosaic() will be covered or hide. Therefore, image(man ride on a motorcycle ) after mosaic would probably lost the front of the object(people and part of motorcycle), only the back of the motorcycle will be one the img4 used for training. I think this the main reason caused this problem.
I want to known how to fix this problem except using -rect or not using mosaic directly. Besides, will it work of the way I do with negative sample images which just use empty .txt label file? And should I adjust the hyper-parameters in hyp-med.yaml to deal with negative sAmples?
My English is not good, if I did not express clear, please let me know.
Really looking forward for your suggestion. Thanks!
Additional
original image :
after mosaic() might be: