变电站缺陷数据集8307张,带xml标注和txt标注,可以直接用于yolo训练

变电站缺陷数据集8307张,
带xml标注和txt标注,可以直接用于yolo训练,赠附五个脚本

变电站缺陷数据集

数据集概述

变电站缺陷数据集是一个专门针对变电站设备和环境缺陷检测的图像数据集。该数据集包含了8307张经过标注的图像,旨在通过机器学习和计算机视觉技术来识别和分类变电站中的各种缺陷,如设备损坏、异常行为等。数据集同时提供了XML和TXT两种标注格式,可以直接用于YOLO系列目标检测模型的训练。

数据集特点
  1. 全面性:数据集涵盖了变电站设备的各种缺陷类型,包括但不限于设备损坏、异常行为等。
  2. 详细标注:每张图像都带有详细的标注信息,包括对象的类别、边界框坐标等。
  3. 兼容性强:提供了XML和TXT两种标注格式,既适合传统的基于XML的标注方式,也方便YOLO模型的直接使用。
  4. 实用性:数据集可以直接应用于变电站的安全监控和设备维护,帮助及时发现并处理潜在的安全隐患。
数据集构成

  • 图像数量:8307张
  • 标注格式
    • XML格式:适用于多种基于XML的标注工具和模型训练。
    • TXT格式:适用于YOLO系列目标检测模型的训练。

数据集用途
  • 缺陷检测:用于训练和测试识别变电站中设备缺陷的算法。
  • 安全监控:在实际应用中,可以用于自动化监控变电站设备的状态,及时发现并处理安全隐患。
  • 故障预防:帮助电力部门提前预警,减少由于设备缺陷导致的事故风险。
  • 研究与开发:为研究人员提供一个基准数据集,用于比较不同算法的效果。
  • 教育与培训:作为教学资源,帮助学生理解计算机视觉和机器学习的基本概念。
数据集获取

变电站缺陷数据集可以从相关的科研机构、数据提供商或者通过开源社区获取。获取数据集时,请遵循数据集发布的许可协议,确保合法使用。

示例代码

下面是一个简单的示例代码,展示了如何使用Python加载和预览变电站缺陷数据集中的图像及其XML格式的标注信息。

1import os
2import random
3import xml.etree.ElementTree as ET
4import matplotlib.pyplot as plt
5from PIL import Image
6
7# 数据集目录路径
8data_dir = 'path/to/transformer_station_defect_dataset'
9image_dir = os.path.join(data_dir, 'images')
10annotation_dir = os.path.join(data_dir, 'annotations_xml')
11
12# 随机选择一张图像
13image_files = os.listdir(image_dir)
14image_file = random.choice(image_files)
15image_path = os.path.join(image_dir, image_file)
16
17# 加载图像
18image = Image.open(image_path)
19
20# 加载XML标注
21xml_file = os.path.splitext(image_file)[0] + '.xml'
22xml_path = os.path.join(annotation_dir, xml_file)
23tree = ET.parse(xml_path)
24root = tree.getroot()
25
26# 绘制边界框
27fig, ax = plt.subplots(1, figsize=(10, 10))
28ax.imshow(image)
29ax.axis('off')
30
31for obj in root.findall('object'):
32    bbox = obj.find('bndbox')
33    xmin = int(bbox.find('xmin').text)
34    ymin = int(bbox.find('ymin').text)
35    xmax = int(bbox.find('xmax').text)
36    ymax = int(bbox.find('ymax').text)
37    label = obj.find('name').text
38    
39    ax.add_patch(plt.Rectangle((xmin, ymin), xmax - xmin, ymax - ymin, edgecolor='r', facecolor='none'))
40    ax.text(xmin, ymin, label, color='r', fontsize=8)
41
42plt.show()
YOLO标注格式转换

如果您需要将XML格式的标注转换为YOLO所需的TXT格式,可以使用以下Python代码示例:

1import os
2import xml.etree.ElementTree as ET
3
4# 数据集目录路径
5data_dir = 'path/to/transformer_station_defect_dataset'
6annotation_dir_xml = os.path.join(data_dir, 'annotations_xml')
7annotation_dir_yolo = os.path.join(data_dir, 'annotations_yolo')
8
9if not os.path.exists(annotation_dir_yolo):
10    os.makedirs(annotation_dir_yolo)
11
12# 类别映射字典
13class_map = {
14    'defect_type_1': 0,  # 替换为实际的类别名和索引
15    'defect_type_2': 1,
16    # 添加更多的类别
17}
18
19for xml_file in os.listdir(annotation_dir_xml):
20    if not xml_file.endswith('.xml'):
21        continue
22    
23    tree = ET.parse(os.path.join(annotation_dir_xml, xml_file))
24    root = tree.getroot()
25    
26    image_width = int(root.find('size/width').text)
27    image_height = int(root.find('size/height').text)
28    
29    with open(os.path.join(annotation_dir_yolo, os.path.splitext(xml_file)[0] + '.txt'), 'w') as f:
30        for obj in root.findall('object'):
31            label = obj.find('name').text.lower().strip()
32            if label in class_map:
33                class_id = class_map[label]
34                
35                bbox = obj.find('bndbox')
36                xmin = int(bbox.find('xmin').text)
37                ymin = int(bbox.find('ymin').text)
38                xmax = int(bbox.find('xmax').text)
39                ymax = int(bbox.find('ymax').text)
40                
41                x_center = (xmin + xmax) / 2.0
42                y_center = (ymin + ymax) / 2.0
43                w = xmax - xmin
44                h = ymax - ymin
45                
46                x_center /= image_width
47                y_center /= image_height
48                w /= image_width
49                h /= image_height
50                
51                f.write(f"{class_id} {x_center:.6f} {y_center:.6f} {w:.6f} {h:.6f}\n")

总结

此变电站缺陷数据集是一个高质量的数据集,涵盖了变电站设备的多种缺陷类型。数据集的特点是全面性、详细标注和兼容性强,能够满足不同研究需求。通过使用该数据集,研究者可以在变电站安全监控和设备维护领域推动技术进步,提高工作效率和安全性。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值