电力设备红外图像目标检测数据集
10000张
21种检测目标:
Arrester body - 绝缘子主体
Arrester voltage equalizing ring - 绝缘子电压均衡环
Breaker - 断路器
Breaker connector - 断路器连接器
Breaker support insulator - 断路器支撑绝缘子
Casing connector - 外壳连接器
Casing general hat - 外壳通用帽
Casing porcelain sleeve - 外壳瓷套
Casing pressure equalizing ring - 外壳压力均衡环
Current transformer connector - 电流互感器连接器
Current transformer general cap - 电流互感器通用盖
Current transformer head - 电流互感器头部
Current transformer porcelain sleeve - 电流互感器瓷套
Current transformer secondary tank - 电流互感器二次罐
Current transformer voltage equalizing ring - 电流互感器电压均衡环
Knife blade - 刀片
Knife gate connector - 刀闸连接器
Knife gate fixing pin - 刀闸固定销
Knife gate support insulator - 刀闸支撑绝缘子
Voltage transformer body - 电压互感器主体
Voltage transformer secondary tank - 电压互感器二次罐
电力设备红外图像目标检测数据集介绍
数据集名称
电力设备红外图像目标检测数据集 (Power Equipment Infrared Image Object Detection Dataset)
数据集描述
本数据集旨在支持电力设备红外图像中的目标检测任务,特别适用于电力系统的维护、故障诊断和自动化监控等领域。通过使用该数据集训练的目标检测模型可以帮助识别和定位电力设备中的关键部件,提高巡检效率和准确性。
数据量
- 总图片数: 10,000张
- 类别数: 21种
检测目标
- 绝缘子主体 (Arrester body)
- 绝缘子电压均衡环 (Arrester voltage equalizing ring)
- 断路器 (Breaker)
- 断路器连接器 (Breaker connector)
- 断路器支撑绝缘子 (Breaker support insulator)
- 外壳连接器 (Casing connector)
- 外壳通用帽 (Casing general hat)
- 外壳瓷套 (Casing porcelain sleeve)
- 外壳压力均衡环 (Casing pressure equalizing ring)
- 电流互感器连接器 (Current transformer connector)
- 电流互感器通用盖 (Current transformer general cap)
- 电流互感器头部 (Current transformer head)
- 电流互感器瓷套 (Current transformer porcelain sleeve)
- 电流互感器二次罐 (Current transformer secondary tank)
- 电流互感器电压均衡环 (Current transformer voltage equalizing ring)
- 刀片 (Knife blade)
- 刀闸连接器 (Knife gate connector)
- 刀闸固定销 (Knife gate fixing pin)
- 刀闸支撑绝缘子 (Knife gate support insulator)
- 电压互感器主体 (Voltage transformer body)
- 电压互感器二次罐 (Voltage transformer secondary tank)
数据格式
- 图像格式: 红外图像 (JPEG或PNG)
- 标注格式: YOLO格式(每个图像对应一个文本文件,包含边界框坐标及类别标签)
目录结构
power_equipment_infrared_dataset/
├── images/
│ ├── train/
│ │ ├── img1.jpg
│ │ ├── img2.jpg
│ │ └── ...
│ ├── val/
│ │ ├── img10001.jpg
│ │ ├── img10002.jpg
│ │ └── ...
├── labels/
│ ├── train/
│ │ ├── img1.txt
│ │ ├── img2.txt
│ │ └── ...
│ ├── val/
│ │ ├── img10001.txt
│ │ ├── img10002.txt
│ │ └── ...
└── data.yaml
data.yaml
配置文件
train: ./power_equipment_infrared_dataset/images/train
val: ./power_equipment_infrared_dataset/images/val
nc: 21 # 类别数量
names: ['arrester_body', 'arrester_voltage_equalizing_ring', 'breaker', 'breaker_connector',
'breaker_support_insulator', 'casing_connector', 'casing_general_hat', 'casing_porcelain_sleeve',
'casing_pressure_equalizing_ring', 'current_transformer_connector', 'current_transformer_general_cap',
'current_transformer_head', 'current_transformer_porcelain_sleeve', 'current_transformer_secondary_tank',
'current_transformer_voltage_equalizing_ring', 'knife_blade', 'knife_gate_connector', 'knife_gate_fixing_pin',
'knife_gate_support_insulator', 'voltage_transformer_body', 'voltage_transformer_secondary_tank']
使用方法
1. 安装依赖库
确保安装了必要的Python库,如pandas
(用于处理CSV文件)、torch
(PyTorch)、ultralytics
(用于YOLOv5/v7/v8)和其他相关依赖:
pip install pandas torch ultralytics
2. 训练脚本
以下是一个简单的训练脚本示例,展示如何使用YOLOv5进行训练。
YOLOv5 训练脚本
from ultralytics import YOLO
import torch
# 设置设备
device = 'cuda' if torch.cuda.is_available() else 'cpu'
# 加载预训练模型或从头开始训练
model = YOLO('yolov5s.pt') # 使用预训练的YOLOv5s模型
# model = YOLO() # 从头开始训练
# 开始训练
results = model.train(
data='path/to/data.yaml', # 指定数据集配置文件路径
epochs=100, # 训练轮次
batch=16, # 批处理大小
imgsz=640, # 输入图像尺寸
workers=8, # 数据加载线程数
device=device, # 使用GPU设备编号,默认为0
project='power_equipment_infrared_detection', # 保存结果的项目名称
name='exp', # 实验名称
exist_ok=True # 如果存在相同实验名,覆盖旧的结果
)
# 可视化训练结果
results.plot()
# 保存模型
model.save('power_equipment_infrared_detection_model.pt')
3. 推理代码
以下是一个简单的推理代码示例,展示如何使用训练好的YOLOv5模型进行推理。
YOLOv5 推理代码
import cv2
from ultralytics import YOLO
# 加载训练好的模型
model = YOLO('power_equipment_infrared_detection_model.pt')
def detect_objects(image_path):
# 读取图像
image = cv2.imread(image_path)
# 进行推理
results = model(image)
# 绘制检测结果
for result in results:
boxes = result.boxes
for box in boxes:
x1, y1, x2, y2 = map(int, box.xyxy[0])
label = model.names[int(box.cls)]
confidence = float(box.conf)
color = (0, 255, 0) # 绿色
cv2.rectangle(image, (x1, y1), (x2, y2), color, 2)
cv2.putText(image, f'{label} {confidence:.2f}', (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
# 显示检测结果
cv2.imshow('Detection Result', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
# 示例用法
image_path = 'path/to/your/image.jpg'
detect_objects(image_path)
图形用户界面 (GUI) 设计
如果您希望提供一个更友好的用户界面,可以使用tkinter
来创建一个简单的GUI。
1. 安装依赖库
确保安装了tkinter
库,用于创建图形界面:
pip install tk
2. GUI代码示例
以下是一个简单的Tkinter GUI示例,展示如何创建一个用户友好的图形界面,支持加载图像并进行目标检测。
import tkinter as tk
from tkinter import filedialog, messagebox
from PIL import Image, ImageTk
import cv2
from ultralytics import YOLO
# 加载训练好的模型
model = YOLO('power_equipment_infrared_detection_model.pt')
def load_image():
global image_path
image_path = filedialog.askopenfilename(filetypes=[("Image files", "*.jpg;*.jpeg;*.png")])
if image_path:
image = Image.open(image_path)
image = image.resize((640, 480))
photo = ImageTk.PhotoImage(image)
image_label.config(image=photo)
image_label.image = photo
def detect_objects():
if image_path:
# 读取图像
image = cv2.imread(image_path)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# 进行推理
results = model(image)
# 绘制检测结果
for result in results:
boxes = result.boxes
for box in boxes:
x1, y1, x2, y2 = map(int, box.xyxy[0])
label = model.names[int(box.cls)]
confidence = float(box.conf)
color = (0, 255, 0) # 绿色
cv2.rectangle(image, (x1, y1), (x2, y2), color, 2)
cv2.putText(image, f'{label} {confidence:.2f}', (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
# 显示检测结果
image = Image.fromarray(cv2.cvtColor(image, cv2.COLOR_RGB2BGR))
image = image.resize((640, 480))
photo = ImageTk.PhotoImage(image)
image_label.config(image=photo)
image_label.image = photo
# 创建主窗口
root = tk.Tk()
root.title("Power Equipment Infrared Object Detection")
# 自定义主题风格
root.tk_setPalette(background='#F0F0F0', foreground='black', activeBackground='blue', activeForeground="white")
# 图像显示区域
image_label = tk.Label(root, bg='#F0F0F0')
image_label.pack(pady=20)
# 按钮
load_button = tk.Button(root, text="Load Image", command=load_image, bg='blue', fg='white')
load_button.pack(side=tk.LEFT, padx=10)
detect_button = tk.Button(root, text="Detect Objects", command=detect_objects, bg='blue', fg='white')
detect_button.pack(side=tk.RIGHT, padx=10)
# 运行主循环
root.mainloop()
总结
这个数据集包含了10,000张电力设备的红外图像,并已进行标注,适用于训练和评估电力设备目标检测模型。数据集涵盖了21种不同的检测目标,包括绝缘子、断路器、外壳、电流互感器、刀闸和电压互感器等关键部件。通过使用YOLO系列的目标检测算法,您可以轻松地进行模型训练和推理,并且可以通过图形用户界面方便地查看检测结果。希望这些信息和代码能帮助您更好地理解和使用这个数据集
带标注 -YOLO格式 可直接用于YOLO系列目标检测算法模型训练