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#
Split Generation:
Use the original train/val/test splits that are defined here
Dataset Subsampling:
The final version consists of
4,000 training samples
1,000 validation samples
2,000 test samples
References#
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()
Dataset Statistics#
Computed over the training dataset.
Image Statistics#
[5]:
fig = plot_channel_histograms(STATS_SATMAE_PATH)
Target Statistics#
[6]:
fig = visualize_segmentation_target_statistics(STATS_SATMAE_PATH, "FLAIR2")
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>]
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
)
Visualize Batch Data#
[11]:
fig, batch = datamodule.visualize_batch()