news 2026/1/14 8:03:10

基于YOLOv10的森林火灾烟雾红外检测系统(YOLOv10深度学习+YOLO数据集+UI界面+Python项目源码+模型)

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
基于YOLOv10的森林火灾烟雾红外检测系统(YOLOv10深度学习+YOLO数据集+UI界面+Python项目源码+模型)

一、项目介绍

摘要

本项目基于先进的YOLOv10目标检测算法,开发了一套高性能的森林火灾烟雾红外检测系统,专门用于从红外图像中识别和定位火灾(fire)和烟雾(smoke)两类关键目标。系统通过对红外热成像视频流的实时分析,能够在复杂自然环境条件下实现早期火灾预警,为森林防火工作提供智能化解决方案。项目构建了包含2000张标注红外图像的专业数据集,其中训练集1600张,验证集和测试集各200张。经实验验证,该系统在森林火灾检测任务中表现出优异的性能,具有检测速度快、准确率高、误报率低等特点,可有效提升森林火灾监测的效率和可靠性。

项目意义

森林火灾是全球性的重大自然灾害,及早发现火情对减少生态损失和经济损失至关重要。本项目的实施具有以下重要意义:

  1. 提升监测效率:传统人工巡查方式覆盖范围有限,本系统可实现24小时不间断、大范围自动监测,单台设备监控面积可提升数倍以上。

  2. 实现早期预警:红外成像可穿透普通烟雾,在可见光尚未形成明显火势前就能检测到温度异常,为灭火争取宝贵时间。

  3. 降低误报率:结合深度学习算法,系统能有效区分真实火情与类似干扰(如云层、雾霭、车辆热源等),误报率比传统红外阈值法低。

  4. 全天候工作能力:红外检测不受昼夜光照条件影响,可在夜间、雾天等可见光摄像机失效环境下正常工作。

  5. 生态保护价值:及早发现和控制森林火灾可减少碳排放和生态破坏,据估算每提前1小时预警可减少约100公顷森林损失。

  6. 经济效益显著:相比直升机巡查等传统方式,自动化监测系统可降低监测成本,且一次投入长期受益。

目录

一、项目介绍

摘要

项目意义

二、项目功能展示

系统功能

图片检测

视频检测

摄像头实时检测

三、数据集介绍

数据集概述

数据集特点

数据集配置文件

数据集制作流程

四、项目环境配置

创建虚拟环境

pycharm中配置anaconda

安装所需要库

五、模型训练

训练代码

训练结果

六、核心代码

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


基于深度学习YOLOv10的森林火灾烟雾红外检测系统(YOLOv10+YOLO数据集+UI界面+Python项目源码+模型)_哔哩哔哩_bilibili

基于深度学习YOLOv10的森林火灾烟雾红外检测系统(YOLOv10+YOLO数据集+UI界面+Python项目源码+模型)

二、项目功能展示

系统功能

图片检测:可对图片进行检测,返回检测框及类别信息。

视频检测:支持视频文件输入,检测视频中每一帧的情况。

摄像头实时检测:连接USB 摄像头,实现实时监测。

参数实时调节(置信度和IoU阈值)

  • 图片检测

该功能允许用户通过单张图片进行目标检测。输入一张图片后,YOLO模型会实时分析图像,识别出其中的目标,并在图像中框出检测到的目标,输出带有目标框的图像。

  • 视频检测

视频检测功能允许用户将视频文件作为输入。YOLO模型将逐帧分析视频,并在每一帧中标记出检测到的目标。最终结果可以是带有目标框的视频文件或实时展示,适用于视频监控和分析等场景。

  • 摄像头实时检测

该功能支持通过连接摄像头进行实时目标检测。YOLO模型能够在摄像头拍摄的实时视频流中进行目标检测,实时识别并显示检测结果。此功能非常适用于安防监控、无人驾驶、智能交通等应用,提供即时反馈。

核心特点:

  • 高精度:基于YOLO模型,提供精确的目标检测能力,适用于不同类型的图像和视频。
  • 实时性:特别优化的算法使得实时目标检测成为可能,无论是在视频还是摄像头实时检测中,响应速度都非常快。
  • 批量处理:支持高效的批量图像和视频处理,适合大规模数据分析。

三、数据集介绍

数据集概述

本项目构建了森林火灾红外专项数据集,共包含2000张高质量标注红外图像,按照8:1:1的比例划分为训练集(1600张)、验证集(200张)和测试集(200张)。数据集涵盖两类关键目标:

  1. 火灾(fire):不同发展阶段(阴燃、明火、大火)的火场区域

  2. 烟雾(smoke):各类形态(薄雾、浓烟、上升烟柱等)的烟雾区域

数据集特点

  1. 多源数据融合:数据集整合了无人机航拍、固定监控设备、卫星遥感等多种来源的红外图像,确保数据多样性。

  2. 全时段覆盖:包含白天、夜晚、黄昏等不同时段的样本,验证模型的时间鲁棒性。

  3. 多气候条件:涵盖晴天、雨天、雾天、雪天等多种气象条件下的火灾样本。

  4. 多地形场景:包含山地、平原、林地、灌木丛等不同地形环境下的火灾特征。

  5. 多光谱数据:部分样本包含长波红外(LWIR)和中波红外(MWIR)双波段数据,提供更丰富的热特征信息。

  6. 精细标注:采用像素级标注边界,对部分重叠目标和半透明烟雾进行了精确区分标注。

  7. 干扰样本丰富:包含阳光反射、热源设备、动物热源等常见干扰样本,增强模型抗干扰能力。

数据集配置文件

数据集采用YOLO格式进行组织,配置文件内容如下:

# YOLOv10森林火灾红外检测数据集配置文件 path: ../datasets/forest_fire_IR train: images/train # 1600张 val: images/val # 200张 test: images/test # 200张 # 检测类别 nc: 2 names: ['fire', 'smoke'] # 训练参数 img_size: 640 # 输入图像尺寸 batch_size: 16 # 批次大小 workers: 8 # 数据加载线程数 fl_gamma: 1.5 # 聚焦损失参数(针对小目标优化) # 红外特定参数 temperature_range: [0, 150] # 温度值归一化范围(℃) normalize: True # 启用温度值归一化

数据集制作流程

  1. 原始数据采集

    • 使用专业红外热像仪采集原始数据

    • 在多个自然保护区建立固定监测点进行长期数据收集

    • 联合消防部门获取真实火灾现场的红外影像资料

    • 通过无人机搭载红外相机进行航拍数据补充

  2. 数据预处理

    • 温度值校准:根据环境温度校正原始红外数据

    • 动态范围调整:优化温度显示范围以突出火情特征

    • 时间同步:对齐多源数据的采集时间戳

    • 地理坐标标注:记录每张图像的GPS位置信息

  3. 数据增强策略

    • 空间增强:随机旋转、翻转、裁剪

    • 辐射增强:模拟不同大气透射率下的辐射衰减

    • 噪声注入:添加传感器噪声和大气扰动噪声

    • 多尺度训练:采用4种不同分辨率进行训练

四、项目环境配置

创建虚拟环境

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

终端输入

conda create -n yolov10 python==3.9

激活虚拟环境

conda activate yolov10

安装cpu版本pytorch

pip install torch torchvision torchaudio

pycharm中配置anaconda

安装所需要库

pip install -r requirements.txt

五、模型训练

训练代码

from ultralytics import YOLOv10 model_path = 'yolov10s.pt' data_path = 'datasets/data.yaml' if __name__ == '__main__': model = YOLOv10(model_path) results = model.train(data=data_path, epochs=500, batch=64, device='0', workers=0, project='runs/detect', name='exp', )
根据实际情况更换模型 yolov10n.yaml (nano):轻量化模型,适合嵌入式设备,速度快但精度略低。 yolov10s.yaml (small):小模型,适合实时任务。 yolov10m.yaml (medium):中等大小模型,兼顾速度和精度。 yolov10b.yaml (base):基本版模型,适合大部分应用场景。 yolov10l.yaml (large):大型模型,适合对精度要求高的任务。
  • --batch 64:每批次64张图像。
  • --epochs 500:训练500轮。
  • --datasets/data.yaml:数据集配置文件。
  • --weights yolov10s.pt:初始化模型权重,yolov10s.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 YOLOv10 from UiMain import UiMainWindow import time import os 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 = YOLOv10(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("正在从摄像头检测...") def stop_detection(self): if self.detection_thread and self.detection_thread.isRunning(): self.detection_thread.stop() self.detection_thread.quit() self.detection_thread.wait() if self.video_writer: self.video_writer.release() self.video_writer = None self.is_camera_running = False self.is_video_running = False self.update_status("检测已停止") def on_frame_received(self, original_frame, result_frame, detections): # 更新原始图像和结果图像 self.display_image(self.original_image_label, original_frame) self.display_image(self.result_image_label, result_frame) # 保存当前结果帧用于后续保存 self.last_detection_result = result_frame # 新增:保存检测结果 # 更新表格 self.clear_results() for class_name, confidence, x, y in detections: self.add_detection_result(class_name, confidence, x, y) # 保存视频帧 if self.video_writer: self.video_writer.write(cv2.cvtColor(result_frame, cv2.COLOR_RGB2BGR)) def on_detection_finished(self): if self.video_writer: self.video_writer.release() self.video_writer = None self.update_status("视频检测完成,结果已保存") elif self.is_camera_running: self.update_status("摄像头检测已停止") else: self.update_status("图片检测完成") def save_result(self): if not hasattr(self, 'last_detection_result') or self.last_detection_result is None: QMessageBox.warning(self, "警告", "没有可保存的检测结果") return save_dir = "results" os.makedirs(save_dir, exist_ok=True) timestamp = time.strftime("%Y%m%d_%H%M%S") if self.is_camera_running or self.is_video_running: # 保存当前帧为图片 save_path = os.path.join(save_dir, f"snapshot_{timestamp}.jpg") cv2.imwrite(save_path, cv2.cvtColor(self.last_detection_result, cv2.COLOR_RGB2BGR)) self.update_status(f"截图已保存: {save_path}") else: # 保存图片检测结果 save_path = os.path.join(save_dir, f"result_{timestamp}.jpg") cv2.imwrite(save_path, cv2.cvtColor(self.last_detection_result, cv2.COLOR_RGB2BGR)) self.update_status(f"检测结果已保存: {save_path}") def closeEvent(self, event): self.stop_detection() event.accept() if __name__ == "__main__": app = QApplication(sys.argv) # 设置应用程序样式 app.setStyle("Fusion") # 创建并显示主窗口 window = MainWindow() window.show() sys.exit(app.exec_())

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

完整全部资源文件(包括测试图片、视频,py文件,训练数据集、训练代码、界面代码等),这里已打包上传至博主的面包多平台,见可参考博客与视频,已将所有涉及的文件同时打包到里面,点击即可运行,完整文件截图如下:

基于深度学习YOLOv10的森林火灾烟雾红外检测系统(YOLOv10+YOLO数据集+UI界面+Python项目源码+模型)_哔哩哔哩_bilibili

基于深度学习YOLOv10的森林火灾烟雾红外检测系统(YOLOv10+YOLO数据集+UI界面+Python项目源码+模型)

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/1/13 17:00:40

零基础掌握NBT编辑器:图形化Minecraft数据编辑全攻略

零基础掌握NBT编辑器:图形化Minecraft数据编辑全攻略 【免费下载链接】NBTExplorer A graphical NBT editor for all Minecraft NBT data sources 项目地址: https://gitcode.com/gh_mirrors/nb/NBTExplorer 还在为复杂的Minecraft数据编辑而头疼吗&#xff…

作者头像 李华
网站建设 2026/1/13 17:32:24

ComfyUI Manager完整使用指南:从安装到精通的核心技巧

ComfyUI Manager是ComfyUI生态系统中不可或缺的核心管理工具,为AI绘画用户提供了强大的插件管理、模型安装和环境配置功能。无论您是初次接触AI绘画的新手,还是希望提升工作效率的资深用户,本指南都将帮助您全面掌握这一高效工具的使用方法。…

作者头像 李华
网站建设 2026/1/13 19:09:03

LUT调色包下载网站运营启示:类比语音模型分发渠道建设

LUT调色包下载网站运营启示:类比语音模型分发渠道建设 在短视频、虚拟主播和有声内容爆发式增长的今天,创作者对“声音”的需求早已不再局限于“能说话”。他们需要的是风格统一、情感丰富、节奏精准、发音准确的声音表达——而这一切,正在被…

作者头像 李华
网站建设 2026/1/5 10:35:42

FGO自动化脚本技术实现与部署指南

在移动游戏Fate/Grand Order的日常运营中,玩家经常面临重复性任务带来的时间消耗问题。FGO-Automata作为基于Python的自动化解决方案,通过图像识别和模拟操作技术,为玩家带来高效的辅助工具,实现从登录到战斗结算的全流程自动化操…

作者头像 李华
网站建设 2026/1/5 10:34:58

ComfyUI-Manager下载性能优化:从问题诊断到高效解决方案

ComfyUI-Manager下载性能优化:从问题诊断到高效解决方案 【免费下载链接】ComfyUI-Manager 项目地址: https://gitcode.com/gh_mirrors/co/ComfyUI-Manager 问题诊断:识别下载瓶颈的根源 在使用ComfyUI进行AI创作时,模型下载速度往往…

作者头像 李华