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, [email protected], [email protected]: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).

你可能感兴趣的:(YOLO,计算机视觉,深度学习,目标检测)