diff --git a/best_isolator_model.pt b/best_isolator_model.pt new file mode 100644 index 0000000..c017f36 Binary files /dev/null and b/best_isolator_model.pt differ diff --git a/model.pt b/model.pt new file mode 100644 index 0000000..e69de29 diff --git a/train.py b/train.py index 6a1d456..0618450 100644 --- a/train.py +++ b/train.py @@ -1,3 +1,4 @@ + """ YOLOv12 绝缘子检测优化训练脚本(最终稳定版) 主要改进: @@ -17,28 +18,30 @@ import numpy as np # +++ 有效参数配置区块 +++ TRAIN_CONFIG = { "stage1": { - "freeze": [0,1,2,3,4], # 冻结前5层 - "epochs": 50, - "batch": 16, - "lr0": 0.005, # 初始学习率 - "lrf": 0.05, # 最终学习率 - "hsv_h": 0.01, # 色相增强幅度 - "degrees": 5.0, # 旋转角度范围 - "perspective": 0.001, # 透视变换 - "flipud": 0.1, # 上下翻转概率 - "optimizer": "SGD", # 优化器类型 - "weight_decay": 0.001, # 权重衰减 - "label_smoothing": 0.1 # 标签平滑 + "freeze": [0, 1, 2, 3, 4], # 冻结前5层 + "epochs": 75, # 增加训练轮数 + "batch": 32, # 增加批量大小 + "lr0": 0.001, # 降低初始学习率 + "lrf": 0.1, # 提高最终学习率 + "hsv_h": 0.01, # 色相增强幅度 + "degrees": 10.0, # 增加旋转角度范围 + "perspective": 0.005, # 增加透视变换 + "flipud": 0.2, # 增加上下翻转概率 + "optimizer": "SGD", # 优化器类型 + "weight_decay": 0.001, # 权重衰减 + "label_smoothing": 0.1, # 标签平滑 + "mosaic": True, # 启用Mosaic增强 + "class_weights": [1.0, 2.0] # 设置类别权重,insulator权重更高 }, "stage2": { - "epochs": 100, - "batch": 8, - "lr0": 0.0005, - "lrf": 0.005, - "mixup": 0.15, # MixUp增强系数 - "close_mosaic": 10, # 最后10epoch关闭Mosaic - "optimizer": "AdamW", # 优化器切换 - "warmup_epochs": 5 # 学习率预热 + "epochs": 150, # 增加训练轮数 + "batch": 16, # 增加批量大小 + "lr0": 0.0001, # 降低初始学习率 + "lrf": 0.01, # 提高最终学习率 + "mixup": 0.2, # 增加MixUp增强系数 + "close_mosaic": 10, # 最后10epoch关闭Mosaic + "optimizer": "AdamW", # 切换优化器为AdamW + "warmup_epochs": 10 # 增大学习率预热轮数 } }