Closed sctrueew closed 2 years ago
👋 Hello @sctrueew, 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 Glenn Jocher at glenn.jocher@ultralytics.com.
Python>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started:
$ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt
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.
@sctrueew 👋 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/](https://github.com/ultralytics/yolov5/issues/2844#issuecomment-851338384)
@sctrueew The number of instances in your orange category is relatively small.
@Zengyf-CVer Hi,
No, I have many instances about orange class than other classes.
number of instances for all classes:
classid_numOfInstance 1008_2911 <==========> orange class 1009_633 1010_2741 1011_4976 1012_701 1013_136 1014_267 1015_2 1016_546 1017_340 1018_672 1019_663 1020_745 1022_628 1023_198 1024_137 1025_35 1026_13 1027_6 1028_56 1029_329 1030_488 1031_2092 1032_1
@sctrueew In the training set and validation set, does the number of instances of your orange class meet 8:2?
@Zengyf-CVer
I used the training set for the valid set. I have 2911 instances for the orange class.
two of the classes are strange. Did overfitting occur?
@sctrueew You'd better separate, 7:3 or 8:2 or 9:1. Except for the normal operation of the test program, do not use 1:1 for experiments.
@sctrueew Thanks. I always used 1:1 for yolov4 and I thought that I can use it for this repo.
@sctrueew You can try the 8:2 instance division first to see if it works.
@Zengyf-CVer Hi,
I've trained again and my result is:
Class Images Labels P R mAP@.5 mAP@.5:.95: 100%|██████████| 11/11 [00:09<00:00, 1.19it/s]
all 500 2926 0.877 0.89 0.921 0.7
Orange 500 254 0.877 0.472 0.573 0.394
@glenn-jocher Hi,
Could you please tell me, where the problem is?
Thanks
@sctrueew I have nothing to add beyond https://github.com/ultralytics/yolov5/issues/5833#issuecomment-982942590
👋 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 ⭐!
Search before asking
Question
Hi everyone,
I've trained a model with yolov5m and I have a problem with some classes which are linear. for example: =>
Almost detection is 50% for the orange class but above 90% for the other classes.
Where is my problem?
Thanks in advance
Additional
No response