Skip to content

Commit 8930e22

Browse files
authored
Evolution commented hyp['anchors'] fix (#3887)
Fix for `KeyError: 'anchors'` error when start hyperparameter evolution: ```bash python train.py --evolve ``` ```bash Traceback (most recent call last): File "E:\yolov5\train.py", line 623, in <module> hyp[k] = max(hyp[k], v[1]) # lower limit KeyError: 'anchors' ```
1 parent 3c3f8fb commit 8930e22

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

train.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,8 @@ def main(opt):
596596

597597
with open(opt.hyp) as f:
598598
hyp = yaml.safe_load(f) # load hyps dict
599+
if 'anchors' not in hyp: # anchors commented in hyp.yaml
600+
hyp['anchors'] = 3
599601
assert LOCAL_RANK == -1, 'DDP mode not implemented for --evolve'
600602
opt.notest, opt.nosave = True, True # only test/save final epoch
601603
# ei = [isinstance(x, (int, float)) for x in hyp.values()] # evolvable indices

0 commit comments

Comments
 (0)