From 0d882e553e2fd43f26d79f9f67a0f2cdae0e1a45 Mon Sep 17 00:00:00 2001 From: Dhia_Oussayed <75687069+Dhiaeddine-Oussayed@users.noreply.github.com> Date: Thu, 28 Jul 2022 20:09:52 +0100 Subject: [PATCH] Fixed a bug for Hyperparameters Evolution. (#344) * 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 --- data/hyp.scratch.custom.yaml | 1 + data/hyp.scratch.p5.yaml | 1 + data/hyp.scratch.p6.yaml | 1 + data/hyp.scratch.tiny.yaml | 1 + train.py | 11 +++++++++-- train_aux.py | 7 ++++++- 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/data/hyp.scratch.custom.yaml b/data/hyp.scratch.custom.yaml index 0ec17fee..92b50d3b 100644 --- a/data/hyp.scratch.custom.yaml +++ b/data/hyp.scratch.custom.yaml @@ -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) diff --git a/data/hyp.scratch.p5.yaml b/data/hyp.scratch.p5.yaml index ca512b76..a64c4043 100644 --- a/data/hyp.scratch.p5.yaml +++ b/data/hyp.scratch.p5.yaml @@ -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) diff --git a/data/hyp.scratch.p6.yaml b/data/hyp.scratch.p6.yaml index dcb55d63..6ab7c01a 100644 --- a/data/hyp.scratch.p6.yaml +++ b/data/hyp.scratch.p6.yaml @@ -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) diff --git a/data/hyp.scratch.tiny.yaml b/data/hyp.scratch.tiny.yaml index b84fbfa9..01c6f496 100644 --- a/data/hyp.scratch.tiny.yaml +++ b/data/hyp.scratch.tiny.yaml @@ -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) diff --git a/train.py b/train.py index 00b8b24f..b87d6879 100644 --- a/train.py +++ b/train.py @@ -638,8 +638,15 @@ if __name__ == '__main__': '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 diff --git a/train_aux.py b/train_aux.py index ce33e7f6..6094beb9 100644 --- a/train_aux.py +++ b/train_aux.py @@ -639,7 +639,12 @@ if __name__ == '__main__': '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