Files
zjsh_yolov11/zjsh_code/obb_main/train/train_obb_zengqiang.py
琉璃月光 eb16eeada3 最新推送
2026-03-10 13:58:21 +08:00

42 lines
1.4 KiB
Python
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.

from ultralytics import YOLO
if __name__ == '__main__':
# ✅ 推荐:加载官方预训练模型 或 自己的 best.pt
model = YOLO(r'yolo11-obb.yaml') #
results = model.train(
data='obb_data.yaml',
epochs=500, # 减少 epochs配合早停
patience=0, # 50 轮无提升则停止
imgsz=640,
batch=4,
workers=10,
device='0',
project='runs/train',
name='exp_obb5', # 建议递增实验编号
exist_ok=False,
# 优化器
optimizer='AdamW',
lr0=0.0005, # 更稳定的学习率
weight_decay=0.01,
momentum=0.937,
# 数据增强OBB 关键)
degrees=5.0, # 随机旋转 ±10°
translate=0.1, # 平移
scale=0.5, # 缩放比例
shear=1.0, # 剪切
flipud=0.0, # 不推荐上下翻转(角度易错)
fliplr=0.5, # ✅ 水平翻转OBB 支持良好
hsv_h=0.015, # 色调扰动
hsv_s=0.7, # 饱和度
hsv_v=0.4, # 明度
# 其他
close_mosaic=50, # 最后10轮关闭 Mosaic 增强,提升稳定性
val=True, # 每轮验证
#
amp=False,
)