glenn-jocher commited on
Commit
8930e22
·
unverified ·
1 Parent(s): 3c3f8fb

Evolution commented `hyp['anchors']` fix (#3887)

Browse files

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'
```

Files changed (1) hide show
  1. train.py +2 -0
train.py CHANGED
@@ -596,6 +596,8 @@ def main(opt):
596
 
597
  with open(opt.hyp) as f:
598
  hyp = yaml.safe_load(f) # load hyps dict
 
 
599
  assert LOCAL_RANK == -1, 'DDP mode not implemented for --evolve'
600
  opt.notest, opt.nosave = True, True # only test/save final epoch
601
  # ei = [isinstance(x, (int, float)) for x in hyp.values()] # evolvable indices
 
596
 
597
  with open(opt.hyp) as f:
598
  hyp = yaml.safe_load(f) # load hyps dict
599
+ if 'anchors' not in hyp: # anchors commented in hyp.yaml
600
+ hyp['anchors'] = 3
601
  assert LOCAL_RANK == -1, 'DDP mode not implemented for --evolve'
602
  opt.notest, opt.nosave = True, True # only test/save final epoch
603
  # ei = [isinstance(x, (int, float)) for x in hyp.values()] # evolvable indices