变压器设备漏油数据集 voc txt

变压器设备漏油数据集

油浸式变压器通常采用油浸自冷式、油浸风冷式和强迫油循环三种冷却方式。该数据集采集于油浸式变压器的设备漏油情况,一般用于变电站的无人巡检,代替传统的人工巡检,与绝缘子的破损检测来源于同一课题。数据集一部分来自真实场景,由于真实场景下样本较少,外加一部分合成图片,共338张,采用VOC标注格式,新增txt格式标签,可以用于yolo训练,赠送五个常用脚本

变压器设备漏油数据集

数据集描述

该数据集是一个专门用于检测油浸式变压器设备漏油情况的数据集,旨在帮助研究人员和开发者训练和评估基于深度学习的目标检测模型。数据集涵盖了油浸自冷式、油浸风冷式和强迫油循环三种冷却方式的油浸式变压器,并记录了设备漏油的情况。通过高质量的图像和详细的标注信息,该数据集为开发高效且准确的漏油检测系统提供了坚实的基础。

数据规模

  • 总样本数量:338张图片
  • 标注格式 :
    • Pascal VOC XML格式
    • YOLO txt格式

图像特性

  • 多样化场景:覆盖了不同类型的油浸式变压器在各种环境下的图像情况。
  • 高质量手工标注:每张图像都有详细的边界框标注,支持直接用于训练目标检测模型。
  • 真实与合成结合:数据集一部分来自真实场景,另一部分是合成图片,以弥补真实场景下样本较少的问题。
  • 多类别支持:主要关注变压器设备的漏油情况,但可能包含其他相关缺陷或背景信息,丰富了数据集的多样性。
  • 无需预处理:数据集已经过处理,可以直接用于训练,无需额外的数据预处理步骤。

应用场景

  • 智能监控:自动检测变压器设备的漏油情况,辅助管理人员及时发现并采取应对措施,提高设备的安全性和可靠性。
  • 无人巡检:集成到变电站的无人巡检系统中,代替传统的人工巡检,提高巡检效率和准确性。
  • 科研分析:用于研究目标检测算法在特定工业应用场景中的表现,特别是在复杂背景和光照条件下的鲁棒性。
  • 教育与培训:可用于安全相关的教育和培训项目,帮助学生和从业人员更好地识别和理解变压器设备的漏油情况。
  • 自动化管理:集成到电力系统的管理系统中,实现对设备状态的自动化监测和管理,预防设备故障。

数据集结构

典型的数据集目录结构如下:

复制代码

深色版本

复制代码
1transformer_oil_leakage_dataset/
2├── images/
3│   ├── img_00001.jpg
4│   ├── img_00002.jpg
5│   └── ...
6├── annotations/
7│   ├── img_00001.xml  # Pascal VOC XML格式
8│   ├── img_00002.xml
9│   └── ...
10├── labels/  # YOLO txt格式
11│   ├── img_00001.txt
12│   ├── img_00002.txt
13│   └── ...
14├── scripts/
15│   ├── convert_voc_to_yolo.py
16│   ├── train_yolo.py
17│   ├── evaluate_yolo.py
18│   ├── visualize_annotations.py
19│   └── data_augmentation.py
20├── README.txt  # 数据说明文件

数据说明

  • 检测目标:以Pascal VOC XML格式和YOLO txt格式进行标注。
  • 数据集内容 :
    • 总共338张图片,每张图片都带有相应的XML和txt标注文件。
  • 标签类型 :
    • 边界框 (Bounding Box)
  • 数据增广:数据集未做数据增广,用户可以根据需要自行进行数据增广。
  • 无需预处理:数据集已经过处理,可以直接用于训练,无需额外的数据预处理步骤。

示例代码

以下是一些常用脚本的示例代码,包括将VOC格式转换为YOLO格式、训练YOLO模型、评估模型性能、可视化标注以及数据增强。

脚本1: 将VOC格式转换为YOLO格式
复制代码
复制代码
1# convert_voc_to_yolo.py
2import os
3import xml.etree.ElementTree as ET
4
5def convert_voc_to_yolo(xml_file, image_size):
6    tree = ET.parse(xml_file)
7    root = tree.getroot()
8    yolo_lines = []
9
10    for obj in root.findall('object'):
11        name = obj.find('name').text
12        bbox = obj.find('bndbox')
13        xmin = int(bbox.find('xmin').text)
14        ymin = int(bbox.find('ymin').text)
15        xmax = int(bbox.find('xmax').text)
16        ymax = int(bbox.find('ymax').text)
17
18        x_center = (xmin + xmax) / 2.0 / image_size[0]
19        y_center = (ymin + ymax) / 2.0 / image_size[1]
20        width = (xmax - xmin) / image_size[0]
21        height = (ymax - ymin) / image_size[1]
22
23        class_id = 0  # 假设只有一个类别
24        yolo_line = f"{class_id} {x_center} {y_center} {width} {height}\n"
25        yolo_lines.append(yolo_line)
26
27    return yolo_lines
28
29def main():
30    voc_dir = 'path/to/annotations'
31    yolo_dir = 'path/to/labels'
32    image_dir = 'path/to/images'
33
34    if not os.path.exists(yolo_dir):
35        os.makedirs(yolo_dir)
36
37    for xml_file in os.listdir(voc_dir):
38        if xml_file.endswith('.xml'):
39            image_path = os.path.join(image_dir, xml_file.replace('.xml', '.jpg'))
40            image = Image.open(image_path)
41            image_size = image.size
42
43            yolo_lines = convert_voc_to_yolo(os.path.join(voc_dir, xml_file), image_size)
44            with open(os.path.join(yolo_dir, xml_file.replace('.xml', '.txt')), 'w') as f:
45                f.writelines(yolo_lines)
46
47if __name__ == "__main__":
48    main()
脚本2: 训练YOLO模型
复制代码
1# train_yolo.py
2import os
3import torch
4from yolov5 import train
5
6def main():
7    data_yaml = 'path/to/data.yaml'  # 包含数据集路径和类别的配置文件
8    model_yaml = 'path/to/model.yaml'  # 模型配置文件
9    weights = 'path/to/weights.pt'  # 预训练权重(可选)
10    epochs = 100
11    batch_size = 8
12    img_size = 640
13
14    train.run(
15        data=data_yaml,
16        cfg=model_yaml,
17        weights=weights,
18        epochs=epochs,
19        batch_size=batch_size,
20        imgsz=img_size
21    )
22
23if __name__ == "__main__":
24    main()
脚本3: 评估YOLO模型
复制代码
1# evaluate_yolo.py
2import os
3import torch
4from yolov5 import val
5
6def main():
7    data_yaml = 'path/to/data.yaml'  # 包含数据集路径和类别的配置文件
8    weights = 'path/to/best.pt'  # 训练好的模型权重
9    img_size = 640
10
11    val.run(
12        data=data_yaml,
13        weights=weights,
14        imgsz=img_size
15    )
16
17if __name__ == "__main__":
18    main()
脚本4: 可视化标注
复制代码
1# visualize_annotations.py
2import os
3import cv2
4import numpy as np
5from PIL import Image
6import xml.etree.ElementTree as ET
7
8def load_image_and_boxes(image_path, annotation_path):
9    # 读取图像
10    image = Image.open(image_path).convert('RGB')
11    
12    # 解析Pascal VOC格式的XML标注文件
13    tree = ET.parse(annotation_path)
14    root = tree.getroot()
15    boxes = []
16    for obj in root.findall('object'):
17        class_name = obj.find('name').text
18        bbox = obj.find('bndbox')
19        xmin = int(bbox.find('xmin').text)
20        ymin = int(bbox.find('ymin').text)
21        xmax = int(bbox.find('xmax').text)
22        ymax = int(bbox.find('ymax').text)
23        boxes.append([class_name, xmin, ymin, xmax, ymax])
24    
25    return image, boxes
26
27def show_image_with_boxes(image, boxes):
28    img = np.array(image)
29    for box in boxes:
30        class_name, xmin, ymin, xmax, ymax = box
31        cv2.rectangle(img, (xmin, ymin), (xmax, ymax), (0, 255, 0), 2)
32        label = f'{class_name}'
33        cv2.putText(img, label, (xmin, ymin - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
34    
35    cv2.imshow('Image with Boxes', img)
36    cv2.waitKey(0)
37    cv2.destroyAllWindows()
38
39def main():
40    images_dir = 'path/to/images'
41    annotations_dir = 'path/to/annotations'
42    
43    # 获取图像列表
44    image_files = [f for f in os.listdir(images_dir) if f.endswith('.jpg')]
45    
46    # 随机选择一张图像
47    selected_image = np.random.choice(image_files)
48    image_path = os.path.join(images_dir, selected_image)
49    annotation_path = os.path.join(annotations_dir, selected_image.replace('.jpg', '.xml'))
50    
51    # 加载图像和边界框
52    image, boxes = load_image_and_boxes(image_path, annotation_path)
53    
54    # 展示带有边界框的图像
55    show_image_with_boxes(image, boxes)
56
57if __name__ == "__main__":
58    main()
脚本5: 数据增强
复制代码
1# data_augmentation.py
2import os
3import cv2
4import numpy as np
5import albumentations as A
6from PIL import Image
7import xml.etree.ElementTree as ET
8
9def load_image_and_boxes(image_path, annotation_path):
10    # 读取图像
11    image = Image.open(image_path).convert('RGB')
12    image = np.array(image)
13    
14    # 解析Pascal VOC格式的XML标注文件
15    tree = ET.parse(annotation_path)
16    root = tree.getroot()
17    boxes = []
18    for obj in root.findall('object'):
19        class_name = obj.find('name').text
20        bbox = obj.find('bndbox')
21        xmin = int(bbox.find('xmin').text)
22        ymin = int(bbox.find('ymin').text)
23        xmax = int(bbox.find('xmax').text)
24        ymax = int(bbox.find('ymax').text)
25        boxes.append([xmin, ymin, xmax, ymax, class_name])
26    
27    return image, boxes
28
29def save_augmented_data(augmented_image, augmented_boxes, output_image_path, output_annotation_path):
30    # 保存增强后的图像
31    augmented_image = Image.fromarray(augmented_image)
32    augmented_image.save(output_image_path)
33    
34    # 保存增强后的标注
35    tree = ET.parse(output_annotation_path)
36    root = tree.getroot()
37    for obj, new_box in zip(root.findall('object'), augmented_boxes):
38        bbox = obj.find('bndbox')
39        bbox.find('xmin').text = str(new_box[0])
40        bbox.find('ymin').text = str(new_box[1])
41        bbox.find('xmax').text = str(new_box[2])
42        bbox.find('ymax').text = str(new_box[3])
43    
44    tree.write(output_annotation_path)
45
46def augment_data(image, boxes):
47    transform = A.Compose([
48        A.RandomRotate90(p=0.5),
49        A.HorizontalFlip(p=0.5),
50        A.VerticalFlip(p=0.5),
51        A.RandomBrightnessContrast(p=0.2),
52        A.HueSaturationValue(p=0.2)
53    ], bbox_params=A.BboxParams(format='pascal_voc', label_fields=['category_ids']))
54
55    category_ids = [box[-1] for box in boxes]
56    bboxes = [box[:-1] for box in boxes]
57    
58    transformed = transform(image=image, bboxes=bboxes, category_ids=category_ids)
59    transformed_image = transformed['image']
60    transformed_bboxes = transformed['bboxes']
61    
62    return transformed_image, transformed_bboxes
63
64def main():
65    images_dir = 'path/to/images'
66    annotations_dir = 'path/to/annotations'
67    output_images_dir = 'path/to/augmented_images'
68    output_annotations_dir = 'path/to/augmented_annotations'
69    
70    if not os.path.exists(output_images_dir):
71        os.makedirs(output_images_dir)
72    
73    if not os.path.exists(output_annotations_dir):
74        os.makedirs(output_annotations_dir)
75    
76    # 获取图像列表
77    image_files = [f for f in os.listdir(images_dir) if f.endswith('.jpg')]
78    
79    for image_file in image_files:
80        image_path = os.path.join(images_dir, image_file)
81        annotation_path = os.path.join(annotations_dir, image_file.replace('.jpg', '.xml'))
82        
83        # 加载图像和边界框
84        image, boxes = load_image_and_boxes(image_path, annotation_path)
85        
86        # 增强数据
87        augmented_image, augmented_boxes = augment_data(image, boxes)
88        
89        # 保存增强后的数据
90        output_image_path = os.path.join(output_images_dir, image_file)
91        output_annotation_path = os.path.join(output_annotations_dir, image_file.replace('.jpg', '.xml'))
92        save_augmented_data(augmented_image, augmented_boxes, output_image_path, output_annotation_path)
93
94if __name__ == "__main__":
95    main()

改进方向

如果您已经使用YOLOv3、YOLOv5或其他模型对该数据集进行了训练,并且认为还有改进空间,以下是一些可能的改进方向:

  1. 数据增强:

    • 进一步增加数据增强策略,例如旋转、翻转、缩放、颜色抖动等,以提高模型的泛化能力。
    • 使用混合增强技术,如MixUp、CutMix等,以增加数据多样性。
  2. 模型优化:

    • 调整模型超参数,例如学习率、批量大小、优化器等,以找到最佳配置。
    • 尝试使用不同的骨干网络(Backbone),例如EfficientNet、ResNet等,以提高特征提取能力。
    • 引入注意力机制,如SENet、CBAM等,以增强模型对关键区域的关注。
  3. 损失函数:

    • 尝试使用不同的损失函数,例如Focal Loss、IoU Loss等,以改善模型的收敛性能。
    • 结合多种损失函数,例如分类损失和回归损失的组合,以平衡不同类型的任务。
  4. 后处理:

    • 使用非极大值抑制(NMS)的改进版本,如Soft-NMS、DIoU-NMS等,以提高检测结果的质量。
    • 引入边界框回归的改进方法,如GIoU、CIoU等,以提高定位精度。
  5. 迁移学习:

    • 使用预训练模型进行微调,利用大规模数据集(如COCO、ImageNet)上的预训练权重,加快收敛速度并提高性能。
  6. 集成学习:

    • 使用多个模型进行集成学习,通过投票或加权平均的方式提高最终的检测效果。
相关推荐
城南皮卡丘20 天前
苹果果实成熟度检测数据集 4195张+YOLO格式
深度学习·yolo·目标检测·计算机视觉·数据集
微尘hjx20 天前
【数据集 11】面向城市道路的坑洞检测数据集(含8760张,已按比例划分训练、验证、测试集,支持YOLO全系列训练)
人工智能·yolo·目标检测·数据集·道路坑洞·路坑数据集·路坑
数聚天成DeepSData23 天前
两份名录里的同名机构,主键该怎么合并
人工智能·深度学习·机器学习·数据集·deepsdata
Felaim1 个月前
【SLAM】SLAM数据集相机规格说明
数据集·vslam·slam·相机标定
数聚天成DeepSData1 个月前
第三方地图工具导出的 Landsat 影像,使用条件和 USGS 官方下载的一样吗
人工智能·深度学习·机器学习·数据集·deepsdata
数聚天成DeepSData1 个月前
验收一批标注数据时,一致性到底在比谁和谁
人工智能·深度学习·机器学习·数据集·deepsdata
数聚天成DeepSData1 个月前
两批标注数据合并前要核对什么
人工智能·深度学习·机器学习·数据集·deepsdata
数聚天成DeepSData1 个月前
外部标注需求里该写清哪几项,样例包才验收得动
人工智能·深度学习·机器学习·数据集·deepsdata
数聚天成DeepSData1 个月前
Landsat 影像去哪里下载:选景、批量与脚本检索怎么选
人工智能·深度学习·机器学习·数据集·deepsdata
数聚天成DeepSData1 个月前
夜间灯光可以代表经济活动吗?先处理年际一致性
人工智能·深度学习·机器学习·数据集·deepsdata