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

道路坑洞分割数据集/道路裂纹分割数据集

1.道路坑洞,道路裂纹分割数据集,包含5790张坑洞分割图像数据(默认分割标注png图片,850MB)2.10000余张道路裂纹图像数据(默认分割标注png图片,3.7GB)3。道路坑洞,道路

道路坑洞与裂纹检测及分割数据集

数据集描述

该数据集是一个专门用于道路维护和安全监控的数据集,旨在帮助研究人员和开发者训练和评估基于深度学习的道路坑洞和裂纹的检测及分割模型。数据集分为三个部分,涵盖了道路坑洞和裂纹的不同类型和场景,提供了高质量的图像和详细的标注信息。

数据1:道路坑洞分割数据集

数据规模
  • 总样本数量:5,790张坑洞分割图像
  • 数据量:约850MB
  • 标注格式:默认分割标注PNG图片
  • 目标类别
    • 道路坑洞
图像特性
  • 高分辨率影像:图像为高分辨率,确保细节清晰。
  • 像素级标注:每张图像都有对应的像素级分割掩码,适用于语义分割任务。
  • 多样化场景:覆盖了不同类型的道路和不同的光照条件下的坑洞情况。
  • 高质量标注:提供详细的像素级掩码,支持直接用于训练分割模型。
应用场景
  • 道路维护:通过自动检测和分割道路坑洞,辅助道路维护部门及时修复,提高道路安全性。
  • 智能交通系统:集成到智能交通系统中,实时监测道路状况,提供预警信息。
  • 科研分析:用于研究语义分割算法在道路维护中的应用,特别是在不同光照和背景条件下的鲁棒性。

数据2:道路裂纹分割数据集

数据规模
  • 总样本数量:10,000余张裂纹分割图像
  • 数据量:约3.7GB
  • 标注格式:默认分割标注PNG图片
  • 目标类别
    • 道路裂纹
图像特性

  • 高分辨率影像:图像为高分辨率,确保细节清晰。
  • 像素级标注:每张图像都有对应的像素级分割掩码,适用于语义分割任务。
  • 多样化场景:覆盖了不同类型的道路和不同的光照条件下的裂纹情况。
  • 高质量标注:提供详细的像素级掩码,支持直接用于训练分割模型。
应用场景
  • 道路维护:通过自动检测和分割道路裂纹,辅助道路维护部门及时修复,提高道路安全性。
  • 智能交通系统:集成到智能交通系统中,实时监测道路状况,提供预警信息。
  • 科研分析:用于研究语义分割算法在道路维护中的应用,特别是在不同光照和背景条件下的鲁棒性。

数据3:道路坑洞与裂纹检测数据集

数据规模
  • 总样本数量:38,000余张图像
  • 数据量:约13GB
  • 标注格式:默认VOC格式XML标注
  • 目标类别
    • 道路坑洞
    • 道路裂纹
图像特性
  • 高分辨率影像:图像为高分辨率,确保细节清晰。
  • 边界框标注:每张图像都有对应的边界框标注,适用于目标检测任务。
  • 多样化场景:覆盖了不同类型的道路和不同的光照条件下的坑洞和裂纹情况。
  • 高质量标注:提供详细的边界框和类别标签,支持PASCAL VOC格式。
应用场景
  • 道路维护:通过自动检测道路坑洞和裂纹,辅助道路维护部门及时修复,提高道路安全性。
  • 智能交通系统:集成到智能交通系统中,实时监测道路状况,提供预警信息。
  • 科研分析:用于研究目标检测算法在道路维护中的应用,特别是在不同光照和背景条件下的鲁棒性。

数据集结构

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

 

深色版本

1road_defects_dataset/
2├── road_potholes_segmentation/
3│   ├── images/
4│   │   ├── img_00001.jpg
5│   │   ├── img_00002.jpg
6│   │   └── ...
7│   ├── masks/
8│   │   ├── img_00001.png
9│   │   ├── img_00002.png
10│   │   └── ...
11├── road_cracks_segmentation/
12│   ├── images/
13│   │   ├── img_00001.jpg
14│   │   ├── img_00002.jpg
15│   │   └── ...
16│   ├── masks/
17│   │   ├── img_00001.png
18│   │   ├── img_00002.png
19│   │   └── ...
20└── road_defects_detection/
21    ├── images/
22    │   ├── img_00001.jpg
23    │   ├── img_00002.jpg
24    │   └── ...
25    ├── annotations/
26    │   ├── img_00001.xml
27    │   ├── img_00002.xml
28    │   └── ...
29    └── README.md  # 数据集说明文件

示例代码

以下是一个使用Python和相关库(如OpenCV、PIL等)来加载和展示数据集的简单示例代码:

 

python

深色版本

1import os
2import cv2
3import numpy as np
4from PIL import Image
5import xml.etree.ElementTree as ET
6
7# 数据集路径
8dataset_path = 'path/to/road_defects_dataset/'
9
10# 加载图像和分割掩码 (分割数据集)
11def load_image_and_mask(image_path, mask_path):
12    # 读取图像
13    image = Image.open(image_path).convert('RGB')
14    
15    # 读取分割掩码
16    mask = Image.open(mask_path).convert('L')  # 掩码通常是灰度图像
17    
18    return image, mask
19
20# 展示图像和分割掩码
21def show_image_with_mask(image, mask):
22    img = np.array(image)
23    mask_array = np.array(mask)
24    
25    # 将掩码转换为彩色图层
26    colored_mask = np.zeros_like(img)
27    colored_mask[mask_array > 0] = [0, 255, 0]
28    
29    # 叠加掩码到原图
30    img = cv2.addWeighted(img, 1, colored_mask, 0.5, 0)
31    
32    cv2.imshow('Image with Mask', img)
33    cv2.waitKey(0)
34    cv2.destroyAllWindows()
35
36# 加载图像和边界框标注 (检测数据集)
37def load_image_and_boxes(image_path, annotation_path):
38    # 读取图像
39    image = Image.open(image_path).convert('RGB')
40    
41    # 解析VOC标注文件
42    tree = ET.parse(annotation_path)
43    root = tree.getroot()
44    boxes = []
45    for obj in root.findall('object'):
46        class_name = obj.find('name').text
47        bbox = obj.find('bndbox')
48        xmin = int(bbox.find('xmin').text)
49        ymin = int(bbox.find('ymin').text)
50        xmax = int(bbox.find('xmax').text)
51        ymax = int(bbox.find('ymax').text)
52        boxes.append([class_name, xmin, ymin, xmax, ymax])
53    return image, boxes
54
55# 展示图像和边界框
56def show_image_with_boxes(image, boxes):
57    img = np.array(image)
58    for box in boxes:
59        class_name, xmin, ymin, xmax, ymax = box
60        cv2.rectangle(img, (xmin, ymin), (xmax, ymax), (0, 255, 0), 2)
61        label = f'{class_name}'
62        cv2.putText(img, label, (xmin, ymin - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
63    
64    cv2.imshow('Image with Boxes', img)
65    cv2.waitKey(0)
66    cv2.destroyAllWindows()
67
68# 主函数
69if __name__ == "__main__":
70    subset = 'road_potholes_segmentation'  # 可以选择 'road_cracks_segmentation' 或 'road_defects_detection'
71    
72    if subset in ['road_potholes_segmentation', 'road_cracks_segmentation']:
73        images_dir = os.path.join(dataset_path, subset, 'images')
74        masks_dir = os.path.join(dataset_path, subset, 'masks')
75        
76        # 获取图像列表
77        image_files = [f for f in os.listdir(images_dir) if f.endswith('.jpg')]
78        
79        # 随机选择一张图像
80        selected_image = np.random.choice(image_files)
81        image_path = os.path.join(images_dir, selected_image)
82        mask_path = os.path.join(masks_dir, selected_image.replace('.jpg', '.png'))
83        
84        # 加载图像和掩码
85        image, mask = load_image_and_mask(image_path, mask_path)
86        
87        # 展示带有掩码的图像
88        show_image_with_mask(image, mask)
89    elif subset == 'road_defects_detection':
90        images_dir = os.path.join(dataset_path, subset, 'images')
91        annotations_dir = os.path.join(dataset_path, subset, 'annotations')
92        
93        # 获取图像列表
94        image_files = [f for f in os.listdir(images_dir) if f.endswith('.jpg')]
95        
96        # 随机选择一张图像
97        selected_image = np.random.choice(image_files)
98        image_path = os.path.join(images_dir, selected_image)
99        annotation_path = os.path.join(annotations_dir, selected_image.replace('.jpg', '.xml'))
100        
101        # 加载图像和边界框
102        image, boxes = load_image_and_boxes(image_path, annotation_path)
103        
104        # 展示带有边界框的图像
105        show_image_with_boxes(image, boxes)
106    else:
107        raise ValueError("Invalid subset. Choose 'road_potholes_segmentation', 'road_cracks_segmentation', or 'road_defects_detection'.")

这段代码展示了如何加载图像和其对应的分割掩码或边界框标注文件,并在图像上绘制分割掩码或边界框。您可以根据实际需求进一步扩展和修改这段代码,以适应您的具体应用场景。

示例代码:使用预训练模型进行推理

以下是使用预训练模型进行推理的示例代码。这里我们假设您使用的是基于U-Net的模型进行分割任务,以及基于YOLOv5的模型进行检测任务。

分割任务 (U-Net)
 

python

深色版本

1import torch
2import torchvision
3import segmentation_models_pytorch as smp
4import cv2
5import numpy as np
6from PIL import Image
7
8# 数据集路径
9dataset_path = 'path/to/road_defects_dataset/'
10
11# 加载预训练模型
12model = smp.Unet(
13    encoder_name='resnet34',
14    encoder_weights='imagenet',
15    in_channels=3,
16    classes=2  # 背景 + 坑洞/裂纹
17)
18weights_path = 'path/to/pretrained/unet_weights.pth'  # 替换成实际的预训练模型路径
19model.load_state_dict(torch.load(weights_path))
20model.eval()
21
22# 主函数
23if __name__ == "__main__":
24    subset = 'road_potholes_segmentation'  # 可以选择 'road_cracks_segmentation'
25    images_dir = os.path.join(dataset_path, subset, 'images')
26    
27    # 获取图像列表
28    image_files = [f for f in os.listdir(images_dir) if f.endswith('.jpg')]
29    
30    # 随机选择一张图像
31    selected_image = np.random.choice(image_files)
32    image_path = os.path.join(images_dir, selected_image)
33    
34    # 读取并预处理图像
35    image = Image.open(image_path).convert('RGB')
36    transform = torchvision.transforms.Compose([
37        torchvision.transforms.Resize((512, 512)),
38        torchvision.transforms.ToTensor(),
39        torchvision.transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
40    ])
41    image_tensor = transform(image).unsqueeze(0)
42    
43    # 使用预训练模型进行推理
44    with torch.no_grad():
45        predictions = model(image_tensor)
46    
47    # 处理预测结果
48    pred_mask = predictions.squeeze().cpu().numpy()
49    pred_mask = (pred_mask > 0.5).astype(np.uint8)  # 二值化掩码
50    
51    # 在图像上绘制掩码
52    img = np.array(image)
53    colored_mask = np.zeros_like(img)
54    colored_mask[pred_mask == 1] = [0, 255, 0]
55    img = cv2.addWeighted(img, 1, colored_mask, 0.5, 0)
56    
57    # 显示结果
58    cv2.imshow('Image with Mask', img)
59    cv2.waitKey(0)
60    cv2.destroyAllWindows()
检测任务 (YOLOv5)
 

python

深色版本

1import torch
2import cv2
3import numpy as np
4from PIL import Image
5import yolov5  # 请确保已安装yolov5库
6
7# 数据集路径
8dataset_path = 'path/to/road_defects_dataset/'
9
10# 加载预训练模型
11model = yolov5.load('path/to/pretrained/yolov5_weights.pt')  # 替换成实际的预训练模型路径
12model.eval()
13
14# 主函数
15if __name__ == "__main__":
16    subset = 'road_defects_detection'
17    images_dir = os.path.join(dataset_path, subset, 'images')
18    
19    # 获取图像列表
20    image_files = [f for f in os.listdir(images_dir) if f.endswith('.jpg')]
21    
22    # 随机选择一张图像
23    selected_image = np.random.choice(image_files)
24    image_path = os.path.join(images_dir, selected_image)
25    
26    # 读取并预处理图像
27    image = Image.open(image_path).convert('RGB')
28    
29    # 使用预训练模型进行推理
30    results = model(image)
31    
32    # 处理预测结果
33    boxes = results.xyxy[0].cpu().numpy()
34    
35    # 在图像上绘制边界框
36    img = np.array(image)
37    for box in boxes:
38        xmin, ymin, xmax, ymax, conf, class_id = box
39        class_name = results.names[int(class_id)]
40        label = f'{class_name} {conf:.2f}'
41        cv2.rectangle(img, (int(xmin), int(ymin)), (int(xmax), int(ymax)), (0, 255, 0), 2)
42        cv2.putText(img, label, (int(xmin), int(ymin) - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
43    
44    # 显示结果
45    cv2.imshow('Image with Boxes', img)
46    cv2.waitKey(0)
47    cv2.destroyAllWindows()

这些代码展示了如何使用预训练的U-Net模型进行分割任务和预训练的YOLOv5模型进行检测任务,并显示和保存推理结果。您可以根据实际需求进一步扩展和修改这段代码,以适应您的具体应用场景。如果您需要使用其他模型进行更高级的功能,如模型微调或增量训练,可以参考相应模型的官方文档来进行相应的配置和操作。


http://www.mrgr.cn/news/31523.html

相关文章:

  • golang学习笔记31——golang 怎么实现枚举
  • AI学习指南深度学习篇-Adagrad超参数调优与性能优化
  • Java对象一口气讲完!φ(* ̄0 ̄)
  • 详细分析分布式事务场景、理论基础以及解决方法
  • 松材线虫目标检测数据集,12522张图-纯手工标注
  • python软体使用Matplotlib设计一个数据可视化工具
  • AI学习指南深度学习篇-Adagrad的Python实践
  • WEB 编程:富文本编辑器 Quill 配合 Pico.css 样式被影响的问题
  • C#开源的一个能利用Windows通知栏背单词的软件
  • 3、无线通信系统的组成
  • NISP 一级 | 8.2 打击网络违法犯罪相关法律法规
  • Vue.js 与 Flask/Django 后端配合:构建现代 Web 应用的最佳实践
  • Python 操作 Arduino 入门
  • 基于 C语言的 Modbus RTU CRC 校验程序
  • 在Python中优雅地打开和操作RDS
  • 达梦数据库的了解
  • 0基础学习HTML(八)头部
  • 中国IT产业新挑战与机遇共存
  • gcc配合cython编译python源代码
  • QTCreator 调试:unknown debugger type “No engine“