当前位置: 首页 > article >正文

变电站缺陷数据集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")

总结

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


http://www.kler.cn/news/310748.html

相关文章:

  • 基于深度学习的零售柜商品识别系统实战思路
  • 阅信云CTO向永清:35岁不应该成为技术职业发展的瓶颈|OceanBase 《DB大咖说》
  • Elasticsearch知识点整理
  • 【计算机毕业设计】医院电子病历
  • 线程池的执行流程
  • Java中的语法糖:让编程更简洁的特性
  • neo4j安装为服务+配置环境变量
  • linux之mysql安装
  • pip清华源地址
  • Vue 自定义指令实战
  • Vue 常见的几种通信方式(总结)
  • ShouldSniffAttr解说
  • Linux: debug:dump_stack 实例
  • 极狐GitLab 重要安全版本:17.3.3, 17.2.7, 17.1.8, 17.0.8, 16.11.10
  • C#使用HttpWebRequest下载文件
  • Java通信协议——UDP通信协议,模拟聊天室(完整详解,附有代码)
  • android含有EditText的键盘弹出后界面的正确处理
  • 人工智能 | 基于ChatGPT开发人工智能服务平台
  • 单片机嵌入式编程中常用技术点
  • Python基础 | 在虚拟环境中安装并在指定文件夹中打开Jupyter notebook
  • Java在零工市场中的应用:构建灵活高效的劳动力平台
  • 【算法】局部敏感哈希(LSH):高效解决相似性搜索问题的利器
  • html页面整合vue2或vue3
  • 选择适合你企业发展的服务器
  • 【Java】网络编程:TCP_IP协议详解(IP协议数据报文及如何解决IPv4不够的状况)
  • C++类和对象(4)
  • Linux平台UOS系统摄像头播放
  • 爬虫--翻页tips
  • .Net Gacutil工具(全局程序集缓存工具)使用教程
  • qt-creator-10.0.2之后版本的jom.exe构建和编译速度慢下来了