Files
ModelTrainEval/configs/detect/film.yaml
T

58 lines
2.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 在 Grad-CAM / SHAP 生成的弱监督框上训练 YOLO 检测模型。
#
# 前置步骤:
# uv run python scripts/generate_boxes.py --config ... --method gradcam # 产出 runs/boxes_gradcam
# uv run python scripts/prepare_yolo_dataset.py --source runs/boxes_gradcam
#
# 用法:
# uv run python detect.py --config configs/detect/film.yaml
# uv run python detect.py --config configs/detect/film.yaml --eval-only \
# --checkpoint runs/detect/film/weights/best.pt
work_dir: runs/detect/film
seed: 42
device: auto
data:
yaml: data/boxes_shap/data.yaml
model:
# 选 v8 而不是 v11/v12:CLAUDE.md 限定只用 convolution 模型,
# 而 YOLO11 的骨架里有 C2PSA(position-sensitive attention)、YOLO12 更是以注意力为主。
# YOLOv8 的 C2f + SPPF 是纯卷积。
# s 是精度/速度的折中;数据只有 1.1 万张且标签是弱监督的,再大容易把标注噪声也学进去。
weights: yolov8s.pt
train:
epochs: 100
imgsz: 640
batch: 16
workers: 8
optimizer: auto
patience: 20 # 20 轮没提升就早停
cos_lr: true
fraction: 1.0 # 只取训练集的一部分;冒烟测试时调小,如 0.02
amp: true # 非 CUDA 后端 ultralytics 会自行退回关闭
# 数据增强。翻转按聚类阶段的结论开着(缺陷没有固定朝向);
# 但 mosaic/mixup 关掉——它们会把四张图拼在一起,而我们每张图只有一个弱监督框,
# 拼接后小目标被缩得更小,对 blackdot / whitedot 这类本来就只占千分之几面积的类别是伤害。
fliplr: 0.5
flipud: 0.5
degrees: 0.0
mosaic: 0.0
mixup: 0.0
hsv_h: 0.0 # 单色/近单色的薄膜图,色相扰动没有意义
hsv_s: 0.3
hsv_v: 0.3
plots: true # results.png / PR 曲线 / 混淆矩阵 / val_batch 预测图
save_period: -1
swanlab:
enabled: true
project: film-detect
name: null
mode: local
tags: [detect, yolov8s, gradcam-boxes]