宜宾建设教育培训中心网站,wordpress子主题缺点,专业手机网站公司吗,在英特尔上建设网站可选择的方案有变压器设备漏油数据集 油浸式变压器通常采用油浸自冷式、油浸风冷式和强迫油循环三种冷却方式。该数据集采集于油浸式变压器的设备漏油情况#xff0c;一般用于变电站的无人巡检#xff0c;代替传统的人工巡检#xff0c;与绝缘子的破损检测来源于同一课题。数据集一部分来自…变压器设备漏油数据集 油浸式变压器通常采用油浸自冷式、油浸风冷式和强迫油循环三种冷却方式。该数据集采集于油浸式变压器的设备漏油情况一般用于变电站的无人巡检代替传统的人工巡检与绝缘子的破损检测来源于同一课题。数据集一部分来自真实场景由于真实场景下样本较少外加一部分合成图片共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 datadata_yaml,
16 cfgmodel_yaml,
17 weightsweights,
18 epochsepochs,
19 batch_sizebatch_size,
20 imgszimg_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 datadata_yaml,
13 weightsweights,
14 imgszimg_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(p0.5),
49 A.HorizontalFlip(p0.5),
50 A.VerticalFlip(p0.5),
51 A.RandomBrightnessContrast(p0.2),
52 A.HueSaturationValue(p0.2)
53 ], bbox_paramsA.BboxParams(formatpascal_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(imageimage, bboxesbboxes, category_idscategory_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或其他模型对该数据集进行了训练并且认为还有改进空间以下是一些可能的改进方向 数据增强 进一步增加数据增强策略例如旋转、翻转、缩放、颜色抖动等以提高模型的泛化能力。使用混合增强技术如MixUp、CutMix等以增加数据多样性。 模型优化 调整模型超参数例如学习率、批量大小、优化器等以找到最佳配置。尝试使用不同的骨干网络Backbone例如EfficientNet、ResNet等以提高特征提取能力。引入注意力机制如SENet、CBAM等以增强模型对关键区域的关注。 损失函数 尝试使用不同的损失函数例如Focal Loss、IoU Loss等以改善模型的收敛性能。结合多种损失函数例如分类损失和回归损失的组合以平衡不同类型的任务。 后处理 使用非极大值抑制NMS的改进版本如Soft-NMS、DIoU-NMS等以提高检测结果的质量。引入边界框回归的改进方法如GIoU、CIoU等以提高定位精度。 迁移学习 使用预训练模型进行微调利用大规模数据集如COCO、ImageNet上的预训练权重加快收敛速度并提高性能。 集成学习 使用多个模型进行集成学习通过投票或加权平均的方式提高最终的检测效果。