GeoBench Flair2#

Intro#

FLAIR2 (French Land cover from Aerospace ImageRy) (Garioud et al. 2023) is a large-scale dataset for semantic segmentation from multi-source optical imagery. The dataset provides comprehensive land cover classification across diverse French landscapes, combining aerial photography with Sentinel-2 satellite imagery to enable multi-scale and multi-temporal analysis for improved land cover mapping accuracy.

Dataset Characteristics#

  • Modalities:

    • Very high-resolution aerial imagery (RGB + NIR)

    • Digital Elevation Model (DEM)

  • Spatial Resolution:

    • Aerial: 0.2m per pixel

  • Spectral Bands:

    • Aerial: RGB + NIR (4 channels)

  • Image Dimensions: 512x512 pixels per patch

  • Labels: 13-class land cover semantic segmentation

    • Building, Previous surface, Impervious surface, Bare soil, Water, Coniferous, Deciduous, Brushwood, Vineyard, Herbaceous vegetation, Agricultural land, Plowed land, Other

GeoBenchV2 Processing Pipeline#

Preprocessing Steps#

  1. Split Generation:

    • Use the original train/val/test splits that are defined here

  2. Dataset Subsampling:

    • The final version consists of

      • 4,000 training samples

      • 1,000 validation samples

      • 2,000 test samples

References#

  1. Garioud, A., Peillet, S., Bookjans, E., Giordano, S., & Wattrelos, B. (2023). FLAIR #2: textural and temporal information for semantic segmentation from multi-source optical imagery dataset. arXiv preprint arXiv:2305.14467.

[1]:
import os
from pathlib import Path

import torch

from geobench_v2.datamodules import GeoBenchFLAIR2DataModule
from geobench_v2.datasets import GeoBenchFLAIR2
from geobench_v2.datasets.normalization import SatMAENormalizer, ZScoreNormalizer
from geobench_v2.datasets.visualization_util import (
    compare_normalization_methods,
    compute_batch_histograms,
    plot_batch_histograms,
    plot_channel_histograms,
    visualize_segmentation_target_statistics,
)

%load_ext autoreload
%autoreload 2
[2]:
DATA_ROOT = Path("../../data/flair2")

STATS_SATMAE_PATH = os.path.join(DATA_ROOT, "flair2_stats_satmae.json")
STATS_CLIP_RESCALE_PATH = os.path.join(DATA_ROOT, "flair2_stats_clip_rescale.json")
[3]:
band_order = GeoBenchFLAIR2.band_default_order

datamodule = GeoBenchFLAIR2DataModule(
    img_size=256,
    batch_size=4,
    num_workers=4,
    root=DATA_ROOT,
    band_order=band_order,
    data_normalizer=torch.nn.Identity(),  # we do custom normalization in the tutorial
)
datamodule.setup("fit")
Using provided pre-initialized normalizer instance: Identity
Using provided pre-initialized normalizer instance: Identity
[4]:
sample_dist_fig = datamodule.visualize_geospatial_distribution()
../_images/dataset_notebooks_flair2_4_0.png

Dataset Statistics#

Computed over the training dataset.

Image Statistics#

[5]:
fig = plot_channel_histograms(STATS_SATMAE_PATH)
../_images/dataset_notebooks_flair2_7_0.png
../_images/dataset_notebooks_flair2_7_1.png

Target Statistics#

[6]:
fig = visualize_segmentation_target_statistics(STATS_SATMAE_PATH, "FLAIR2")
../_images/dataset_notebooks_flair2_9_0.png

Raw Batch Statistics#

[7]:
# Get a batch of data from the dataloader
train_dataloader = datamodule.train_dataloader()
raw_batch = next(iter(train_dataloader))

raw_batch_stats = compute_batch_histograms(raw_batch, n_bins=100)


raw_figs = plot_batch_histograms(
    raw_batch_stats, band_order, title_suffix=" (Raw Data)"
)
raw_figs
[7]:
[<Figure size 1200x500 with 1 Axes>, <Figure size 1200x500 with 1 Axes>]
../_images/dataset_notebooks_flair2_11_1.png
../_images/dataset_notebooks_flair2_11_2.png

Effect of Normalization Schemes#

[9]:
zscore_normalizer = ZScoreNormalizer(STATS_CLIP_RESCALE_PATH, band_order)
satmae_normalizer = SatMAENormalizer(STATS_SATMAE_PATH, band_order)
[10]:
norm_fig, normalized_batches = compare_normalization_methods(
    raw_batch, [zscore_normalizer, satmae_normalizer], datamodule
)
../_images/dataset_notebooks_flair2_14_0.png

Visualize Batch Data#

[11]:
fig, batch = datamodule.visualize_batch()
../_images/dataset_notebooks_flair2_16_0.png