diff --git a/data/hyps/hyp.finetune_objects365.yaml b/data/hyps/hyp.Objects365.yaml similarity index 68% rename from data/hyps/hyp.finetune_objects365.yaml rename to data/hyps/hyp.Objects365.yaml index 073720a65be5..74971740f7c7 100644 --- a/data/hyps/hyp.finetune_objects365.yaml +++ b/data/hyps/hyp.Objects365.yaml @@ -1,4 +1,7 @@ # YOLOv5 🚀 by Ultralytics, GPL-3.0 license +# Hyperparameters for Objects365 training +# python train.py --weights yolov5m.pt --data Objects365.yaml --evolve +# See Hyperparameter Evolution tutorial for details https://github.com/ultralytics/yolov5#tutorials lr0: 0.00258 lrf: 0.17 diff --git a/data/hyps/hyp.VOC.yaml b/data/hyps/hyp.VOC.yaml new file mode 100644 index 000000000000..aa952c501969 --- /dev/null +++ b/data/hyps/hyp.VOC.yaml @@ -0,0 +1,40 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license +# Hyperparameters for VOC training +# python train.py --batch 128 --weights yolov5m6.pt --data VOC.yaml --epochs 50 --img 512 --hyp hyp.scratch-med.yaml --evolve +# See Hyperparameter Evolution tutorial for details https://github.com/ultralytics/yolov5#tutorials + +# YOLOv5 Hyperparameter Evolution Results +# Best generation: 319 +# Last generation: 434 +# metrics/precision, metrics/recall, metrics/mAP_0.5, metrics/mAP_0.5:0.95, val/box_loss, val/obj_loss, val/cls_loss +# 0.86236, 0.86184, 0.91274, 0.72647, 0.0077056, 0.0042449, 0.0013846 + +lr0: 0.0033 +lrf: 0.15184 +momentum: 0.74747 +weight_decay: 0.00025 +warmup_epochs: 3.4278 +warmup_momentum: 0.59032 +warmup_bias_lr: 0.18742 +box: 0.02 +cls: 0.21563 +cls_pw: 0.5 +obj: 0.50843 +obj_pw: 0.6729 +iou_t: 0.2 +anchor_t: 3.4172 +fl_gamma: 0.0 +hsv_h: 0.01032 +hsv_s: 0.5562 +hsv_v: 0.28255 +degrees: 0.0 +translate: 0.04575 +scale: 0.73711 +shear: 0.0 +perspective: 0.0 +flipud: 0.0 +fliplr: 0.5 +mosaic: 0.87158 +mixup: 0.04294 +copy_paste: 0.0 +anchors: 3.3556 diff --git a/data/hyps/hyp.finetune.yaml b/data/hyps/hyp.finetune.yaml deleted file mode 100644 index b89d66ff8dee..000000000000 --- a/data/hyps/hyp.finetune.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# YOLOv5 🚀 by Ultralytics, GPL-3.0 license -# Hyperparameters for VOC finetuning -# python train.py --batch 64 --weights yolov5m.pt --data VOC.yaml --img 512 --epochs 50 -# See tutorials for hyperparameter evolution https://github.com/ultralytics/yolov5#tutorials - -# Hyperparameter Evolution Results -# Generations: 306 -# P R mAP.5 mAP.5:.95 box obj cls -# Metrics: 0.6 0.936 0.896 0.684 0.0115 0.00805 0.00146 - -lr0: 0.0032 -lrf: 0.12 -momentum: 0.843 -weight_decay: 0.00036 -warmup_epochs: 2.0 -warmup_momentum: 0.5 -warmup_bias_lr: 0.05 -box: 0.0296 -cls: 0.243 -cls_pw: 0.631 -obj: 0.301 -obj_pw: 0.911 -iou_t: 0.2 -anchor_t: 2.91 -# anchors: 3.63 -fl_gamma: 0.0 -hsv_h: 0.0138 -hsv_s: 0.664 -hsv_v: 0.464 -degrees: 0.373 -translate: 0.245 -scale: 0.898 -shear: 0.602 -perspective: 0.0 -flipud: 0.00856 -fliplr: 0.5 -mosaic: 1.0 -mixup: 0.243 -copy_paste: 0.0 diff --git a/data/hyps/hyp.scratch.yaml b/data/hyps/hyp.scratch.yaml deleted file mode 100644 index 31f6d142e285..000000000000 --- a/data/hyps/hyp.scratch.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# YOLOv5 🚀 by Ultralytics, GPL-3.0 license -# Hyperparameters for COCO training from scratch -# python train.py --batch 40 --cfg yolov5m.yaml --weights '' --data coco.yaml --img 640 --epochs 300 -# See tutorials for hyperparameter evolution https://github.com/ultralytics/yolov5#tutorials - -lr0: 0.01 # initial learning rate (SGD=1E-2, Adam=1E-3) -lrf: 0.1 # final OneCycleLR learning rate (lr0 * lrf) -momentum: 0.937 # SGD momentum/Adam beta1 -weight_decay: 0.0005 # optimizer weight decay 5e-4 -warmup_epochs: 3.0 # warmup epochs (fractions ok) -warmup_momentum: 0.8 # warmup initial momentum -warmup_bias_lr: 0.1 # warmup initial bias lr -box: 0.05 # box loss gain -cls: 0.5 # cls loss gain -cls_pw: 1.0 # cls BCELoss positive_weight -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) -hsv_v: 0.4 # image HSV-Value augmentation (fraction) -degrees: 0.0 # image rotation (+/- deg) -translate: 0.1 # image translation (+/- fraction) -scale: 0.5 # image scale (+/- gain) -shear: 0.0 # image shear (+/- deg) -perspective: 0.0 # image perspective (+/- fraction), range 0-0.001 -flipud: 0.0 # image flip up-down (probability) -fliplr: 0.5 # image flip left-right (probability) -mosaic: 1.0 # image mosaic (probability) -mixup: 0.0 # image mixup (probability) -copy_paste: 0.0 # segment copy-paste (probability) diff --git a/train.py b/train.py index 88586fde395e..d8df31b72282 100644 --- a/train.py +++ b/train.py @@ -456,7 +456,7 @@ def parse_opt(known=False): parser.add_argument('--weights', type=str, default=ROOT / 'yolov5s.pt', help='initial weights path') parser.add_argument('--cfg', type=str, default='', help='model.yaml path') parser.add_argument('--data', type=str, default=ROOT / 'data/coco128.yaml', help='dataset.yaml path') - parser.add_argument('--hyp', type=str, default=ROOT / 'data/hyps/hyp.scratch.yaml', help='hyperparameters path') + parser.add_argument('--hyp', type=str, default=ROOT / 'data/hyps/hyp.scratch-low.yaml', help='hyperparameters path') parser.add_argument('--epochs', type=int, default=300) parser.add_argument('--batch-size', type=int, default=16, help='total batch size for all GPUs, -1 for autobatch') parser.add_argument('--imgsz', '--img', '--img-size', type=int, default=640, help='train, val image size (pixels)') diff --git a/utils/general.py b/utils/general.py index 4b7a7c6f0cbf..3044b9c1ae78 100755 --- a/utils/general.py +++ b/utils/general.py @@ -795,7 +795,7 @@ def print_mutation(results, hyp, save_dir, bucket, prefix=colorstr('evolve: ')): # Download (optional) if bucket: url = f'gs://{bucket}/evolve.csv' - if gsutil_getsize(url) > (os.path.getsize(evolve_csv) if os.path.exists(evolve_csv) else 0): + if gsutil_getsize(url) > (evolve_csv.stat().st_size if evolve_csv.exists() else 0): os.system(f'gsutil cp {url} {save_dir}') # download evolve.csv if larger than local # Log to evolve.csv