Closed Sauravpandey98 closed 2 years ago
👋 Hello @Sauravpandey98, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.
If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.
If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.
For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.
Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:
git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install
YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.
@Sauravpandey98 👋 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!
Hi @Sauravpandey98, Give details about size of the dataset and training results/graphs if possible, so that everybody will understand your issue.
For now my suggestion is try to run the detection using yolov5m_Objects365.pt by passing --classes 20 (i.e Storage box). i hope you will get better results.
python path/to/detect.py --weights yolov5m_Objects365.pt --classes 20
yeah thanks @Guttappa1238 and @glenn-jocher for responding. @Guttappa1238 I have tried with yolov5m_Objects365 model .But it is not performing well.
In my dataset , I have only one class i.e "box" as you can see from the example images given in issue.Firstly I have trained a base model using a dataset of 1200 training images and manually tuned the hyper-parameters to find best model.After this I fine tuned the best model on 1000 training images.These prediction result are using the fine tuned model.
Now In my case most of false positive is occurring when the model picks wrinkled polythene wrapping or tapes as edges.So I am asking what changes should I do in my dataset or training strategy to decrease these kind of false positives.
hello, can I learn the original version of the pictures and which model you are using? (image without bbox)
@Sauravpandey98 Couple of suggestions that might help:
utils/augmentations.py
try to play around with augmentations, specifically under albumentations class. One example could be adding random sun flare, that could mimic the lights falling on the tapes on the boxes that might be a potential cause for the issue. https://albumentations.ai/docs/api_reference/augmentations/transforms/#albumentations.augmentations.transforms.RandomSunFlareHope this helps.
@anujdutt9 thanks for suggestions.But I have a query regarding mAP values.So on observation I found that even if the model starts overfitting ( generally it occurs when object loss starts increasing),the mAP@0.5:0.95 continues to increase while the mAP@0.5 remains stable.So suppose If I give same weightage to both the mAP values to calulate fitness,the best fitness would still not be corresponds to minimum loss value.
So should I prefer fitness value here or should I use those weights that has max mAP value along with minimum loss.For example in this case:
@Sauravpandey98 sure. Some metrics like mAP@0.5:0.95 are more influenced by regression loss than obj loss and vice versa. The default fitness function is most weighted towards the main COCO metric of mAP@0.5:0.95: https://github.com/ultralytics/yolov5/blob/6dd82c025298d219a1eb1fe8e486fb99d5324d34/utils/metrics.py#L15-L19
Ideally all losses would begin to overfit in concert, but in practice each loss will overfit at a different point in training (assuming you train long enough). You can try to balance these manually using the loss gain hyperparameters, or evolve hyperparameters: https://github.com/ultralytics/yolov5/blob/6dd82c025298d219a1eb1fe8e486fb99d5324d34/data/hyps/hyp.scratch-low.yaml#L13-L17
Thanks @glenn-jocher for these insights into loss values.But can you please give me a suggestion? So from the graphs you can see that object loss value started to go up from 100 epoch.While according to above mentioned fitness score I am getting best weights at 196 epoch.
So,should I use weights at 100 epoch or weights at 196 epoch for prediction?
@Sauravpandey98 not sure I understand your question. If you want the weights that produced the best mAP on the validation set use best.pt. That's the entire point of best.pt.
Search before asking
Question
Hi to all, I am working on the problem of detecting boxes in warehouses.I am using yolov5 for object detection and it is working fine in most of the cases.But I am getting a particular kind of false detections that I am not able to remove.Example of of such case is shown below.Any suggestion to solve this problem would be appreciated.
Additional
No response