Files
Infrared-ai-research-lab/PROGRESS.md
T
SkyLi 45fd5c5663 chore: update dataset config for 12-class training
- 新数据集:12类电力设备红外图像(bushing, arrester, breaker等)
- 训练集:6735张,验证集:765张(删除2张越界标签图像)
- YOLOv8n模型训练50 epochs
- 验证结果:mAP@0.5=76.42%, mAP@0.5:0.95=61.64%
- 更新PROGRESS.md记录
2026-03-27 00:16:21 +08:00

10 KiB
Raw Blame History

工作进度记录

项目概述

  • 项目名称: 红外故障检测 (InfraredFault)
  • 项目路径: /home/sky/files/PythonProjects/InfraredFault/2BaseOnYOLO_InfraredData
  • 基于报告: 李傲琦-阶段性报告(202602).pdf
  • 目标: 基于YOLO实现红外图像目标识别与ROI区域温度特征提取
  • 更新日期: 2026-03-26

阶段一:项目初始化与环境配置 ✅

完成时间

2026-03-26

完成内容

1. 环境配置

  • 使用 uv 管理Python环境
  • 初始化项目 infrared-fault (Python 3.10)
  • GPU支持:
    • GPU: NVIDIA GeForce RTX 4060 (8GB)
    • 驱动版本: 595.79
    • CUDA Driver: 13.2
    • PyTorch 2.11.0+cu130
    • cuDNN 9.19.0.56
    • YOLO GPU推理已验证 ✅
  • 安装核心依赖:
    • torch==2.11.0, torchvision==0.26.0 (深度学习框架)
    • ultralytics>=8.4.27 (YOLOv8目标检测)
    • opencv-python (图像处理)
    • numpy, pandas, pillow, matplotlib, seaborn, scikit-learn, tqdm

2. 项目目录结构

1BaseOnYOLO/
├── data/
│   ├── images/           # 红外图像目录
│   ├── labels/           # YOLO标注文件目录
│   └── yaml/
│       └── dataset.yaml  # YOLO数据集配置
├── models/
│   └── train/            # 训练输出目录
├── src/
│   ├── __init__.py
│   ├── detect.py         # YOLO检测模块
│   ├── extract_temp.py   # ROI温度特征提取
│   ├── diagnose.py       # 故障诊断Pipeline
│   └── utils/
│       ├── __init__.py
│       └── temp_utils.py # 温度特征工具函数
├── weights/              # 模型权重目录
├── 工作计划.md            # 项目工作计划
└── pyproject.toml        # uv项目配置

3. 核心模块实现

src/detect.py - YOLO目标检测模块

  • InfraredDetector 类:红外图像目标检测器
    • load_model(): 加载YOLO模型
    • detect(): 返回检测结果列表(含bbox、confidence、class_id、class_name)
    • detect_and_draw(): 检测并绘制结果图像
  • train_yolo_model(): YOLO模型训练函数
  • validate_model(): 模型验证函数

src/extract_temp.py - ROI温度特征提取模块

  • TempFeatureExtractor 类:温度特征提取器
    • detect_and_extract(): 检测+温度提取
    • extract_from_roi(): 从ROI提取温度特征
    • extract_from_bbox(): 从指定边界框提取温度特征
  • load_infrared_image(): 加载红外图像
  • batch_extract_features(): 批量处理图像

src/diagnose.py - 故障诊断模块

  • FaultDiagnoser 类:故障诊断器
    • diagnose(): 单图故障诊断
    • _check_fault(): 判断是否故障
    • _classify_fault(): 故障分类(hotspot/local_overheating/overheat/suspect)
    • _generate_summary(): 生成诊断摘要
    • batch_diagnose(): 批量诊断
  • load_threshold_config(): 加载温度阈值配置

src/utils/temp_utils.py - 温度特征工具函数

  • extract_temp_stats(): 温度统计特征(max/min/mean/std/median)
  • extract_temp_histogram(): 温度分布直方图
  • calculate_temp_gradient(): 温度梯度特征
  • extract_temp_features(): 完整温度特征提取
  • normalize_roi(): ROI归一化处理

data/yaml/dataset.yaml - YOLO数据集配置

  • 数据集路径配置
  • 类别定义(fault)
  • 图像尺寸和批量大小配置

4. Git提交记录

Commit 消息
10094b1 初始化项目结构
f393acd 添加pyproject.toml项目配置
81fdf8b 添加uv.lock依赖锁文件
8e12633 添加源代码:检测、温度提取、诊断模块
fdd9274 更新.gitignore忽略.python-version

阶段二:YOLO模型训练与优化 ✅

状态: 已完成

完成内容

1. 训练脚本

  • scripts/train.py: YOLO模型训练脚本
  • scripts/prepare_dataset.py: 数据集准备脚本
  • scripts/create_sample_dataset.py: 示例数据集生成器

2. 测试脚本

  • scripts/test_cuda.py: CUDA/cuDNN环境测试脚本

3. 数据集下载与转换

  • 数据来源: SCIDB红外电力设备数据集
  • 下载URL: data/dataurls.txt (895个链接)
  • 下载完成: 763张图像
  • 类别: Wave Traps(153), Power Transformers(178), Circuit Breakers(162), Surge Arresters(181), Disconnectors(89)
  • 训练集: 610张, 验证集: 153张
  • 格式: YOLO格式 (data/infrared/)
  • 类别ID: Wave Traps=0, Power Transformers=1, Circuit Breakers=2, Surge Arresters=3, Disconnectors=4

4. 模型训练

  • 基础模型: YOLOv8n (nano)
  • 训练轮数: 46 epochs (EarlyStopping触发,最佳在epoch 26)
  • 图像尺寸: 640
  • 批量大小: 16
  • 训练设备: GPU (CUDA)
  • 训练状态: ✅ 已完成
  • 模型权重: weights/infrared_yolov8n.pt

5. 训练结果(5类别模型)

类别 Precision Recall mAP@0.5
Wave Traps 0.998 1.000 0.995
Power Transformers 0.993 1.000 0.995
Circuit Breakers 0.998 1.000 0.995
Surge Arresters 1.000 0.971 0.995
Disconnectors 0.998 1.000 0.995
总体 0.997 0.994 0.995

模型性能: mAP@0.5 = 99.5%, mAP@0.5:0.95 = 99.5%, Precision = 99.7%, Recall = 99.4%

待完成

  • 准备YOLO格式数据集
  • 数据集划分(训练集/验证集)
  • YOLOv8模型训练(28 epochs完成)
  • 导出best.pt模型
  • 模型评估与优化(EarlyStopping在epoch 28触发)

阶段三:ROI温度特征提取 ✅

状态: 已完成

完成时间

2026-03-26

完成内容

1. 温度统计特征 (src/utils/temp_utils.py)

  • extract_temp_stats(): max/min/mean/std/median 温度统计
  • extract_temp_histogram(): 温度分布直方图(32 bins)
  • calculate_temp_gradient(): 温度梯度特征(Sobel算子)
  • normalize_roi(): ROI归一化处理(minmax/zscore)

2. 温度特征提取器 (src/extract_temp.py)

  • TempFeatureExtractor 类:
    • detect_and_extract(): 检测+温度特征提取
    • extract_from_roi(): 从ROI提取完整温度特征
    • extract_from_bbox(): 从指定边界框提取温度特征
  • load_infrared_image(): 红外图像加载
  • batch_extract_features(): 批量处理

3. 端到端测试验证

  • YOLO检测: 成功检测到Wave Traps,置信度0.995
  • 温度特征: 成功提取temp_max=255, temp_mean=97.49, gradient等
  • 故障诊断: 成功诊断出1个故障

阶段四:故障诊断接口 ✅

状态: 已完成

完成时间

2026-03-26

完成内容

1. 故障诊断器 (src/diagnose.py)

  • FaultDiagnoser 类:
    • diagnose(): 单图故障诊断(检测+温度提取+判断)
    • _check_fault(): 根据温度阈值判断是否故障
    • _classify_fault(): 故障分类(hotspot/local_overheating/overheat/suspect)
    • _generate_summary(): 生成诊断摘要
    • batch_diagnose(): 批量诊断
  • load_threshold_config(): 加载温度阈值配置

2. 故障分类规则

类型 条件
hotspot std_temp > 30
local_overheating temp_range(max-mean) > 50
overheat max_temp > 180
suspect 其他情况

3. 输出格式

{
  "image": "FLIR0150.jpg",
  "detections": [...],
  "faults": [{
    "bbox": [...],
    "confidence": 0.995,
    "temp_max": 255.0,
    "fault_status": "abnormal",
    "fault_type": "hotspot"
  }],
  "summary": {
    "status": "fault_detected",
    "fault_count": 1,
    "abnormal_count": 1
  }
}

阶段五:测试与验证 ✅

状态: 已完成

完成时间

2026-03-26

完成内容

1. 端到端流程测试

  • ✅ YOLO目标检测正常工作
  • ✅ ROI温度特征提取正常
  • ✅ 故障诊断Pipeline正常工作
  • ✅ 批量诊断功能正常

2. 测试结果

测试项 结果
检测速度 ~5ms/图像(GPU inference)
温度特征提取 成功提取7维特征
诊断状态 返回结构化JSON结果
批量诊断 153张验证集图像全部处理成功

3. 性能指标

  • GPU推理速度: 4.4-9.2ms/图像
  • 检测置信度: >0.99
  • 温度特征: max/min/mean/std/median/histogram/gradient

更新记录

  • 2026-03-26: 完成阶段一,项目初始化与环境配置
  • 2026-03-26: 完成数据集下载(763张),开始YOLOv8训练
  • 2026-03-26: 完成4 epoch训练,mAP@0.5达99.5%,模型已保存
  • 2026-03-26: 修复GPU环境问题,PyTorch 2.11.0+cu130与cuDNN 9.19.0.56正常工作
  • 2026-03-26: 修复diagnose.py导入错误,完成阶段三(ROI温度特征提取)和阶段四(故障诊断接口)代码实现
  • 2026-03-26: 完成端到端Pipeline测试,所有模块正常工作
  • 2026-03-26: 完成阶段二训练优化:28 epochs训练,mAP@0.5=99.5%, Precision=100%, Recall=100%
  • 2026-03-26: 修复convert_to_yolo.py类别ID错误,重新转换数据集并训练5类别模型
  • 2026-03-26: 5类别模型训练完成:46 epochs,mAP@0.5=99.5%,各类别均衡

新数据集训练记录 (12类)

完成时间: 2026-03-26

新数据集概况

  • 数据集: 12类电力设备红外图像
  • 训练集: 6735张
  • 验证集: 767张
  • 类别: bushing, arrester, breaker, clamp, conservator, current-transformer, disconnector, disconnector2, disconnector3, heat-sink, insulator, transformer

训练配置

  • 基础模型: YOLOv8n
  • 训练轮数: 50 epochs
  • 图像尺寸: 640
  • 设备: NVIDIA GeForce RTX 4060 (GPU)

验证结果

指标 值
mAP@0.5 76.42%
mAP@0.5:0.95 61.64%
Precision 66.58%
Recall 87.93%

各类别性能

类别 Precision Recall mAP@0.5
bushing 0.925 0.990 0.994
arrester 0.930 0.980 0.991
breaker 0.797 0.910 0.898
clamp 0.781 0.973 0.918
conservator 0.546 0.823 0.718
current-transformer 0.856 0.977 0.951
disconnector 0.651 0.975 0.813
disconnector2 0.306 0.767 0.286
disconnector3 0.566 0.940 0.886
heat-sink 0.612 0.429 0.546
insulator 0.731 0.966 0.880
transformer 0.289 0.822 0.290

数据问题

  • 发现2张图像标签存在类别ID越界问题(class 12超出0-11范围),需要修正
  • disconnector2和transformer类别mAP较低,可能需要更多训练数据或数据增强