Skip to content

Latest commit

ย 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

FIRO Logo

๐Ÿ”ฅ FIRO โ€” Wildfire Detection System

Edge AI ยท Real-Time Monitoring ยท Forest Fire Early Warning

Python TensorFlow Lite Firebase Raspberry Pi License

FIRO is a lightweight, real-time wildfire detection system built for resource-constrained edge devices. A MobileNetV2 model โ€” optimized to TensorFlow Lite INT8 โ€” runs directly on a Raspberry Pi 5, classifying forest camera images and pushing fire alerts to a web dashboard and WhatsApp, all without relying on cloud compute.

BS Final Year Project ยท Department of Data Science ยท University of Kotli, AJK
Ahmed Ali ยท Seher Ishtiaq ยท Supervisor: Mr. Nabeel Ali ยท Session 2021โ€“2025


๐Ÿ“‹ Table of Contents


๐ŸŒ Overview

Wildfires in Pakistan โ€” especially in Azad Jammu & Kashmir โ€” are increasingly devastating. In 2024 alone, 2,214 high-confidence VIIRS fire alerts were recorded across Pakistan. Traditional detection relies on satellite imagery (with 16-day revisit cycles), manual watchtowers, and public reporting โ€” all too slow for early intervention.

FIRO (Fire Intelligence & Response Observatory) solves this by putting AI directly on the ground:

  • A USB camera mounted on a forest tower feeds images to a Raspberry Pi 5
  • An INT8-quantized MobileNetV2 model runs fully on-device โ€” no cloud compute needed
  • Only lightweight metadata (fire/no-fire label, confidence, GPS, timestamp) is sent to Firebase
  • Alerts reach Forest Department staff via WhatsApp and a real-time web dashboard

97.5% accuracy ยท <1s inference latency ยท Runs on a $80 edge device


๐Ÿ— System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        EDGE LAYER                                   โ”‚
โ”‚                                                                     โ”‚
โ”‚   ๐Ÿ“ท USB Camera                                                     โ”‚
โ”‚       โ”‚  RGB frames                                                 โ”‚
โ”‚       โ–ผ                                                             โ”‚
โ”‚   ๐Ÿ–ฅ๏ธ  Raspberry Pi 5                                                โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
โ”‚   โ”‚  1. Capture image at timed intervals             โ”‚              โ”‚
โ”‚   โ”‚  2. Resize to 224ร—224 ยท Normalize pixels        โ”‚              โ”‚
โ”‚   โ”‚  3. Run MobileNetV2 Lite (INT8 TFLite)          โ”‚              โ”‚
โ”‚   โ”‚  4. Get: { label, confidence, timestamp, GPS }  โ”‚              โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚  Metadata only (no raw images)
                           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                       CLOUD LAYER (Firebase)                        โ”‚
โ”‚                                                                     โ”‚
โ”‚   ๐Ÿ”ฅ Firestore โ†’ stores fire_logs collection                        โ”‚
โ”‚   ๐Ÿ” Firebase Auth โ†’ secures dashboard access                       โ”‚
โ”‚   ๐Ÿ“ก Triggers โ†’ WhatsApp alerts on fire detection                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                โ”‚
                โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     DASHBOARD LAYER                                 โ”‚
โ”‚                                                                     โ”‚
โ”‚   ๐ŸŒ Web Dashboard (HTML/JS + Python Dash)                          โ”‚
โ”‚   โ”œโ”€โ”€ Live map with camera locations (Leaflet)                      โ”‚
โ”‚   โ”œโ”€โ”€ Real-time alert panel (auto-polls every 5 s)                  โ”‚
โ”‚   โ”œโ”€โ”€ Event log history (filterable)                                โ”‚
โ”‚   โ””โ”€โ”€ Dark mode ยท PWA-enabled                                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœจ Key Features

Feature Description
๐Ÿง  On-Device Inference MobileNetV2 Lite (INT8) runs entirely on Raspberry Pi โ€” no cloud compute
โšก Real-Time Detection Images captured and classified continuously; results pushed in seconds
๐Ÿ“ก Minimal Bandwidth Only compact metadata sent to Firebase โ€” no raw image uploads
๐Ÿ—บ๏ธ Live Map Dashboard Leaflet-powered interactive map shows all camera locations and fire status
๐Ÿšจ Instant Alerts WhatsApp notifications delivered to forest staff on fire detection
๐Ÿ” Secure Login Firebase Authentication guards dashboard access
๐Ÿ“œ Event Log History Full searchable log of all detection events with timestamps
๐ŸŒ™ Dark / Light Mode Full theme support across all dashboard pages
๐Ÿ“ฑ PWA Ready Installable as a mobile app via service worker + manifest
๐Ÿ“Š Python Dash View Alternative Plotly/Dash analytics panel (app.py) for deeper analysis

๐Ÿ›  Tech Stack

Edge Device (Raspberry Pi 5)

Component Technology
Language Python 3.11
ML Framework TensorFlow Lite (INT8)
Model MobileNetV2 (fine-tuned, quantized)
Camera USB Camera (OpenCV capture)
Cloud Push Firebase Admin SDK

Dashboard (Web)

Component Technology
Frontend HTML5, Tailwind CSS, Vanilla JS
Maps Leaflet.js
Auth Firebase Authentication
Database Cloud Firestore
Icons Font Awesome 6
PWA Service Worker + Web App Manifest
Analytics Panel Python Dash + Plotly

Cloud & Infrastructure

Component Technology
Database Firebase Firestore
Authentication Firebase Auth (Email/Password)
Alerts WhatsApp (via Firebase trigger)
Hosting Firebase Hosting (recommended)

๐Ÿ“ Repository Structure

FIRO-FYP/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ dashboard/                    # Web dashboard frontend + Dash backend
โ”‚   โ”œโ”€โ”€ index.html                   # Main monitoring dashboard (live map, alerts)
โ”‚   โ”œโ”€โ”€ login.html                   # Firebase Auth login/signup page
โ”‚   โ”œโ”€โ”€ logs.html                    # Historical fire event log page
โ”‚   โ”œโ”€โ”€ settings.html                # User preferences (theme toggle)
โ”‚   โ”œโ”€โ”€ login.css                    # Login page styles
โ”‚   โ”œโ”€โ”€ login.js                     # Legacy login helper (superseded by login.html)
โ”‚   โ”œโ”€โ”€ script.js                    # Firebase initialization script
โ”‚   โ”œโ”€โ”€ service-worker.js            # PWA offline caching
โ”‚   โ”œโ”€โ”€ manifest.json                # PWA web app manifest
โ”‚   โ”œโ”€โ”€ logo.png                     # FIRO / university logo
โ”‚   โ”œโ”€โ”€ app.py                       # Python Dash analytics dashboard
โ”‚   โ””โ”€โ”€ service_account_key.json     # โš ๏ธ  SECRET โ€” never commit (in .gitignore)
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ Models Source Files/          # Trained & optimized ML model
โ”‚   โ””โ”€โ”€ mobilenetv2_fire_detection.tflite   # INT8 quantized TFLite model
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ raspberry-pi/                 # Edge device inference code
โ”‚   โ”œโ”€โ”€ capture.py                   # Camera capture + inference loop
โ”‚   โ”œโ”€โ”€ firebase_push.py             # Push results to Firestore
โ”‚   โ””โ”€โ”€ requirements.txt             # Pi dependencies
โ”‚
โ”œโ”€โ”€ .gitignore                       # Ignores secrets, venvs, IDE files
โ””โ”€โ”€ README.md                        # You are here

Note: The raspberry-pi/ folder contains the on-device code that runs the inference loop on Raspberry Pi 5. Both codebases share the same Firebase project.


๐Ÿ“Š Model Performance

Model Comparison (Same Wildfire Dataset)

Model Parameters Test Accuracy
MobileNetV2 (Proposed) 2.6 M 97.50% โœ…
VGG-16 15.24 M 93.23%
ResNet-50 ~25 M 96.59%
EfficientNet-B0 4.38 M 98.47%
EfficientNetV2-B0 6.25 M 97.58%
YOLOv11 Nano 1.53 M 96.40%

MobileNetV2 was chosen despite not being the highest-accuracy model โ€” its 2.6M parameter count, TFLite compatibility, and INT8 quantization make it the only realistic choice for real-time inference on Raspberry Pi 5.

Quantized Model (Deployed)

Metric MobileNetV2 (FP32) MobileNetV2 Lite (INT8)
Accuracy 0.96 0.95
Precision 0.96 0.95
Recall 0.96 0.95
F1-Score 0.96 0.95

Dataset

  • Total images: 6,247 (Fire: 2,821 ยท No Fire: 3,427)
  • Train / Val / Test: 4,350 / 656 / 1,241
  • Image size: 224 ร— 224 RGB
  • Source: Kaggle forest fire dataset

Real-World Night Test

12 images captured in actual forest fires near Khuiratta and Nakyal, AJK (Dec 2025 โ€“ Jan 2026) โ†’ 100% detection accuracy under low-light, real-world conditions.


๐Ÿš€ Getting Started

Prerequisites

  • Python 3.10 or 3.11
  • A Firebase project (create one free)
  • Raspberry Pi 5 with Raspberry Pi OS (64-bit)
  • USB camera
  • Git

1. Dashboard Setup

Clone the repo:

git clone https://github.com/datixai/FIRO-FYP.git
cd FIRO-FYP

Install Python dependencies (for app.py Dash dashboard):

cd dashboard
python -m venv venv
source venv/bin/activate        # Windows: venv\Scripts\activate
pip install dash plotly pandas google-cloud-firestore

Set your Firebase credentials:

export GCP_KEY_PATH=/path/to/your/service_account_key.json

Run the Dash analytics dashboard:

python app.py
# Open http://127.0.0.1:8050

For the HTML dashboard (index.html, login.html, etc.) โ€” simply open in a browser or deploy to Firebase Hosting:

npm install -g firebase-tools
firebase login
firebase init hosting
firebase deploy

2. Raspberry Pi Setup

# On Raspberry Pi 5 (SSH in or open terminal)
git clone https://github.com/datixai/FIRO-FYP.git
cd FIRO-FYP/raspberry-pi

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Place your Firebase service account key (from Firebase Console โ†’ Project Settings โ†’ Service Accounts):

# Copy the JSON key to the raspberry-pi directory (this file is gitignored)
cp /path/to/service_account_key.json ./service_account_key.json

Run the detection loop:

python capture.py

The script will:

  1. Capture an image via the USB camera every N seconds
  2. Resize and normalize to 224ร—224
  3. Run inference using mobilenetv2_fire_detection.tflite
  4. Push results to Firebase Firestore
  5. Trigger WhatsApp alert if fire is detected

3. Firebase Configuration

  1. Go to Firebase Console โ†’ your project
  2. Enable Firestore Database โ€” start in production mode
  3. Enable Authentication โ†’ Email/Password provider
  4. Create your Firestore collection: fire_logs
  5. Download Service Account Key (Project Settings โ†’ Service Accounts โ†’ Generate New Private Key)
  6. โš ๏ธ Never commit this file โ€” it is listed in .gitignore

Firestore document structure (written by Raspberry Pi):

{
  "timestamp_ms": 1704067200000,
  "timestamp_str": "2026-01-01 12:00:00",
  "detection_class": "Fire",
  "fire_probability": 0.94,
  "camera_location": "Khuiratta Tower 1",
  "coords_x": 33.6844,
  "coords_y": 73.0479,
  "device_id": "rpi5-unit-01"
}

๐Ÿ–ฅ๏ธ Dashboard Pages

Login Screen

Firebase-authenticated login/signup. Session expires on browser close (session persistence).
File: dashboard/login.html

Main Dashboard (index.html)

  • Live Leaflet map โ€” colour-coded markers (๐Ÿ”ด Fire / ๐ŸŸข Safe) at each camera location
  • Alert panel โ€” pulses red with critical fire alert details when fire is detected
  • Stats cards โ€” total alerts, active cameras, latest detection time
  • Real-time updates โ€” auto-polls Firebase every 5 seconds
  • Dark / Light mode toggle

Fire Event Log (logs.html)

  • Full history of all detection events from Firebase
  • Filter by: Fire / No Fire / All
  • Each entry shows: timestamp, location, confidence score, classification
  • Dark mode supported

Settings (settings.html)

  • Theme preference (Light / Dark)
  • More options in development (alert thresholds, notification recipients)

Python Dash Dashboard (app.py)

  • Alternative analytics view using Plotly/Dash
  • Scatter mapbox with fire probability bubble sizing
  • Recent log table with conditional red highlighting for fire events
  • Last-hour data window with 5-second polling

โš™๏ธ Edge Device Pipeline

USB Camera
    โ”‚
    โ”‚ RGB frame
    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Preprocessing               โ”‚
โ”‚  โ€ข Resize โ†’ 224 ร— 224              โ”‚
โ”‚  โ€ข Normalize pixel values [0, 1]   โ”‚
โ”‚  โ€ข Format as float32 tensor        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
                 โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   TFLite Interpreter                โ”‚
โ”‚   mobilenetv2_fire_detection.tflite โ”‚
โ”‚   (INT8 quantized, ~2.6M params)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
                 โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Postprocessing              โ”‚
โ”‚  โ€ข Softmax probabilities           โ”‚
โ”‚  โ€ข Threshold: 0.70 โ†’ Fire          โ”‚
โ”‚  โ€ข Add GPS, device ID, timestamp   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ”‚             โ”‚
          โ–ผ             โ–ผ
   Firebase          WhatsApp
   Firestore         Alert
   (metadata)        (if fire)

Training Setup:

  • Framework: TensorFlow 2.x + Keras
  • Hardware: NVIDIA Tesla P100 GPU
  • Transfer learning: ImageNet pre-trained weights โ†’ fine-tuned on wildfire dataset
  • Quantization: Post-training INT8 via TFLite Converter + calibration dataset

๐Ÿ“ˆ Results

  • โœ… 97.5% test accuracy (MobileNetV2 FP32)
  • โœ… 95% accuracy after INT8 quantization (negligible drop)
  • โœ… 100% accuracy on 12 real night-time wildfire images from AJK
  • โœ… Sub-second inference on Raspberry Pi 5
  • โœ… All 6 unit test cases passed (capture โ†’ preprocess โ†’ infer โ†’ push โ†’ alert โ†’ display)

๐ŸŒ Motivation

Pakistan recorded 966 high-confidence fire alerts in 2025 and 1,905 in 2024 โ€” the highest ever recorded. The December 2025 Neelum Valley fire and recurring fires in Sherani, Margalla Hills, and Gilgit-Baltistan illustrate the urgent need for early warning systems. Satellite-based tools have 16-day revisit cycles. Manual watchtowers don't scale.

FIRO is designed for exactly this gap: affordable, deployable, and accurate โ€” built for the forest conditions of Northern Pakistan and Azad Kashmir.


๐Ÿ”ฎ Future Work

  • Multi-sensor fusion (temperature, humidity, gas sensors)
  • Drone-based aerial image integration
  • SMS / mobile push notifications in addition to WhatsApp
  • Temporal modeling for smoke trajectory prediction
  • Federated learning across multiple edge nodes
  • Large-scale long-term field deployment and validation
  • Admin panel for managing camera nodes and alert thresholds

๐Ÿ‘ฅ Authors

Name Role Contact
Ahmed Ali Group Leader rajaahmedalikhan97@gmail.com
Seher Ishtiaq Member hania93malik@gmail.com

Supervisor: Mr. Nabeel Ali
Institution: Department of Data Science, Faculty of Computing & Engineering
University of Kotli, Azad Jammu & Kashmir


๐Ÿ“„ License

This project is released under the MIT License.
Built with โค๏ธ for the forests of Azad Kashmir.


FIRO ยท University of Kotli AJK ยท BS Data Science ยท 2021โ€“2025

About

Forest fire solution combining thermal/RGB cameras with optimized deep learning models (EfficientNet + MobileViT) for real-time wildfire detection in Pakistan's forests. Deployable on Raspberry Pi, featuring Grad-CAM exploitability and multi-sensor fusion to reduce false alarms.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages