This repository implements a deep-learning pipeline to detect illegal logging in the Mawas Conservation Area (Central Kalimantan, Indonesia) using Sentinel‑1 SAR imagery. It combines a DeepLabV3 encoder with an EfficientNet‑B4 backbone and a UNet-style decoder enhanced by SCSE attention. The model is trained for binary semantic segmentation of illegal logging vs. background on tiled VH, VV, and VV/VH input bands. Results in the paper report F1 ≈ 0.656 and IoU ≈ 0.488, demonstrating strong potential for operational monitoring with further refinement.
If your local repo structure or filenames differ, adapt the paths below. This README reflects the paper and standard deep-learning project patterns.
# 1) Clone
git clone https://github.com/HGTNewCoder/forest_detection.git
cd forest_detection
# 2) Create environment
conda create -n forest-detect python=3.10 -y
conda activate forest-detect
# 3) Install dependencies
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121 # or CPU index-url
pip install segmentation-models-pytorch efficientnet-pytorch
pip install albumentations opencv-python numpy scipy
pip install rasterio shapely geopandas pyproj
pip install scikit-image scikit-learn tqdm pyyaml
pip install matplotlib seaborn
# 4) Organize data
# data/raw/ (SAR VV, VH, ratio)
# data/labels/ (binary masks)
# 5) Preprocess
python scripts/preprocess.py \
--input_dir data/raw \
--label_dir data/labels \
--output_dir data/tiles \
--crop_size 2464 \
--tile_size 382 \
--bands VV,VH,RATIO \
--val_split 0.2 \
--filter_tiles 15
# 6) Train
python train.py \
--data_dir data/tiles \
--epochs 450 \
--batch_size 8 \
--lr 3e-4 \
--max_lr 1e-3 \
--weight_decay 1e-5 \
--loss focal_tversky \
--focal_alpha 0.6 --focal_gamma 2.0 \
--tversky_alpha 0.4 --tversky_beta 0.6 \
--amp \
--save_dir outputs/run_01
# 7) Evaluate
python eval.py \
--model_ckpt outputs/run_01/best.ckpt \
--data_dir data/tiles/val \
--threshold 0.5
# 8) Inference on a new scene
python infer.py \
--scene_path data/raw/S1_scene.tif \
--model_ckpt outputs/run_01/best.ckpt \
--bands VV,VH,RATIO \
--tile_size 382 \
--overlap 32 \
--threshold 0.5 \
--out_raster outputs/run_01/pred_illegal_logging.tifforest_detection/
├─ README.md
├─ train.py
├─ eval.py
├─ infer.py
├─ models/
│ ├─ deeplab_unet_scse.py
│ ├─ backbones.py
│ ├─ losses.py
│ └─ utils.py
├─ data/
│ ├─ raw/
│ ├─ labels/
│ └─ tiles/
├─ scripts/
│ ├─ preprocess.py
│ └─ visualize.py
├─ cfg/
│ └─ default.yaml
├─ outputs/
│ └─ run_01/
├─ requirements.txt
└─ LICENSE
The dataset consists of dual-polarized Sentinel-1 SAR imagery (VV and VH) acquired over the Mawas region between 2020 and 2023. Ground truth masks for illegal logging are manually annotated based on time-series inspection of canopy disturbance, corroborated by expert validation and auxiliary optical imagery. All SAR scenes are preprocessed using terrain correction, speckle filtering, and radiometric calibration. VV and VH channels are stacked and normalized to form the input tensor.
To improve model robustness, data augmentation includes random rotations, flips, elastic deformations, and intensity scaling. Patches are extracted at 512×512 resolution with overlap to preserve edge continuity. The dataset is split into training, validation, and test sets using spatial stratification to prevent leakage across temporally adjacent scenes.
- Area: ~750 km² within Mawas Conservation Area, Central Kalimantan, Indonesia
- Sensor/mode: Sentinel‑1 IW swath; 250 km swath; 5m × 20m resolution
- Polarizations: VV, VH, and VV/VH ratio
- Temporal span: Mar 2015 – Dec 2016 (23 scenes)
- Preprocessing: Crop to 2464×2464, tile to 382×382, filter tiles to balance classes, normalize bands, augment (rotation, flips, brightness/contrast, Gaussian noise, coarse dropout)
The segmentation model integrates a DeepLabV3 encoder with an EfficientNet-B4 backbone and a UNet-style decoder enhanced by Spatial and Channel Squeeze & Excitation (SCSE) attention modules. This hybrid architecture is designed to balance semantic richness with spatial precision, enabling accurate delineation of logging-induced canopy disturbance from noisy SAR backscatter signals. The SCSE blocks improve feature recalibration by adaptively weighting spatial and channel-wise information, which is particularly beneficial in low-contrast, high-variability peatland imagery.
The model is trained using a pixel-wise binary cross-entropy loss with class weighting to address severe foreground-background imbalance. Optimization is performed using AdamW with cosine annealing learning rate scheduling. Batch normalization and dropout are employed to improve generalization across seasonal and hydrological variability.
- Encoder: DeepLabV3 with EfficientNet‑B4 backbone (ImageNet pretrained)
- ASPP: Multi-dilation aggregation
- Decoder: UNet style with skip connections
- Attention: SCSE blocks
- Loss: 0.6 × Focal loss (γ=2.0, α=0.6) + 0.4 × Tversky loss (α=0.4, β=0.6)
- Optimizer: Adam with OneCycleLR, AMP enabled
The model is trained for 100 epochs with early stopping based on validation IoU. Evaluation metrics include pixel-wise accuracy, F1 score, precision, recall, and mean Intersection over Union (mIoU). Ablation studies are conducted to assess the impact of SCSE attention, backbone depth, and polarization channel combinations. Results demonstrate that the proposed architecture outperforms baseline UNet and DeepLabV3 models, particularly in detecting small and fragmented logging patches.
python train.py \
--data_dir data/tiles \
--epochs 450 --batch_size 8 \
--lr 3e-4 --max_lr 1e-3 \
--weight_decay 1e-5 \
--pct_start 0.3 --div_factor 25 --final_div_factor 10000 \
--loss focal_tversky --focal_alpha 0.6 --focal_gamma 2.0 \
--tversky_alpha 0.4 --tversky_beta 0.6 \
--amp --save_dir outputs/run_01Paper results:
- Accuracy: 89.55%
- Precision: 0.6741
- Recall: 0.6381
- F1: 0.6556
- IoU: 0.4876
- Dice: 0.6556
python infer.py \
--scene_path data/raw/S1_scene.tif \
--model_ckpt outputs/run_01/best.ckpt \
--bands VV,VH,RATIO \
--tile_size 382 --overlap 32 \
--threshold 0.5 \
--out_raster outputs/run_01/pred_illegal_logging.tifUse scripts/visualize.py to overlay predictions on SAR inputs.
- Seeds: Set for Python, NumPy, Torch
- Logging: Save config, commit hash, environment info
- Docker: Build with CUDA runtime + dependencies for cloud portability
- Optional: Deploy as a Gradio app on Hugging Face Spaces
This project is based on the research presented in:
- Thinh Ha – Beaver Works Summer Institute
- Tanish Khanna – Beaver Works Summer Institute
- Naga Kasam – Beaver Works Summer Institute
- Ruhaan Arya – Beaver Works Summer Institute
- Arush Shangari – Beaver Works Summer Institute
- Ikshit Gupta – Beaver Works Summer Institute
Special thanks to Mr. Scheele (MIT Lincoln Lab), Mr. Amriche (SUNY), and Dr. Xiao (MIT Lincoln Lab) for their guidance, and to the Sentinel‑1/Copernicus program for providing SAR data.