-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting the right anchor size to your model #6838
Comments
👋 Hello @ShaharSarShalom, 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 [email protected]. RequirementsPython>=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 EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf 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. |
👋 Hello! Thanks for asking about model anchors. YOLOv5 🚀 uses a new Ultralytics algorithm called AutoAnchor for anchor verification and generation before training starts. Autoanchor will analyse your anchors against your dataset and training settings (like # Specify anchor count (per layer)
anchors: 3
# --OR-- Specify anchor values manually
anchors:
- [10,13, 16,30, 33,23] # P3/8
- [30,61, 62,45, 59,119] # P4/16
- [116,90, 156,198, 373,326] # P5/32 When generating new anchors, autoanchor first applies a kmeans function against your dataset labels (scaled to your training No action is required on your part to use autoanchor. If you would like to force manual anchors for any reason, you can skip autoanchor with the python train.py --noautoanchor Good luck 🍀 and let us know if you have any other questions! |
Thank you for your answer **I'm still confuse whether or not shall I use the anchor output from the hyperparamters (training with evolve flag) **
I assume your intention is to use the naive training script anytime. thanks |
👋 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 Sir @glenn-jocher , --OR-- Specify anchor values manuallyanchors:
|
@tbonewmy yes that's correct! |
Are they corresponding to the rescaled image size or original image size? |
@tbonewmy they correspond to --imgsz images |
is the 8,16,32 corresponding to the grid size? And P3,P4,P5 the three feature maps? |
My auto anchor only return 12 values for yolov5n . So what should i change the anchor config, i thought we need at least 18 values for version 4. |
n=6, width+height=2, 2n=12 |
@lhztop in your example, AutoAnchor has computed 2 sets of 6 anchor box dimensions each, so there should be no issue using the resulting 12 values with the version of YOLOv5 that you are running. Just copy these 12 values into your anchor parameter list in the |
Hi, I'm quite confused by the 'saved to model' part. I'm training a model and autoanchor showed up, so when using the trained ckpt for inference and load model in my downstream project, should I modify *.yaml accordingly, or use the old *.yaml ? |
@Shadow-Alex yes, you should update the |
Search before asking
Question
I'm trying to set my model anchor boxes to an optimal value
One source says that an autoanchor calculates the anchor sizes before the model starts and changes the model accordingly.
On the other hand, while running the hyper parameters evaluation (on the same dataset) I get this line:
AutoAnchor: 0.87 anchors/target, 0.167 Best Possible Recall (BPR). Anchors are a poor fit to dataset ⚠️, attempting to improve... AutoAnchor: Running kmeans for 16 anchors on 3570 points... AutoAnchor: Evolving anchors with Genetic Algorithm: fitness = 0.8325: 100% 1000/1000 [00:01<00:00, 643.73it/s] AutoAnchor: thr=0.22: 1.0000 best possible recall, 9.15 anchors past thr AutoAnchor: n=16, img_size=1280, metric_all=0.308/0.832-mean/best, past_thr=0.449-mean: 11,25, 19,16, 40,15, 18,43, 42,35, 24,64, 83,29, 35,89, 79,66, 158,49, 56,143, 115,104, 78,254, 170,136, 375,332, 858,444 AutoAnchor: New anchors saved to model. Update model *.yaml to use these anchors in the future. Image sizes 1280 train, 1280 val
1st question, which anchor sizes shall I use?
2nd question, how do I convert the hyperparameters evaluation output from this-
11,25, 19,16, 40,15, 18,43, 42,35, 24,64, 83,29, 35,89, 79,66, 158,49, 56,143, 115,104, 78,254, 170,136, 375,332, 858,444
To the model file -
`# Parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
width_multiple: 1.0 # layer channel multiple
anchors:
glenn-jocher thank you for the best repo at github!
Additional
No response
The text was updated successfully, but these errors were encountered: