Skip to content

Commit

Permalink
Evolution commented hyp['anchors'] fix (#3887)
Browse files Browse the repository at this point in the history
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'
```
  • Loading branch information
glenn-jocher authored Jul 5, 2021
1 parent 3c3f8fb commit 8930e22
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ def main(opt):

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

0 comments on commit 8930e22

Please sign in to comment.