Closed ghost closed 3 years ago
@hammadyounas2008 π 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 --img-size
), and will adjust your anchors as necessary if it determines the original anchors are a poor fit, or if an anchor count was specified in your model.yaml rather than anchor values, i.e.
# 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 --img-size
), and then uses these kmeans centroids as initial conditions for a Genetic Evolution (GE) algorithm. The GE algorithm will evolve all anchors for 1000 generations under default settings, using the CIoU loss (same one used during training) combined with Best Possible Recall (BPR) as its fitness function.
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 --noautoanchor
flag:
python train.py --noautoanchor
Thanks for your reply, It automatically changes the anchor in the model or do I have to manually place the value? My validation error is still 0
@hammadyounas2008 I believe https://github.com/ultralytics/yolov5/issues/4301#issuecomment-892556355 addresses your question.
Zero validation error is quite impressive.
Sorry Precision and recall of validation is still 0, I am just asking did I have to update the anchor manually or it will work automatically to update the .yaml file? Like this images
Can we output the result of the autoanchor?
@AnranXu autoanchor already outputs results to console.
@glenn-jocher what is the default anchor number?
@fcakyon π Hello! Thanks for asking about model anchors. Default anchor count is 3 per output layer.
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 --img-size
), and will adjust your anchors as necessary if it determines the original anchors are a poor fit, or if an anchor count was specified in your model.yaml rather than anchor values, i.e.
# 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 --img-size
), and then uses these kmeans centroids as initial conditions for a Genetic Evolution (GE) algorithm. The GE algorithm will evolve all anchors for 1000 generations under default settings, using the CIoU loss (same one used during training) combined with Best Possible Recall (BPR) as its fitness function.
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 --noautoanchor
flag:
python train.py --noautoanchor
π 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 the model using the following command
Where is the new anchor file is saved to train the model again? I have an image size of 4800x2728 with greater number of labels in image