π°οΈ Deforestation Detection App
This application uses a transformer-based ChangeFormer model to detect deforestation in the Brazilian Amazon using Sentinel-2 satellite imagery. Developed as a final year project, it processes 4-band (RGB + NIR) .tif images from 2020 and 2021 to generate binary change masks and overlay predictions, achieving an F1-score of 0.9986 and IoU of 0.9972 on validation data.
π Overview
- Model: Custom
ChangeFormerwith a Vision Transformer encoder, Feature Difference Module, and Deconv Decoder. - Data: Sentinel-2 Level-2A imagery (10m resolution) and PRODES deforestation labels.
- Interface: Gradio-powered app for drag-and-drop uploads and real-time visualization.
- Purpose: Scalable and interpretable tool for land monitoring, policy-making, and conservation.
β¨ Features
- Upload two
.tifimages (2020 and 2021) with 4 bands: B2 (blue), B3 (green), B4 (red), and B8 (NIR). - Outputs:
- β Raw RGB base image (2021)
- β Binary change mask (black/white)
- β RGB + red overlay for deforested regions
- β Comment on % of detected change
- Handles large images with patch-based tiling, normalization, and stitching.
βοΈ Setup & Usage
π§ Prerequisites
- Python 3.8+
- Required libraries:
torch,torchvision,timm,rasterio,numpy,pillow,gradio
π¦ Installation
git clone https://github.com/manuelhorvey/ChangeFormer.git
cd ChangeFormer
pip install -r requirements.txt
Place your trained model checkpoint as:
models/best_model.pth
π Run Locally
python app.py
Then open: http://localhost:7860
π§ͺ Input & Output
Input
Two 4-band
.tifimages from the same area:- One from 2020
- One from 2021
Patches preferred (e.g., 256Γ256)
Output
- RGB image from 2021
- Red-highlighted deforestation overlay
- Binary change mask
- Textual feedback on % change
βοΈ Images with <20% cloud cover yield best accuracy.
π Project Details
| Item | Value |
|---|---|
| Region | Brazilian Amazon (e.g., APA Triunfo do Xingu) |
| Dataset Size | 19,560 patches (256Γ256), 4 channels, 2 years |
| Metrics | F1-score: 0.9986, IoU: 0.9972 |
| Augmentations | Rotations (90/180/270), flips |
| Future Plans | Web-based monitoring alerts, SAR fusion, forecasting |
π₯ Authors
- Emmanuel Amey
- Sammuel Young Appiah
- Asare Prince Owusu
- Yaaya Pearl Apenu
Based on ideas from Alshehri et al. (2024), IEEE GRSL.
πͺͺ License
This project is licensed under the MIT License.
---
Inference Providers NEW
This model isn't deployed by any Inference Provider. π 1 Ask for provider support
Evaluation results
- f1 on Brazilian Amazon (2020β2021)self-reported0.999
- iou on Brazilian Amazon (2020β2021)self-reported0.997