omerfarooq223/Agentic-Fire-Detection

GitHub: omerfarooq223/Agentic-Fire-Detection

基于YOLOv8的自主火灾烟雾检测系统,结合智能事件响应和RAG知识库提供完整的消防安全解决方案。

Stars: 0 | Forks: 0

# FireWatch AI: 自主火灾与烟雾事件管理系统 [![FastAPI](https://img.shields.io/badge/FastAPI-005571?style=for-the-badge&logo=fastapi)](https://fastapi.tiangolo.com/) [![React](https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB)](https://reactjs.org/) [![YOLOv8](https://img.shields.io/badge/YOLOv8-00A6ED?style=for-the-badge&logo=yolo)](https://ultralytics.com/) [![SQLite](https://img.shields.io/badge/SQLite-07405E?style=for-the-badge&logo=sqlite&logoColor=white)](https://www.sqlite.org/) FireWatch AI 是一个生产级、高保真的监控系统,专为自主火灾和烟雾检测而设计。它集成了最先进的计算机视觉(YOLOv8)与智能事件响应循环和高端网络HUD仪表板。 ![System Demo](https://raw.githubusercontent.com/omerfarooq223/Agentic-Fire-Detection/main/demo.gif) ## 🚀 系统功能 ### 1. 自主事件响应(零延迟) 系统配备了**智能决策引擎**,可实时监控风险等级。当检测置信度或面积阈值被突破(风险分数>50%)时,系统自动执行以下操作: - **发送邮件警报**:向设施管理人员发送包含检测元数据的通知。 - **启动紧急呼叫**:升级至911服务(模拟逻辑)。 - **激活抑制系统**:根据环境触发区域特定的洒水系统(水、二氧化碳或泡沫),例如服务器机房与仓库。 ### 2. 网络HUD视觉叠加层 一个复杂的基于画布的粒子引擎,将原始视频流转化为可操作的智能信息: - **热力图检测**:基于热强度的动态颜色缩放(蓝色→黄色→红色)。 - **粒子物理**:用于高影响力可视化的实时发光余烬和火花效果。 - **战术数据标签**:浮动HUD元素,显示类别名称、置信度和像素面积测量值。 - **扫描线效果**:动画"网络HUD"扫描线和角落括号,带来军事级监控体验。 ### 3. 智能RAG助手 基于LangChain和FAISS构建的集成**检索增强生成(RAG)**系统。 - 知识库专注于消防协议、疏散程序和OSHA标准。 - 优先考虑安全性的上下文感知响应,而非通用AI行为。 ### 4. 操作仪表板 采用高级玻璃态设计灵感的UI,包含: - **实时状态监控**:后端和传感器馈送的健康检查。 - **检测时间线**:使用Recharts进行历史趋势分析。 - **紧凑视频控制**:用于上传、检测和导出结果的高效工作流 ## 🏗️ 技术架构 ``` graph TB %% Detection Layer subgraph Detection ["🛡️ 1. DETECTION LAYER (YOLOv8)"] direction TB input[Video / CCTV Stream] --> yolo[best.pt Detection Engine] yolo --> boxes[Bounding Boxes] yolo --> masks[Segmentation Masks] end %% Agentic Layer subgraph Agentic ["🤖 2. AGENTIC LAYER (fire_agent.py)"] direction TB engine[Incident Decision Engine] llm[Groq LLM: Llama 3.3 70B] suppress[Autonomous Suppression Trigger] engine --- llm end %% RAG Layer subgraph RAG ["📚 3. RAG LAYER (real_rag_system.py)"] direction TB embed[SentenceTransformers] faiss[FAISS Vector DB] kb[Knowledge Base: NFPA 101, 13, 72 & OSHA] kb --> embed --> faiss end %% Backend Layer subgraph Backend ["⚙️ 4. BACKEND LAYER (FastAPI + SQLite)"] direction TB api[REST API Endpoints] db[(SQLite Database)] api --- db end %% Inter-layer connections Detection -->|zone_id, coords, area| Agentic Agentic <-->|Safety Context| RAG Agentic -->|Incident Logs| Backend Backend <-->|Real-time Telemetry| HUD[React HUD Dashboard] %% Styling style Detection fill:#0a1a2a,stroke:#22d3ee,stroke-width:2px,color:#fff style Agentic fill:#0a1a2a,stroke:#818cf8,stroke-width:2px,color:#fff style RAG fill:#0a1a2a,stroke:#facc15,stroke-width:2px,color:#fff style Backend fill:#0a1a2a,stroke:#ec4899,stroke-width:2px,color:#fff ``` ## 🛠️ 技术栈 - **计算机视觉**:Ultralytics YOLOv8(分割与检测)、OpenCV - **后端**:FastAPI、SQLAlchemy(SQLite)、Pydantic - **AI/LLM**:SentenceTransformers(嵌入)、FAISS(向量存储)、基于GPT的知识检索 - **前端**:React 18、Vite、Lucide-React、Recharts - **样式**:自定义CSS3(玻璃态、粒子引擎、关键帧动画) ## 🧠 模型训练与性能 该系统使用高性能深度学习模型,针对实时安全监控进行了优化。 - **架构**:基于**YOLOv8l**(大型)进行训练,以实现最大特征提取。 - **数据集**:基于**FASDD(火灾与烟雾检测数据集)**进行训练,包含超过**95,000张图像**。 - **检测精度**:仅经过**17个epoch**的微调即达到**80% mAP**。 - **分割精度**:使用YOLOv8-seg实现高保真分割掩码,达到**92%精度**。 - **硬件**:所有训练均在**Kaggle GPU**环境中完成 ## 📂 项目结构 ``` . ├── fire_backend.py # Core FastAPI Server & CV Logic ├── fire_agent.py # Autonomous Decision Logic & Incident Handling ├── real_rag_system.py # Vector Database & Retrieval Engine ├── models/ # YOLO Weights & Segmentation Modules ├── tests/ # System Validation Scripts ├── frontend/ # React Application │ ├── src/ │ │ ├── App.jsx # Dashboard Hub │ │ ├── overlay-enhanced.js # Cyber HUD Particle Engine │ │ └── index.css # HUD Design System │ └── package.json └── .env.example # Environment Template ``` ## ⚡ 快速开始 ### 1) 后端环境 ``` # Create Virtual Environment python3 -m venv .venv source .venv/bin/activate # Install Dependencies pip install -r requirements.txt # Start the CV/FastAPI engine python fire_backend.py ``` *基础URL:`http://localhost:8000` | 文档:`/docs`* ### 2) 前端环境 ``` # Navigate and launch dashboard cd frontend npm install npm run dev ``` ### 3. 环境配置 根据`.env.example`在根目录创建`.env`文件: ``` FIRE_DETECT_MODEL=./best.pt BACKEND_URL=http://localhost:8000 GROQ_API_KEY=your_groq_api_key ``` ## 📋 操作流程 1. **仪表板初始化**:确保右上角状态芯片显示**在线**。 2. **视频分析**:上传任何MP4/AVI文件。系统将自动隐藏上传面板以最大化网络HUD视窗。 3. **紧急覆盖**:"事件响应"面板中提供手动触发按钮,用于人工介入控制。 4. **导出**:可通过紧凑控制器中的"导出"按钮导出带有网络HUD烧录的处理后的视频 ## 👤 致谢

Designed and Developed with precision by

Muhammad Umar Farooq

Portfolio

"Building the future of autonomous safety systems."
标签:AI助手, AV绕过, FastAPI, HUD界面, RAG, React, SQLite, Syscalls, YOLOv8, 事件管理, 工业安全, 库, 应急响应, 智能报警, 智能监控, 检索增强生成, 消防系统, 深度学习, 火灾检测, 烟雾检测, 热力图, 物联网安全, 目标检测, 目标检测模型, 粒子系统, 结构化查询, 自主响应, 自动化安全, 视频分析, 计算机视觉, 边缘计算, 逆向工具