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

基于深度学习YOLOv11的铁轨轨道缺陷检测系统(YOLOv11+YOLO数据集+UI界面+登录注册界面+Python项目源码+模型)

一、项目介绍

本项目旨在构建一套基于深度学习的铁轨轨道缺陷自动检测系统,利用YOLOv11目标检测算法对铁路轨道表面的缺陷进行实时识别与定位。数据集涵盖四类常见缺陷类型,分别为剥落(Spalling)烧伤(Wheel Burn)挤压变形(Squat)波浪磨耗(Corrugation),共计训练集1916张、验证集240张、测试集240张。系统在数据预处理阶段采用图像增强与归一化方法,以提升模型的泛化能力。在模型训练过程中,结合YOLOv11的高效特征提取与多尺度预测机制,实现对不同尺寸缺陷的精确检测。为了便于实际应用,系统集成了可视化UI界面、用户登录注册功能及模型在线推理功能,支持现场快速部署与操作。实验结果表明,该系统在多类轨道缺陷检测任务中表现出较高的准确率与实时性,能够为铁路运维部门提供可靠的检测工具,从而降低人工巡检成本并提升轨道安全管理水平。


引言
铁路作为重要的交通运输方式,其安全性直接关系到社会运行效率与人员财产安全。轨道作为列车运行的基础设施,在长期高强度运营中极易受到轮轨作用力、气候变化及材料疲劳等因素的影响,从而产生多种类型的表面缺陷,如剥落、烧伤、挤压变形与波浪磨耗等。若这些缺陷未能及时发现与处理,将可能引发列车运行振动加剧、结构疲劳加速甚至脱轨等严重安全事故。因此,建立高效、准确的轨道缺陷检测系统,对于保障铁路运输安全具有重要意义。

传统轨道检测依赖人工巡检与专用检测车,存在检测周期长、劳动强度大、主观性强等问题,且难以在复杂运营环境中保持高精度与实时性。近年来,深度学习特别是目标检测技术的快速发展,为铁路轨道缺陷自动化检测提供了新的解决方案。YOLO系列算法因其端到端、高速与高精度的特点,已被广泛应用于工业质检与安全监测领域。

本研究基于YOLOv11构建铁路轨道缺陷检测模型,充分利用其深层特征提取能力与多尺度检测机制,实现对四类轨道缺陷的快速识别与定位。同时,结合可视化UI界面与用户管理功能,打造可直接部署于铁路运维现场的一体化检测平台,为铁路行业智能化运维提供技术支撑。

目录

一、项目介绍

二、项目功能展示

2.1 用户登录系统

2.2 检测功能

2.3 检测结果显示

2.4 参数配置

2.5 其他功能

3. 技术特点

4. 系统流程

三、数据集介绍

1. 数据来源与采集

2. 数据标注

3. 数据集划分

数据集配置文件

四、项目环境配置

创建虚拟环境

安装所需要库

五、模型训练

训练代码

训练结果

六、核心代码

🔐登录注册验证

🎯 多重检测模式

🖼️ 沉浸式可视化

⚙️ 参数配置系统

✨ UI美学设计

🔄 智能工作流

七、项目源码(视频简介)


基于深度学习YOLOv11的铁轨轨道缺陷检测系统(YOLOv11+YOLO数据集+UI界面+登录注册界面+Python项目源码+模型)_哔哩哔哩_bilibili

基于深度学习YOLOv11的铁轨轨道缺陷检测系统(YOLOv11+YOLO数据集+UI界面+登录注册界面+Python项目源码+模型)

二、项目功能展示

✅ 用户登录注册:支持密码检测和安全性验证。

✅ 三种检测模式:基于YOLOv11模型,支持图片、视频和实时摄像头三种检测,精准识别目标。

✅ 双画面对比:同屏显示原始画面与检测结果。

✅ 数据可视化:实时表格展示检测目标的类别、置信度及坐标。

✅智能参数调节:提供置信度滑块,动态优化检测精度,适应不同场景需求。

✅科幻风交互界面:深色主题搭配动态光效,减少视觉疲劳,提升操作体验。

✅多线程高性能架构:独立检测线程保障流畅运行,实时状态提示,响应迅速无卡顿。

2.1 用户登录系统

  • 提供用户登录和注册功能

  • 用户名和密码验证

  • 账户信息本地存储(accounts.json)

  • 密码长度至少6位的安全要求

2.2 检测功能

  • 图片检测:支持JPG/JPEG/PNG/BMP格式图片的火焰烟雾检测

  • 视频检测:支持MP4/AVI/MOV格式视频的逐帧检测

  • 摄像头检测:实时摄像头流检测(默认摄像头0)

  • 检测结果保存到"results"目录

2.3 检测结果显示

  • 显示原始图像和检测结果图像

  • 检测结果表格展示,包含:

    • 检测到的类别

    • 置信度分数

    • 物体位置坐标(x,y)、

2.4 参数配置

  • 模型选择

  • 置信度阈值调节(0-1.0)

  • IoU(交并比)阈值调节(0-1.0)

  • 实时同步滑块和数值输入框

2.5 其他功能

  • 检测结果保存功能

  • 视频检测时自动保存结果视频

  • 状态栏显示系统状态和最后更新时间

  • 无边框窗口设计,可拖动和调整大小

3. 技术特点

  • 采用多线程处理检测任务,避免界面卡顿

  • 精美的UI设计,具有科技感的视觉效果:

    • 发光边框和按钮

    • 悬停和按下状态效果

    • 自定义滑块、表格和下拉框样式

  • 检测结果保存机制

  • 响应式布局,适应不同窗口大小

4. 系统流程

  1. 用户登录/注册

  2. 选择检测模式(图片/视频/摄像头)

  3. 调整检测参数(可选)

  4. 开始检测并查看结果

  5. 可选择保存检测结果

  6. 停止检测或切换其他模式

三、数据集介绍

本研究所使用的数据集专门针对铁路轨道表面缺陷检测任务构建,涵盖了铁路运行过程中最常见的四类轨道表面缺陷:

  1. Spalling(剥落):由于轮轨接触应力集中导致轨面材料脱落形成坑洼区域。

  2. Wheel Burn(烧伤):车轮打滑或紧急制动造成轨面局部温度急剧升高,形成表面烧蚀痕迹。

  3. Squat(挤压变形):由轮轨动载冲击导致轨面局部塑性变形并伴随裂纹发展。

  4. Corrugation(波浪磨耗):列车周期性动力作用引起轨面波状磨耗,通常呈现周期性波峰波谷。

1. 数据来源与采集

数据集来源于多种铁路轨道运行场景,包括普通客运铁路、货运铁路及部分高速铁路试验段。采集设备采用高分辨率工业相机,安装在轨检车和巡检机器人上,结合自然光与补光灯照明,确保图像在不同光照条件下均能清晰呈现缺陷特征。采集分辨率为1920×1080,保证了轨面细节的保真度。

2. 数据标注

所有轨道缺陷样本均由轨道检测专家团队进行手工标注,标注工具为LabelImg,采用YOLO格式(TXT文件记录类别及边界框坐标)。标注遵循以下原则:

  • 仅标注轨道表面出现的目标缺陷,不标注非缺陷性污渍或阴影。

  • 缺陷边界框尽量贴合实际缺陷边缘,确保定位精度。

  • 对于同一轨道区域出现的多个缺陷,分别标注为独立目标。

3. 数据集划分

为保证模型训练与评估的科学性,数据集按照8:1:1的比例划分为训练集、验证集与测试集:

数据集类型样本数量占比说明
训练集(Train)191680%用于模型参数优化
验证集(Val)24010%用于调参与模型选择
测试集(Test)24010%用于最终性能评估

数据集配置文件

数据集采用标准化YOLO格式组织:

# └── coco ← downloads here (20.1 GB) # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..] train: F:\铁轨轨道缺陷检测数据集\train\ val: F:\铁轨轨道缺陷检测数据集\val\ test: F:\铁轨轨道缺陷检测数据集\test\ nc: 4 # 20288 of 40670 images, submit to https://competitions.codalab.org/competitions/20794 # Classes names: ["Spalling", "Wheel Burn", "Squat" , "Corrugation"]

四、项目环境配置

创建虚拟环境

首先新建一个Anaconda环境,每个项目用不同的环境,这样项目中所用的依赖包互不干扰。

终端输入

conda create -n yolov11 python==3.9

激活虚拟环境

conda activate yolov11

安装cpu版本pytorch

pip install torch torchvision torchaudio

安装所需要库

pip install -r requirements.txt

pycharm中配置anaconda

五、模型训练

训练代码

from ultralytics import YOLO model_path = 'yolo11s.pt' data_path = 'data.yaml' if __name__ == '__main__': model = YOLO(model_path) results = model.train(data=data_path, epochs=100, batch=8, device='0', workers=0, project='runs', name='exp', )
根据实际情况更换模型 # yolov11n.yaml (nano):轻量化模型,适合嵌入式设备,速度快但精度略低。 # yolov11s.yaml (small):小模型,适合实时任务。 # yolov11m.yaml (medium):中等大小模型,兼顾速度和精度。 # yolov11b.yaml (base):基本版模型,适合大部分应用场景。 # yolov11l.yaml (large):大型模型,适合对精度要求高的任务。
  • --batch 8:每批次8张图像。
  • --epochs 100:训练100轮。
  • --datasets/data.yaml:数据集配置文件。
  • --weights yolov11s.pt:初始化模型权重,yolov11s.pt是预训练的轻量级YOLO模型。

训练结果

六、核心代码

import sys import cv2 import numpy as np from PyQt5.QtWidgets import QApplication, QMessageBox, QFileDialog from PyQt5.QtCore import QThread, pyqtSignal from ultralytics import YOLO from UiMain import UiMainWindow import time import os from PyQt5.QtWidgets import QDialog from LoginWindow import LoginWindow class DetectionThread(QThread): frame_received = pyqtSignal(np.ndarray, np.ndarray, list) # 原始帧, 检测帧, 检测结果 finished_signal = pyqtSignal() # 线程完成信号 def __init__(self, model, source, conf, iou, parent=None): super().__init__(parent) self.model = model self.source = source self.conf = conf self.iou = iou self.running = True def run(self): try: if isinstance(self.source, int) or self.source.endswith(('.mp4', '.avi', '.mov')): # 视频或摄像头 cap = cv2.VideoCapture(self.source) while self.running and cap.isOpened(): ret, frame = cap.read() if not ret: break # 保存原始帧 original_frame = frame.copy() # 检测 results = self.model(frame, conf=self.conf, iou=self.iou) annotated_frame = results[0].plot() # 提取检测结果 detections = [] for result in results: for box in result.boxes: class_id = int(box.cls) class_name = self.model.names[class_id] confidence = float(box.conf) x, y, w, h = box.xywh[0].tolist() detections.append((class_name, confidence, x, y)) # 发送信号 self.frame_received.emit( cv2.cvtColor(original_frame, cv2.COLOR_BGR2RGB), cv2.cvtColor(annotated_frame, cv2.COLOR_BGR2RGB), detections ) # 控制帧率 time.sleep(0.03) # 约30fps cap.release() else: # 图片 frame = cv2.imread(self.source) if frame is not None: original_frame = frame.copy() results = self.model(frame, conf=self.conf, iou=self.iou) annotated_frame = results[0].plot() # 提取检测结果 detections = [] for result in results: for box in result.boxes: class_id = int(box.cls) class_name = self.model.names[class_id] confidence = float(box.conf) x, y, w, h = box.xywh[0].tolist() detections.append((class_name, confidence, x, y)) self.frame_received.emit( cv2.cvtColor(original_frame, cv2.COLOR_BGR2RGB), cv2.cvtColor(annotated_frame, cv2.COLOR_BGR2RGB), detections ) except Exception as e: print(f"Detection error: {e}") finally: self.finished_signal.emit() def stop(self): self.running = False class MainWindow(UiMainWindow): def __init__(self): super().__init__() # 初始化模型 self.model = None self.detection_thread = None self.current_image = None self.current_result = None self.video_writer = None self.is_camera_running = False self.is_video_running = False self.last_detection_result = None # 新增:保存最后一次检测结果 # 连接按钮信号 self.image_btn.clicked.connect(self.detect_image) self.video_btn.clicked.connect(self.detect_video) self.camera_btn.clicked.connect(self.detect_camera) self.stop_btn.clicked.connect(self.stop_detection) self.save_btn.clicked.connect(self.save_result) # 初始化模型 self.load_model() def load_model(self): try: model_name = self.model_combo.currentText() self.model = YOLO(f"{model_name}.pt") # 自动下载或加载本地模型 self.update_status(f"模型 {model_name} 加载成功") except Exception as e: QMessageBox.critical(self, "错误", f"模型加载失败: {str(e)}") self.update_status("模型加载失败") def detect_image(self): if self.detection_thread and self.detection_thread.isRunning(): QMessageBox.warning(self, "警告", "请先停止当前检测任务") return file_path, _ = QFileDialog.getOpenFileName( self, "选择图片", "", "图片文件 (*.jpg *.jpeg *.png *.bmp)") if file_path: self.clear_results() self.current_image = cv2.imread(file_path) self.current_image = cv2.cvtColor(self.current_image, cv2.COLOR_BGR2RGB) self.display_image(self.original_image_label, self.current_image) # 创建检测线程 conf = self.confidence_spinbox.value() iou = self.iou_spinbox.value() self.detection_thread = DetectionThread(self.model, file_path, conf, iou) self.detection_thread.frame_received.connect(self.on_frame_received) self.detection_thread.finished_signal.connect(self.on_detection_finished) self.detection_thread.start() self.update_status(f"正在检测图片: {os.path.basename(file_path)}") def detect_video(self): if self.detection_thread and self.detection_thread.isRunning(): QMessageBox.warning(self, "警告", "请先停止当前检测任务") return file_path, _ = QFileDialog.getOpenFileName( self, "选择视频", "", "视频文件 (*.mp4 *.avi *.mov)") if file_path: self.clear_results() self.is_video_running = True # 初始化视频写入器 cap = cv2.VideoCapture(file_path) frame_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) frame_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) fps = cap.get(cv2.CAP_PROP_FPS) cap.release() # 创建保存路径 save_dir = "results" os.makedirs(save_dir, exist_ok=True) timestamp = time.strftime("%Y%m%d_%H%M%S") save_path = os.path.join(save_dir, f"result_{timestamp}.mp4") fourcc = cv2.VideoWriter_fourcc(*'mp4v') self.video_writer = cv2.VideoWriter(save_path, fourcc, fps, (frame_width, frame_height)) # 创建检测线程 conf = self.confidence_spinbox.value() iou = self.iou_spinbox.value() self.detection_thread = DetectionThread(self.model, file_path, conf, iou) self.detection_thread.frame_received.connect(self.on_frame_received) self.detection_thread.finished_signal.connect(self.on_detection_finished) self.detection_thread.start() self.update_status(f"正在检测视频: {os.path.basename(file_path)}") def detect_camera(self): if self.detection_thread and self.detection_thread.isRunning(): QMessageBox.warning(self, "警告", "请先停止当前检测任务") return self.clear_results() self.is_camera_running = True # 创建检测线程 (默认使用摄像头0) conf = self.confidence_spinbox.value() iou = self.iou_spinbox.value() self.detection_thread = DetectionThread(self.model, 0, conf, iou) self.detection_thread.frame_received.connect(self.on_frame_received) self.detection_thread.finished_signal.connect(self.on_detection_finished) self.detection_thread.start() self.update_status("正在从摄像头检测...")

🔐登录注册验证

对应文件:LoginWindow.py

# 账户验证核心逻辑 def handle_login(self): username = self.username_input.text().strip() password = self.password_input.text().strip() if not username or not password: QMessageBox.warning(self, "警告", "用户名和密码不能为空!") return if username in self.accounts and self.accounts[username] == password: self.accept() # 验证通过 else: QMessageBox.warning(self, "错误", "用户名或密码错误!") # 密码强度检查(注册时) def handle_register(self): if len(password) < 6: # 密码长度≥6位 QMessageBox.warning(self, "警告", "密码长度至少为6位!")

🎯多重检测模式

对应文件:main.py

图片检测

def detect_image(self): file_path, _ = QFileDialog.getOpenFileName( self, "选择图片", "", "图片文件 (*.jpg *.jpeg *.png *.bmp)") if file_path: self.detection_thread = DetectionThread(self.model, file_path, conf, iou) self.detection_thread.start() # 启动检测线程

视频检测

def detect_video(self): file_path, _ = QFileDialog.getOpenFileName( self, "选择视频", "", "视频文件 (*.mp4 *.avi *.mov)") if file_path: self.video_writer = cv2.VideoWriter() # 初始化视频写入器 self.detection_thread = DetectionThread(self.model, file_path, conf, iou)

实时摄像头

def detect_camera(self): self.detection_thread = DetectionThread(self.model, 0, conf, iou) # 摄像头设备号0 self.detection_thread.start()

🖼️沉浸式可视化

对应文件:UiMain.py

双画面显示

def display_image(self, label, image): q_img = QImage(image.data, w, h, bytes_per_line, QImage.Format_RGB888) pixmap = QPixmap.fromImage(q_img) label.setPixmap(pixmap.scaled(label.size(), Qt.KeepAspectRatio)) # 自适应缩放

结果表格

def add_detection_result(self, class_name, confidence, x, y): self.results_table.insertRow(row) items = [ QTableWidgetItem(class_name), # 类别列 QTableWidgetItem(f"{confidence:.2f}"), # 置信度 QTableWidgetItem(f"{x:.1f}"), # X坐标 QTableWidgetItem(f"{y:.1f}") # Y坐标 ]

⚙️参数配置系统

对应文件:UiMain.py

双阈值联动控制

# 置信度阈值同步 def update_confidence(self, value): confidence = value / 100.0 self.confidence_spinbox.setValue(confidence) # 滑块→数值框 self.confidence_label.setText(f"置信度阈值: {confidence:.2f}") # IoU阈值同步 def update_iou(self, value): iou = value / 100.0 self.iou_spinbox.setValue(iou)

UI美学设计

对应文件:UiMain.py

科幻风格按钮

def create_button(self, text, color): return f""" QPushButton {{ border: 1px solid {color}; color: {color}; border-radius: 6px; }} QPushButton:hover {{ background-color: {self.lighten_color(color, 10)}; box-shadow: 0 0 10px {color}; # 悬停发光效果 }} """

动态状态栏

def update_status(self, message): self.status_bar.showMessage( f"状态: {message} | 最后更新: {time.strftime('%H:%M:%S')}" # 实时时间戳 )

🔄智能工作流

对应文件:main.py

线程管理

class DetectionThread(QThread): frame_received = pyqtSignal(np.ndarray, np.ndarray, list) # 信号量通信 def run(self): while self.running: # 多线程检测循环 results = self.model(frame, conf=self.conf, iou=self.iou) self.frame_received.emit(original_frame, result_frame, detections)

七、项目源码(视频简介)

基于深度学习YOLOv11的铁轨轨道缺陷检测系统(YOLOv11+YOLO数据集+UI界面+登录注册界面+Python项目源码+模型)_哔哩哔哩_bilibili

基于深度学习YOLOv11的铁轨轨道缺陷检测系统(YOLOv11+YOLO数据集+UI界面+登录注册界面+Python项目源码+模型)

http://www.jsqmd.com/news/375338/

相关文章:

  • 2026国自然申报倒计时:如何利用AI辅助工具高效完成申请书撰写
  • 普通Fetch和Fetch 流式的区别?
  • 前端组件上新:全球数字货币符号展示的“标准答案”
  • 集星獭 | 让集成“看得见、管得住”——四大监控能力实战指南
  • 基于深度学习YOLOv11的茶叶病害检测系统(YOLOv11+YOLO数据集+UI界面+登录注册界面+Python项目源码+模型)
  • 2026新春装修推荐上海二手房装修公司10家口碑企业深度解析报告 - 速递信息
  • 基于深度学习YOLOv11的钢材缺陷检测系统(YOLOv11+YOLO数据集+UI界面+登录注册界面+Python项目源码+模型)
  • 基于深度学习YOLOv12的茶叶病害检测系统(YOLOv12+YOLO数据集+UI界面+登录注册界面+Python项目源码+模型)
  • 2026新春上海装修新风向:效果还原实力派公司榜单权威发布新春特辑 - 速递信息
  • 2026年2月宁波装修设计公司推荐榜单 - 疯一样的风
  • 迎2026开年家装观察:效果图还原度成上海装企新名片实力代表 - 速递信息
  • 2026新春装修季上海二手房装修公司10家优质公司深度测评报告 - 速递信息
  • Why Does RL Generalize Better Than SFT A Data-Centric Perspective on VLM Post-Training
  • DailyCoding C++ CMake | CMake 踩坑记:解决 ROS 项目中的“循环引用”与库链接依赖问题
  • Nodejs+vue+ElementUI框架实验室设备租赁报修管理系统
  • Android多进程开发 - AIDL 最简单的实现、传递数据大小限制
  • 基于springboot和vue框架的民宿房间预订推荐系统的设计与实现
  • 基于springboot和vue框架的固定资产转移管理系统设计与实现
  • Android Jetpack Compose - PullToRefreshBox、RadioButton、DatePicker、DatePickerDialog、DateRangePicker
  • 输入洗车店小时流量,预测高峰,推荐用户错峰时间。
  • 基于springboot和vue框架的校园个人资料管理系统设计与实现
  • S-GRec Personalized Semantic-Aware Generative Recommendation with Asymmetric Advantage
  • 输入夜市各摊位人流数据,计算并推荐收益最高位置。
  • 2026最新十大知名欧松板品牌推荐榜!优质环保品质与高性价比源头厂家选择指南,适配环保家装与全屋定制多场景 - 品牌推荐2026
  • 基于深度学习YOLOv10的安全锥识别检测系统(YOLOv10+YOLO数据集+UI界面+Python项目源码+模型)
  • 基于springboot和vue框架的企业人事绩效考核综合管理系统
  • 极萌美容仪有效果吗?效果见证,美丽无需等待 - 速递信息
  • redis学习笔记(四)—— list数据类型
  • 基于springboot和vue框架的企业人才招聘系统
  • 行业内专业的2025板材十大品牌排名 - 品牌推荐(官方)