This project simulates an autonomous wildfire detection and containment system using drones, satellite imagery, and AI. It uses reinforcement learning (PPO) to coordinate a swarm of drones to prevent the spread of forest fires.
-
Purpose: Loads satellite imagery (Sentinel/MODIS) to detect vegetation health and thermal anomalies.
-
Key Steps:
- Loads
.tiffiles for NDVI (Normalized Difference Vegetation Index) and thermal data. - If real data not available → simulates data randomly.
- Preprocesses images for the model (resize + normalize).
- Loads
Key terms:
- NDVI: Measures vegetation health. Range [-1, 1].
- Thermal anomalies: Areas that are unusually hot → could indicate fire.
- Uses a ResNet18 model for feature extraction from satellite images.
- Combines features with NDVI and thermal data.
- Uses Isolation Forest to detect anomalies (fire-prone areas).
Key terms:
- ResNet18: Neural network for feature extraction from images.
- Isolation Forest: ML model to detect anomalies (outliers).
-
Scores risk based on threat detection.
-
Computes confidence for each risk.
-
Decides action:
- deploy_drones → if high risk & high confidence
- monitor → if low risk
Key terms:
- Confidence: Likelihood that the detected threat is real.
- Action escalation: Deciding whether drones should intervene.
- Controls multiple drones.
- Each drone has a role: scout, containment, monitor.
- Drones move using a simple A pathfinding* logic to reach targets.
Key terms:
- Scout: Explore unexplored areas.
- Containment: Fight fire edges.
- Monitor: Stay put or observe.
- Battery: Energy consumed per move.
- Plans firebreaks to prevent fire spread.
- Applies retardant to reduce fuel load and slow down fire.
Key terms:
- Firebreaks: Paths cleared to stop fire.
- Fuel load: Amount of combustible material.
-
Digital simulation of the forest as a grid graph.
-
Nodes = forest patches, edges = adjacency.
-
Attributes per node:
on_fire→ is this patch burningfuel→ amount of flammable materialspread_prob→ probability fire spreads to this patchvisited→ if drone has visited
Key terms:
- Digital twin: Virtual model of a real-world system.
- Wind factor & terrain cost: Affect fire spread probability.
- Custom RL environment for training drones.
- Action space: MultiDiscrete (up/down/left/right/stay) per drone.
- Observation space: NDVI + fire map (2 channels).
- Reward: Encourages putting out fire and minimizing energy.
Key terms:
- Reward: Positive points for extinguishing fire, negative for energy waste.
- Episode done: Drones depleted or fire fully contained.
-
System Initialization
- All agents (Satellite, Threat, Decision, Drone, Containment) are initialized.
- Digital twin created for forest.
-
Data Ingestion
- Load satellite tiles and NDVI maps.
- Simulate if data is missing.
-
Threat Detection
- Detect potential fire spots via ML model.
- Compute risk and confidence.
- Decide actions (deploy drones or monitor).
-
Drone Movement
- Drones move according to roles.
- Fire updates in digital twin based on spread rules.
-
Reinforcement Learning
- PPO trains drones for optimal containment policy.
- DummyVecEnv wraps the environment for Stable-Baselines3.
- Stop training when reward threshold reached (example: 50).
-
Containment & Metrics
- Plan firebreaks & apply retardant.
- Update fire spread post-drone intervention.
- Compute metrics.
| Metric | Meaning |
|---|---|
| Latency | Time system took to run the simulation. Low = faster response. |
| Area Saved | How many initial fire patches were successfully contained. |
| Time to Containment | Time elapsed until fire is mostly contained. |
| Energy Consumed | Sum of drone battery usage during simulation. |
| CO2 Avoided | Environmental impact: more fire contained → more CO₂ saved. |
Note: If Area Saved = 0 and CO2 Avoided = 0, it means drones didn’t successfully contain any fires in this run.
- NDVI Map → background of forest health.
- Drones → red dots.
- Active fires → orange dots.
- Updates dynamically each step in simulation.
- Install dependencies:
pip install torch torchvision rasterio stable-baselines3 gymnasium matplotlib networkx streamlit - Run Streamlit app:
streamlit run wildfire_sim.py- Press "Start Simulation" → Watch drones react, fires spread, and metrics update.
- Metrics logged in
metrics.csvfor analysis.
- Integrates satellite imagery, ML anomaly detection, digital twin modeling, and drone swarm control.
- Real-time metric reporting: area saved, CO₂ avoided, energy used.
- RL-based drone coordination using PPO.