YOLO Hyperparameter Evolution

1. HyperScratch @/data/hyps/hyp.scratch.yaml
lr0: 0.01 # initial learning rate (SGD=1E-2, Adam=1E-3)
lrf: 0.15 # 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训练阈值 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 # 图像 HSV-Hue 增强分数 image HSV-Hue augmentation (fraction)
hsv_s: 0.7 # 图像 HSV-饱和度增强分数 image HSV-Saturation augmentation (fraction)
hsv_v: 0.4 # 图像 HSV 值增强分数 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)

2. Model fitness @/utils/metrics.py
默认的fitness function比例如下

def fitness(x):
    # Model fitness as a weighted combination of metrics
    w = [0.0, 0.0, 0.1, 0.9]  # weights for [P, R, mAP@0.5, mAP@0.5:0.95]
    return (x[:, :4] * w).sum(1)

3. Envolve

# Single-GPU
python train.py --epochs 10 --data coco128.yaml --weights yolov5s.pt --cache --evolve

# Multi-GPU
for i in 0 1 2 3; do
  nohup python train.py --epochs 10 --data coco128.yaml --weights yolov5s.pt --cache --evolve --device $i > evolve_gpu_$i.log &
done

Results are logged to runs/evolve/exp/evolve.csv, and the highest fitness offspring is saved every generation as runs/evolve/hyp_evolved.yaml.

evolve.csv is plotted as evolve.png by utils.plots.plot_evolve() after evolution finishes with one subplot per hyperparameter showing fitness (y axis) vs hyperparameter values (x axis).

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Namespace(weights='yolo7.pt', cfg='cfg/training/yolov7.yaml', data='data/DOTA_split.yaml', hyp='data/hyp.scratch.p5.yaml', epochs=10, batch_size=4, img_size=[640, 640], rect=False, resume=False, nosave=False, notest=False, noautoanchor=False, evolve=False, bucket='', cache_images=False, image_weights=False, device='', multi_scale=False, single_cls=False, ada m=False, sync_bn=False, local_rank=-1, workers=8, project='runs/train', entity=None, name='exp', exist_ok=False, quad=False, linear_lr=False, label_smoothing=0.0, upload_dataset=False, bbox_interval=-1, save_period=-1, artifact_alias='latest', freeze=[0], v5_metric=False, world_size=1, global_rank=-1, save_dir='runs\\train\\exp2', total_batch_size=4) tensorboard: Start with 'tensorboard --logdir runs/train', view at http://localhost:6006/ hyperparameters: lr0=0.01, lrf=0.1, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.3, cls_pw=1.0, obj=0.7, obj_pw= 1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.2, scale=0.9, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.15, copy_paste=0.0, paste_in=0.15, loss_ota=1 Traceback (most recent call last): File "D:\Documents\Desktop\YOLO_suanfa\yolov7-main\train.py", line 618, in <module> train(hyp, opt, device, tb_writer) File "D:\Documents\Desktop\YOLO_suanfa\yolov7-main\train.py", line 64, in train data_dict = yaml.load(f, Loader=yaml.SafeLoader) # data dict File "D:\Documents\Desktop\YOLO_suanfa\yolov7-main\venv\lib\site-packages\yaml\__init__.py", line 79, in load loader = Loader(stream) File "D:\Documents\Desktop\YOLO_suanfa\yolov7-main\venv\lib\site-packages\yaml\loader.py", line 34, in __init__ Reader.__init__(self, stream) File "D:\Documents\Desktop\YOLO_suanfa\yolov7-main\venv\lib\site-packages\yaml\reader.py", line 85, in __init__ self.determine_encoding() File "D:\Documents\Desktop\YOLO_suanfa\yolov7-main\venv\lib\site-packages\yaml\reader.py", line 124, in determine_encoding self.update_raw() File "D:\Documents\Desktop\YOLO_suanfa\yolov7-main\venv\lib\site-packages\yaml\reader.py", line 178, in update_raw data = self.stream.read(size) UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 233: illegal multibyte sequence
07-15

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值