Skip to content

Repository files navigation

🛰️ ConvNeXt-EDL-Deforestation-Amazon

Fourier Domain Adaptation with Evidential Deep Learning for Cross-Domain Deforestation Detection in the Brazilian Amazon

Python PyTorch License: MIT Landsat-8 CUDA

Keywords: deforestation detection, domain adaptation, evidential deep learning, remote sensing, satellite imagery, semantic segmentation, Landsat-8, Amazon rainforest, ConvNeXt, Fourier Domain Adaptation (FDA), uncertainty estimation, unsupervised domain adaptation, land use land cover, LULC, change detection, deep learning, PyTorch, environmental monitoring, PRODES, Brazilian Amazon, computer vision, earth observation


The Problem

Deforestation in the Brazilian Amazon is accelerating — 11,568 km² were cleared in 2022 alone. Satellite-based monitoring with deep learning can detect deforestation at scale, but there's a critical gap:

Supervised models trained on one region fail catastrophically when deployed to a different biome. Adversarial domain adaptation (DANN) adds millions of parameters and suffers from training instability. Deep ensembles provide reliable uncertainty but require 5× the memory and compute.

This project replaces both of these expensive techniques with lightweight, parameter-free alternatives — and achieves state-of-the-art results on one of three domain pairs.


What We Did

We reimplemented and improved a recent deforestation detection system (de Moura et al., Forests 2025) with three key replacements:

Base Paper Component Our Replacement Improvement
DANN (adversarial DA, ~1.2M params) FDA (Fourier Domain Adaptation, 0 params) No adversarial instability, pure frequency-domain
Deep Ensemble (5 models, ~50M params) EDL (Evidential Deep Learning, 1 model) 3.5× less memory, per-pixel uncertainty in 1 pass
Xception/DeepLabv3+ (~54M params) ConvNeXt Hybrid (9.5M params) 6× smaller, modern CNN with depthwise conv

Architecture

Architecture End-to-end pipeline: (1) FDA swaps low-frequency amplitude between source and target domains via FFT — zero learnable parameters; (2) ConvNeXt encoder extracts features through CNN stem + 7×7 depthwise convolution blocks; (3) Evidential decoder produces Dirichlet distribution parameters via Softplus activation, yielding both predictions and uncertainty maps.

Model: FADENet — 9,548,546 parameters

Encoder (HybridEncoder):

  • CNN Stem: Conv2d(14→128) → BN → ReLU → Conv2d(128→256, stride=2) → 32×32
  • Stage 2: Conv2d(256→512, stride=2) → 16×16
  • Bottleneck: 2× ConvNeXt blocks (DWConv 7×7 → BN → PWConv↑4× → GELU → PWConv↓ + residual)

Decoder (EvidentialDecoder):

  • ConvTranspose2d(512→256) → skip connection → Conv2d → BN → ReLU
  • ConvTranspose2d(256→128) → Head: Conv2d(128→2) → Softplus → non-negative evidence
  • Output: Dirichlet parameters α = evidence + 1 → binary segmentation + uncertainty

Study Area

Study Area Three Brazilian biomes used as source/target domains for cross-domain experiments.

Domain Region Biome Image Size Patches (64×64) Years
PA Pará Amazon (dense forest) 1,100×2,600 2,652 2016–2017
RO Rondônia Amazon (open forest) 2,554×5,130 6,240 2016–2017
MA Maranhão Cerrado (savanna) 1,719×1,442 1,144 2017–2018
  • Satellite: Landsat-8 (7 spectral bands × 2 time points = 14 channels)
  • Ground Truth: PRODES (Brazilian Government deforestation monitoring)
  • Class Imbalance: Deforestation covers only 2–3% of pixels

Results

Cross-Domain F1-Score (Mean ± Std, 3 seeds)

Domain Pair Transfer Type Our Result Base Paper Best Δ
PA → RO Within-biome (Amazon → Amazon) 59.6% ± 0.7% 36.3% +23.3 pp
MA → RO Cross-biome (Cerrado → Amazon) 52.2% ± 1.5% 59.1% -6.9 pp
RO → MA Cross-biome (Amazon → Cerrado) 54.7% ± 0.1% 67.8% -13.1 pp

The PA→RO (within-biome) result is our headline finding — a 23.3 percentage point improvement over the base paper's best configuration. For cross-biome transfers (MA↔RO), structural vegetation differences limit frequency-only style adaptation.

Ablation Study (MA→RO, seed 42)

Configuration Best F1
FDA Only 56.5%
No Self-Training 56.5%
Full Pipeline 54.2%
Source-Only (no DA) 51.2%
No FDA 51.2%

Key Finding: FDA alone is optimal. Adding self-training and ProSFDA pseudo-label refinement actually degrades performance — a counterintuitive but reproducible result that we analyze in detail.

Uncertainty Calibration

Metric Value
Uncertainty (correct predictions) 0.2570
Uncertainty (incorrect predictions) 0.3402
Ratio (wrong/right) 1.32×
High-confidence (>90%) accuracy 75.1%
Low-confidence (<60%) accuracy 38.5%

EDL uncertainty is well-calibrated: the model is measurably more uncertain when it's wrong, enabling reliable flagging of unreliable predictions.

Qualitative Predictions

Predictions PA→RO: Satellite image, ground truth (red = deforestation), model prediction, and uncertainty heatmap. High uncertainty correctly concentrates at deforestation boundaries.

Analysis Figures

Domain Comparison Ours vs. base paper F1-scores across all domain pairs.

Ablation Ablation study showing FDA-Only as the optimal configuration.

Uncertainty Analysis Three-panel uncertainty analysis: (left) distribution of epistemic uncertainty for correct vs incorrect predictions; (center) calibration curve; (right) confidence vs uncertainty scatter.


Why This Matters

  1. FDA is better than DANN for remote sensing DA. Zero parameters, zero instability, and it outperforms adversarial training on our strongest domain pair. This has implications for any cross-domain RS task.

  2. EDL provides calibrated uncertainty cheaply. A single forward pass gives per-pixel uncertainty without the 5× cost of deep ensembles. This is critical for operational monitoring where "I don't know" is more valuable than a wrong prediction.

  3. Self-training can hurt. Our ablation conclusively shows that pseudo-label refinement degrades performance when the domain gap is large — a cautionary finding for the UDA community.

  4. Lightweight models compete. 9.5M parameters (6× smaller than the base paper's Xception) achieve the best result on PA→RO. Model size isn't everything.


Getting Started

1. Clone & Install

git clone https://github.com/ZentaCros/convnext-edl-deforestation-amazon.git
cd convnext-edl-deforestation-amazon
pip install -r requirements.txt

Requires Python 3.10+ and a CUDA-capable GPU (tested on NVIDIA RTX 4080, 16 GB VRAM).

2. Download Data

python download_data.py

This downloads the Landsat-8 imagery and PRODES ground truth from Google Drive (~2 GB). The data is from the original paper (de Moura et al., 2025).

3. Run All Experiments (3 domains × 3 seeds + source-only baselines)

python run_experiments.py

This runs 12 experiments sequentially (~16 hours total on RTX 4080).

4. Run Ablation Study

python run_ablation.py

Runs 4 ablation configurations on MA→RO with seed 42.

5. Generate Publication Figures

python generate_figures.py

Creates 6 dark-themed figures in figures/.

6. Uncertainty Analysis

python uncertainty_analysis.py

Computes uncertainty calibration metrics and generates analysis plots.


Repository Structure

convnext-edl-deforestation-amazon/
├── README.md
├── requirements.txt
├── LICENSE
├── models.py              # FADENet (HybridEncoder + EvidentialDecoder)
├── train.py               # Full 4-phase training pipeline with visualization
├── loss.py                # Weighted EDL loss with KL divergence regularization
├── dataset.py             # PyTorch Dataset with FDA style transfer
├── utils.py               # Logging utility
├── download_data.py       # Google Drive data downloader
├── run_experiments.py     # Orchestrator: 3 domains × 3 seeds
├── run_ablation.py        # Ablation: 4 configs on MA→RO
├── generate_figures.py    # 6 publication-quality figures
├── uncertainty_analysis.py # Post-hoc uncertainty calibration
├── figures/               # Generated publication figures
│   ├── architecture.png   # Full architecture diagram
│   ├── methodology.png    # 4-phase training pipeline (4K)
│   ├── study_area_map.png # Brazilian biomes map
│   └── fig1-6_*.png       # Training, comparison, ablation, uncertainty
├── visuals/               # Qualitative prediction panels
│   ├── 07_visual_PA_to_RO_best.png
│   ├── 08_visual_MA_to_RO_best.png
│   └── 09_visual_RO_to_MA_best.png
└── results/               # Experiment data
    ├── master_results.csv      # All 12 experiment F1-scores
    ├── ablation_summary.csv    # 4-config ablation results
    └── uncertainty_stats.csv   # Calibration metrics

Hyperparameters

Parameter Value
Batch size 64
Optimizer AdamW (lr=1e-4, weight_decay=1e-4)
Epochs 50
Loss Weighted EDL (class weights: [0.8, 1.2])
FDA β 0.01 (swap 1% of lowest frequencies)
ProSFDA confidence threshold 0.90
Seeds 42, 123, 456

Training Pipeline

Methodology Four-phase training pipeline repeated each epoch: (1) supervised training on FDA-styled source patches with real labels; (2) test-time BatchNorm adaptation on unlabeled target patches; (3) ProSFDA prototype filtering to generate high-confidence pseudo-labels; (4) self-training on filtered pseudo-labels. Our ablation study shows Phase 1 alone (FDA-Only) is optimal.

Phase Name Description
1 Supervised + FDA Train on source patches styled to look like target (via FDA), using real GT labels
2 Test-Time Adaptation Evaluate on target domain with BatchNorm in train mode (statistics adaptation)
3 ProSFDA Build per-class prototypes from high-confidence (>90%) target predictions
4 Self-Training Fine-tune on filtered pseudo-labels from Phase 3

Note: Our ablation shows Phase 1 alone (FDA-Only) is optimal — Phases 3–4 degrade performance.


Related Work


Citation

If you use this code or build upon this work, please cite:

@misc{azeem2026convnext_edl_deforestation,
  title   = {Fourier Domain Adaptation with Evidential Deep Learning for
             Cross-Domain Deforestation Detection},
  author  = {Muhammad Hamza Azeem},
  year    = {2026},
  url     = {https://github.com/ZentaCros/convnext-edl-deforestation-amazon}
}

Acknowledgments


License

MIT License. See LICENSE for details.

About

Fourier Domain Adaptation + Evidential Deep Learning for source-free cross-domain deforestation detection in the Brazilian Amazon using Landsat-8 satellite imagery. ConvNeXt encoder (9.5M params) with per-pixel uncertainty estimation. PyTorch implementation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages