Fine-tuning Geospatial Foundation Models (Prithvi, TerraMind) for building footprint segmentation from Sentinel-2 using TerraTorch — Algiers case study
# 🛰️ TerraTorch Building Segmentation
> **Fine-tuning Geospatial Foundation Models (Prithvi, TerraMind) for building footprint segmentation from Sentinel-2 imagery using TerraTorch — Algiers, Algeria case study.**
---
## Table of Contents
- Overview
- Why Foundation Models?
- Architecture
- Results
- Installation
- Quick Start
- Configuration
- Project Structure
- Relation to UrbanGraphSAGE
- Citation
- Acknowledgements
- License
---
## Overview
This project fine-tunes **Geospatial Foundation Models** (GFMs) for building footprint segmentation from Sentinel-2 satellite imagery over Algiers, Algeria. We leverage TerraTorch — an open-source toolkit built on PyTorch Lightning and TorchGeo — to efficiently adapt pretrained GFM backbones to our downstream segmentation task.
### Motivation
Foundation models pretrained on massive EO datasets encode rich spectral-spatial representations. Fine-tuning them for specific downstream tasks requires far fewer labeled samples than training from scratch — critical for underrepresented regions like North Africa where annotated datasets are scarce.
### Key Features
- 🧠 **Multiple GFM backbones:** Prithvi, TerraMind, SatMAE, ScaleMAE via TerraTorch model factories
- 🔧 **Flexible decoders:** UperNet, FPN, and segmentation decoders from SMP and mmsegmentation
- 📊 **Systematic comparison:** GFM fine-tuning vs. training from scratch vs. ImageNet transfer
- ⚡ **CLI + notebook workflows:** Launch experiments via YAML configs or Jupyter notebooks
- 🗺️ **Algiers case study:** Sentinel-2 building segmentation in an underrepresented urban area
---
## Why Foundation Models?
| Approach | Labeled Data Needed | Pretraining Data | Spectral Support | Transfer Quality |
|----------|-------------------|------------------|------------------|-----------------|
| From Scratch (U-Net) | High | None | All bands | ❌ No transfer |
| ImageNet Transfer | Medium | RGB natural images | 3 bands only | ⚠️ Domain gap |
| **GFM Fine-tuning** | ** …