Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Wildfire Detection AI/ML System

An AI-powered system for detecting wildfires in images and video streams using deep learning.

Project Overview

This system uses computer vision and deep learning to detect the presence of wildfires in images and video streams. The project is implemented in three phases:

  1. Phase 1: Core AI/ML model for image-based fire detection
  2. Phase 2: Real-time webcam integration
  3. Phase 3: Raspberry Pi deployment
  4. Phase 4: Web Interface Integration

Features

  • Transfer learning using MobileNetV2 for efficient fire detection
  • Real-time webcam monitoring with visual alerts
  • Comprehensive data visualization and model performance analysis
  • Interactive dataset verification and cleaning tools
  • Automated model evaluation and reporting

Installation

  1. Clone this repository:
git clone [repository-url]
cd firedetect
  1. Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Project Structure

firedetect/
├── data/
│   ├── fire/         # Fire images for training
│   ├── no_fire/      # Non-fire images for training
│   └── review/       # Images requiring manual review
├── src/
│   ├── data.py           # Data loading and preprocessing
│   ├── model.py          # Neural network model definition
│   ├── train.py          # Training script
│   ├── inference.py      # Inference module
│   └── visualize.py      # Visualization tools
├── models/           # Saved model files
├── logs/             # Training and inference logs
├── visualizations/   # Generated plots and visualizations
├── requirements.txt
└── README.md
web_interface/
├── app.py            # Web application for camera streaming and detection
├── static/           # Static files for web interface
└── templates/        # HTML templates for web interface

Component Descriptions

  1. Data Module (data.py):

    • Handles dataset loading and preprocessing
    • Implements data augmentation for training
    • Manages training/validation data splits
  2. Model Module (model.py):

    • Defines the MobileNetV2-based neural network architecture
    • Configures transfer learning layers
    • Sets up model compilation with appropriate loss and metrics
  3. Training Pipeline (train.py):

    • Orchestrates the training process
    • Implements early stopping and model checkpointing
    • Saves trained models to disk
  4. Visualization Module (visualize.py):

    • Generates performance visualizations
    • Creates confusion matrices and evaluation reports
    • Produces dataset distribution plots
  5. Inference Module (inference.py):

    • Loads trained models
    • Performs prediction on new images
    • Processes results for interpretation
  6. Web Interface (app.py):

    • Provides browser-based UI for the system
    • Handles camera feed integration
    • Displays real-time detection results

Data Flow

  1. Training data flows from the Data Module to the Training Pipeline
  2. The Model Module provides the architecture used by the Training Pipeline
  3. The Training Pipeline generates artifacts for the Visualization Module
  4. The Inference Module uses the trained model for predictions
  5. The Web Interface uses the Inference Module for real-time detection on camera feeds

Usage

Data Preparation

For proper training, organize your dataset:

  • Place fire images in data/fire/
  • Place non-fire images in data/no_fire/

Ensure your dataset is properly categorized and labeled before proceeding with training.

Training the Model

python src/train.py --data_dir data/ --epochs 50 --batch_size 32

The training process includes:

  • Automatic data augmentation
  • Transfer learning with MobileNetV2
  • Early stopping to prevent overfitting
  • Model checkpointing to save the best model
  • Comprehensive visualization generation

Visualizations

During training, the system automatically generates:

  • Dataset distribution plots
  • Sample image grids
  • Training/validation metrics plots
  • Confusion matrices
  • Detailed evaluation reports

All visualizations are saved in the visualizations/ directory.

Running Inference on Images

python src/inference.py --model_path models/best_model.h5 --image_path path/to/image.jpg

Real-time Webcam Detection

To use the web interface for real-time wildfire detection:

cd web_interface
python app.py

This will start a web server that provides:

  • Real-time camera streaming
  • Fire detection on camera feed
  • Visual alerts when fire is detected

Model Architecture

The system uses a transfer learning approach based on MobileNetV2:

  • Pre-trained on ImageNet
  • Fine-tuned for wildfire detection
  • Additional custom layers for binary classification
  • Optimized for real-time performance

Performance Metrics

The model is evaluated on:

  • Accuracy
  • Precision
  • Recall
  • F1-score
  • Confusion matrix

Data Requirements

  • Place fire images in data/fire/
  • Place non-fire (normal forest) images in data/no_fire/
  • Supported formats: JPG, PNG
  • Recommended minimum dataset size: 1000 images per class

Recent Changes

  • Added comprehensive data visualization tools
  • Implemented interactive dataset verification system
  • Enhanced model evaluation with detailed metrics
  • Added automatic visualization generation during training
  • Improved documentation and code organization

About

An AI-powered system for detecting wildfires in images and video streams using deep learning.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages