Skip to content

Commit

Permalink
Fixed a bug for Hyperparameters Evolution. (WongKinYiu#344)
Browse files Browse the repository at this point in the history
* Update hyp.scratch.custom.yaml

anchors parameter missing, evolution won't start without.

* Update train.py

Updated the hyperparameter evolution metadata variable to match the hyp.yaml files for the evolution to run successfully.

* Update hyp.scratch.p5.yaml

Added the anchors parameter, evolution don't start without it.

* Update hyp.scratch.p6.yaml

added the anchors parameter for the hyperparameter evolution.

* Update hyp.scratch.tiny.yaml

added the anchors parameter for the hyperparameters evolution

* Update hyp.scratch.custom.yaml

* Update hyp.scratch.tiny.yaml

* Update hyp.scratch.p5.yaml

* Update hyp.scratch.p6.yaml

* Update train.py

* Update train_aux.py
  • Loading branch information
Dhiaeddine-Oussayed authored Jul 28, 2022
1 parent 264fc09 commit 0d882e5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions data/hyp.scratch.custom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ obj: 0.7 # obj loss gain (scale with pixels)
obj_pw: 1.0 # obj BCELoss positive_weight
iou_t: 0.20 # IoU training threshold
anchor_t: 4.0 # anchor-multiple threshold
# anchors: 3 # anchors per output layer (0 to ignore)
fl_gamma: 0.0 # focal loss gamma (efficientDet default gamma=1.5)
hsv_h: 0.015 # image HSV-Hue augmentation (fraction)
hsv_s: 0.7 # image HSV-Saturation augmentation (fraction)
Expand Down
1 change: 1 addition & 0 deletions data/hyp.scratch.p5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ obj: 0.7 # obj loss gain (scale with pixels)
obj_pw: 1.0 # obj BCELoss positive_weight
iou_t: 0.20 # IoU training threshold
anchor_t: 4.0 # anchor-multiple threshold
# anchors: 3 # anchors per output layer (0 to ignore)
fl_gamma: 0.0 # focal loss gamma (efficientDet default gamma=1.5)
hsv_h: 0.015 # image HSV-Hue augmentation (fraction)
hsv_s: 0.7 # image HSV-Saturation augmentation (fraction)
Expand Down
1 change: 1 addition & 0 deletions data/hyp.scratch.p6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ obj: 0.7 # obj loss gain (scale with pixels)
obj_pw: 1.0 # obj BCELoss positive_weight
iou_t: 0.20 # IoU training threshold
anchor_t: 4.0 # anchor-multiple threshold
# anchors: 3 # anchors per output layer (0 to ignore)
fl_gamma: 0.0 # focal loss gamma (efficientDet default gamma=1.5)
hsv_h: 0.015 # image HSV-Hue augmentation (fraction)
hsv_s: 0.7 # image HSV-Saturation augmentation (fraction)
Expand Down
1 change: 1 addition & 0 deletions data/hyp.scratch.tiny.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ obj: 1.0 # obj loss gain (scale with pixels)
obj_pw: 1.0 # obj BCELoss positive_weight
iou_t: 0.20 # IoU training threshold
anchor_t: 4.0 # anchor-multiple threshold
# anchors: 3 # anchors per output layer (0 to ignore)
fl_gamma: 0.0 # focal loss gamma (efficientDet default gamma=1.5)
hsv_h: 0.015 # image HSV-Hue augmentation (fraction)
hsv_s: 0.7 # image HSV-Saturation augmentation (fraction)
Expand Down
11 changes: 9 additions & 2 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,15 @@ def train(hyp, opt, device, tb_writer=None):
'flipud': (1, 0.0, 1.0), # image flip up-down (probability)
'fliplr': (0, 0.0, 1.0), # image flip left-right (probability)
'mosaic': (1, 0.0, 1.0), # image mixup (probability)
'mixup': (1, 0.0, 1.0)} # image mixup (probability)

'mixup': (1, 0.0, 1.0), # image mixup (probability)
'copy_paste': (1, 0.0, 1.0), # segment copy-paste (probability)
'paste_in': (1, 0.0, 1.0)} # segment copy-paste (probability)

with open(opt.hyp, errors='ignore') as f:
hyp = yaml.safe_load(f) # load hyps dict
if 'anchors' not in hyp: # anchors commented in hyp.yaml
hyp['anchors'] = 3

assert opt.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
7 changes: 6 additions & 1 deletion train_aux.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,12 @@ def train(hyp, opt, device, tb_writer=None):
'fliplr': (0, 0.0, 1.0), # image flip left-right (probability)
'mosaic': (1, 0.0, 1.0), # image mixup (probability)
'mixup': (1, 0.0, 1.0)} # image mixup (probability)


with open(opt.hyp, errors='ignore') as f:
hyp = yaml.safe_load(f) # load hyps dict
if 'anchors' not in hyp: # anchors commented in hyp.yaml
hyp['anchors'] = 3

assert opt.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 0d882e5

Please sign in to comment.