Skip to content

Repository files navigation

πŸ”₯ Real-Time Fire Detection Using YOLOv8, OpenCV & Deep Learning



🚨 AI-Based Intelligent Fire Detection & Safety Monitoring System

Real-Time Fire Detection through Computer Vision and Deep Learning


πŸŽ“ Digital Image Processing (DIP) Semester Project

πŸ‘¨β€πŸ’» Developed by Ghayoor Khan


πŸ“– Introduction

Fire accidents remain one of the major causes of damage to human life, industrial infrastructure, forests, and public property worldwide. Traditional fire alarm systems mainly rely on smoke sensors and heat detectors, which may fail in large-scale environments or open spaces.

With the advancement of Artificial Intelligence, Computer Vision, and Deep Learning, visual fire detection systems have become more accurate, scalable, and intelligent.

This project presents a Real-Time Fire Detection System developed using:

  • YOLOv8 (You Only Look Once)
  • OpenCV
  • PyTorch
  • Python

The system detects fire directly from live webcam video streams using AI-powered object detection techniques.

The project combines concepts of:

  • Digital Image Processing
  • Computer Vision
  • Deep Learning
  • Real-Time Object Detection
  • Intelligent Surveillance Systems

🎯 Project Objectives

The primary objectives of this project are:

βœ… Detect fire in real time using Artificial Intelligence
βœ… Apply Digital Image Processing concepts practically
βœ… Train a custom YOLOv8 object detection model
βœ… Build an intelligent safety monitoring system
βœ… Explore real-world Computer Vision applications
βœ… Improve understanding of Deep Learning workflows


🧠 Core Technologies Used

Technology Purpose
Python 3.10 Core programming language
YOLOv8 Real-time object detection
OpenCV Video processing & visualization
PyTorch Deep learning framework
NumPy Numerical operations
Roboflow Dataset management & annotation
VS Code Development environment

πŸ” About YOLOv8

YOLOv8 (You Only Look Once Version 8) is a state-of-the-art real-time object detection model developed by Ultralytics.

It is widely used because of:

  • high speed,
  • strong accuracy,
  • lightweight architecture,
  • and real-time performance.

In this project, YOLOv8 was trained specifically to detect fire from images and live video streams.


πŸ“‚ Dataset Collection & Preparation

🌐 Dataset Source

The fire dataset used in this project was collected from:

πŸ”— Roboflow

Roboflow is a professional Computer Vision platform used for:

  • dataset management,
  • image annotation,
  • preprocessing,
  • augmentation,
  • and YOLO dataset export.

The dataset contained:

  • fire images,
  • labeled annotations,
  • training images,
  • validation images,
  • and testing samples.

πŸ—ƒοΈ Dataset Structure

The dataset was organized according to YOLO object detection format.

dataset/
β”‚
β”œβ”€β”€ train/
β”‚   β”œβ”€β”€ images/
β”‚   β”œβ”€β”€ labels/
β”‚   └── labels.cache
β”‚
β”œβ”€β”€ valid/
β”‚   β”œβ”€β”€ images/
β”‚   β”œβ”€β”€ labels/
β”‚   └── labels.cache
β”‚
β”œβ”€β”€ test/
β”‚   β”œβ”€β”€ images/
β”‚   └── labels/
β”‚
└── data.yaml

πŸ“‘ About data.yaml

The data.yaml file contains:

  • dataset paths,
  • class names,
  • training configuration,
  • and validation information.

It acts as the main configuration file for YOLOv8 training.


πŸ§ͺ Project Workflow

The system works in two major phases:


1️⃣ Training Phase

During training:

βœ” Fire dataset loaded βœ” YOLOv8 pretrained model initialized βœ” Dataset processed into batches βœ” Deep learning training performed βœ” Model optimized over multiple epochs βœ” Best weights saved automatically


πŸ“Š Model Training

The YOLOv8 model was trained using:

  • custom fire dataset,
  • GPU/CPU processing,
  • object detection techniques,
  • and supervised learning methods.

Training Details

Parameter Value
Model YOLOv8n
Epochs 30
Framework PyTorch
Detection Type Fire Detection
Dataset Format YOLO

πŸ’Ύ Trained Weights

After successful training:

best.pt

was generated as the best-performing trained model.

Additional files generated:

  • training graphs,
  • metrics,
  • loss curves,
  • validation results,
  • and inference outputs.

πŸ“‚ Training Output Structure

runs/
└── detect/
    β”œβ”€β”€ train/
    └── train2/
        β”œβ”€β”€ weights/
        β”‚   β”œβ”€β”€ best.pt
        β”‚   └── last.pt
        β”‚
        β”œβ”€β”€ args.yaml
        β”œβ”€β”€ results.csv
        β”œβ”€β”€ confusion_matrix.png
        β”œβ”€β”€ labels.jpg
        └── training graphs

2️⃣ Real-Time Detection Phase

In the detection phase:

πŸŽ₯ Webcam captures live video 🧠 YOLOv8 processes each frame πŸ”₯ Fire regions detected instantly πŸ“¦ Bounding boxes drawn πŸ“ˆ Confidence scores displayed

The system performs detection in real time with smooth visualization.


βš™οΈ Detection Pipeline

Webcam Input
      ↓
Frame Capture
      ↓
YOLOv8 Inference
      ↓
Fire Detection
      ↓
Bounding Box Visualization
      ↓
Real-Time Output Display

πŸ› οΈ Installation Guide

Step 1 β€” Clone Repository

git clone https://github.com/your-username/Real-Time-Fire-Detection-Using-YOLOv8-and-OpenCV.git

Step 2 β€” Navigate to Project Folder

cd Real-Time-Fire-Detection-Using-YOLOv8-and-OpenCV

Step 3 β€” Install Dependencies

pip install -r requirements.txt

πŸ“¦ requirements.txt

ultralytics
opencv-python
numpy

▢️ Running the Project

πŸ”Ή Train Custom Model

python train.py

πŸ”Ή Start Real-Time Fire Detection

python detect.py

πŸ“Έ System Output

The system generates:

βœ… Real-time fire detection windows βœ… Bounding boxes βœ… Confidence score display βœ… Trained model weights βœ… Training graphs & metrics βœ… Detection visualizations


🌍 Real-World Applications

This system can be used in:

🏭 Industrial safety monitoring 🌲 Forest fire surveillance 🏒 Smart building systems 🚨 Emergency alert systems 🏠 Home automation πŸ“Ή Intelligent CCTV monitoring πŸ›‘οΈ Public safety infrastructure


πŸš€ Future Improvements

This project will continue to evolve into a more intelligent smart safety system.

Planned future enhancements include:

πŸ”” Automatic alarm integration πŸ“± SMS and mobile notifications ☁️ IoT-enabled monitoring 🌫️ Smoke detection capability πŸ“· Multi-camera CCTV support 🌐 Web dashboard integration 🧠 Improved AI model accuracy πŸ“‘ Cloud-based monitoring system 🚨 Emergency response automation


⚑ Advantages of the System

βœ” Real-time detection βœ” AI-powered monitoring βœ” Faster than traditional systems βœ” Cost-effective solution βœ” Scalable architecture βœ” Intelligent surveillance support


⚠️ Current Limitations

  • Detection quality depends on dataset quality
  • Extreme lighting conditions may affect accuracy
  • Smoke-only situations remain challenging
  • Performance varies depending on hardware

🧠 Skills Demonstrated

This project demonstrates practical expertise in:

  • Artificial Intelligence
  • Computer Vision
  • Deep Learning
  • YOLOv8 Model Training
  • Object Detection
  • OpenCV Integration
  • Dataset Preparation
  • Real-Time AI Systems
  • Digital Image Processing
  • Python Development

πŸŽ“ Academic Contribution

This project was developed as a major semester project for:

Digital Image Processing (DIP)

The project combines theoretical image processing concepts with practical AI implementation to solve real-world safety problems.

It reflects:

  • practical learning,
  • research mindset,
  • implementation ability,
  • and problem-solving skills.

πŸ‘¨β€πŸ’» Developer

Ghayoor Khan

Computer Science Student Passionate about:

  • Artificial Intelligence
  • Computer Vision
  • Deep Learning
  • Intelligent Safety Systems

πŸ“š References

  • Ultralytics YOLOv8 Documentation
  • OpenCV Official Documentation
  • PyTorch Documentation
  • Roboflow Dataset Platform

⭐ AI-Powered Smart Fire Detection System

Future intelligent surveillance and emergency monitoring solution

If you found this repository useful, consider giving it a star ⭐

About

Deep Learning-based real-time fire detection and intelligent surveillance system using YOLOv8, OpenCV, and Computer Vision techniques.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages