Closed akashAD98 closed 3 years ago
Try adding some images that have zero objects, as described in "background images" on this page.
@adrianholovaty thanks for the reply, I have 2 question
@akashAD98 π 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/
@adrianholovaty @glenn-jocher so background images are images with plan background?? how to determine what kind of background images needs to add according to use case? Note: please have look at my FP results. should i need to add this FP backround or its normal baground? it would be great if you give 1 exmple. Thank you so much!
I have 25 classes which are shotgun, pistol, rifle... but it's falling in real-world scenarios. doing too much false prediction. so what are the best background images for this use case???
@akashAD98 this is pretty simple. Images without objects are background images. Find them whereever you want.
@glenn-jocher got it .thanks
@akashAD98 the only criteria is of course the images shouldn't contain the classes you are training on, so you could include the image shown above as a background image (provided of course it's not in your val set).
So, for a background image AAA.jpg we have to have an empty AAA.txt or no txt file is needed?
@m-nasiri this is already answered in https://github.com/ultralytics/yolov5/issues/4194#issuecomment-888280050
π 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 β!
βQuestion
I have trained my model & its performing well on validation data, i got 82% MAP(@0.5), But when i tested my model on frames/video its giving few false predictions.
My dataset has 25 classes & each class has more than 2000 instances.
I have classes like blood,cigarette ,pipe,tank..etc
This are the few results
2.I have class of alcohol & its detecting god but for For any bottle or bottlelike shape object its predicting Alcohol
3.I have a class cigarette & it's detecting an object which looks like cigarette. ![cig](https://user-images.githubusercontent.com/62583018/127321555-1b832559-0594-452d-94bc-5f1713c947c1.pn
@glenn-jocher i already read the Thanks. Im looking for your suggetion