GeoBench Data Modules#
Base Classes#
- class geobench_v2.datamodules.GeoBenchClassificationDataModule[source]#
Bases:
GeoBenchDataModuleGeoBench Classification DataModule.
By default, will yield a batch of images and their corresponding labels as a dictionary with keys ‘image’ and ‘label’.
- __init__(dataset_class, img_size, band_order, batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations='default', eval_augmentations='default', pin_memory=False, **kwargs)[source]#
Initialize GeoBench Classification DataModule.
- Parameters:
dataset_class (Dataset) – Dataset class to use in the DataModule
img_size (int) – Desired image input size for the model
band_order (Sequence[float | str] | dict[str, Sequence[float | str]]) – band order of the image sample to be returned
batch_size (int) – Batch size during training
eval_batch_size (int) – Batch size during evaluation, can usually be larger than batch_size, to speed up evaluation.
num_workers (int) – Number of workers for dataloaders
collate_fn (Callable | None) – Collate function that can reformat samples to the needs of the model.
train_augmentations (Callable | None | str) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Callable | None | str) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – whether to pin memory in dataloaders
**kwargs (Any) – Additional keyword arguments passed to
dataset_class
- define_augmentations()[source]#
Define augmentations for the dataset and task, that are applied on a batch of data.
Augmentations will be applied in on_after_batch_transfer in the LightningDataModule.
- setup_image_size_transforms()[source]#
Setup image resizing transforms for train, val, test.
Image resizing and normalization happens on dataset level on individual data samples.
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
- class geobench_v2.datamodules.GeoBenchSegmentationDataModule[source]#
Bases:
GeoBenchDataModuleGeoBench Segmentation DataModule.
By default, will yield a batch of images and their corresponding masks as a dictionary with keys ‘image’ and ‘mask’.
- __init__(dataset_class, img_size, band_order, batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations='default', eval_augmentations='default', pin_memory=False, **kwargs)[source]#
Initialize GeoBench Segmentation DataModule.
- Parameters:
dataset_class (Dataset) – Dataset class to use in the DataModule
img_size (int) – Desired image input size for the model
band_order (Sequence[float | str] | dict[str, Sequence[float | str]]) – band order of the image sample to be returned
batch_size (int) – Batch size during training
eval_batch_size (int) – Batch size during evaluation, can usually be larger than batch_size, to speed up evaluation.
num_workers (int) – Number of workers for dataloaders
collate_fn (Callable | None) – Collate function that can reformat samples to the needs of the model.
train_augmentations (Callable | None | str) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Callable | None | str) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – whether to pin memory in dataloaders
**kwargs (Any) – Additional keyword arguments passed to
dataset_class
- define_augmentations()[source]#
Define augmentations for the dataset and task, that are applied on a batch of data.
Augmentations will be applied in on_after_batch_transfer in the LightningDataModule.
- setup_image_size_transforms()[source]#
Setup image resizing transforms for train, val, and test.
Image resizing and normalization happens on the dataset level on individual data samples.
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
- class geobench_v2.datamodules.GeoBenchObjectDetectionDataModule[source]#
Bases:
GeoBenchDataModuleGeoBench Object Detection DataModule.
By default, will yield a batch of images and their corresponding bounding boxes and labels as a dictionary with keys ‘image’, ‘boxes_xyxy’, and ‘labels’.
- __init__(dataset_class, img_size, band_order, batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations='default', eval_augmentations='default', pin_memory=False, **kwargs)[source]#
Initialize GeoBench Object Detection DataModule.
- Parameters:
dataset_class (Dataset) – Dataset class to use in the DataModule
img_size (int) – Desired image input size for the model
band_order (Sequence[float | str] | dict[str, Sequence[float | str]]) – band order of the image sample to be returned
batch_size (int) – Batch size during training
eval_batch_size (int) – Batch size during evaluation, can usually be larger than batch_size, to speed up evaluation.
num_workers (int) – Number of workers for dataloaders
collate_fn (Callable | None) – Collate function that can reformat samples to the needs of the model.
train_augmentations (Callable | None | str) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Callable | None | str) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – whether to pin memory in dataloaders
**kwargs (Any) – Additional keyword arguments passed to
dataset_class
- define_augmentations()[source]#
Define augmentations for the dataset and task, that are applied on a batch of data.
Augmentations will be applied in on_after_batch_transfer in the LightningDataModule.
- setup_image_size_transforms()[source]#
Setup image resizing transforms for train, val, test.
Image resizing and normalization happens on dataset level on individual data samples.
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
- class geobench_v2.datamodules.GeoBenchDataModule[source]#
Bases:
LightningDataModule,ABCGeoBench DataModule.
- __init__(dataset_class, img_size, band_order, batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations='default', eval_augmentations='default', pin_memory=False, **kwargs)[source]#
Initialize GeoBench DataModule.
- Parameters:
dataset_class (Dataset) – Dataset class to use in the DataModule
img_size (int) – Desired image input size for the model
band_order (Sequence[float | str] | dict[str, Sequence[float | str]]) – band order of the image sample to be returned
batch_size (int) – Batch size during training
eval_batch_size (int) – Batch size during evaluation, can usually be larger than batch_size, to speed up evaluation.
num_workers (int) – Number of workers for dataloaders
collate_fn (Callable | None) – Collate function that can reformat samples to the needs of the model.
train_augmentations (Callable | None | str) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should not include normalization, normalization happens on the dataset level for each sample, while geometric and color augmentations will be applied on a batch of data
eval_augmentations (Callable | None | str) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should not include normalization, normalization happens on the dataset level for each sample, while geometric and color augme]ntations will be applied on a batch of data
pin_memory (bool) – whether to pin memory in dataloaders
**kwargs (Any) – Additional keyword arguments passed to
dataset_class
- setup(stage=None)[source]#
Setup data for train, val, test.
- Parameters:
stage (str | None) – One of ‘fit’, ‘validate’, ‘test’, or ‘predict’.
- abstractmethod setup_image_size_transforms()[source]#
Setup image resizing transforms for train, val, test.
Image resizing and normalization happens on dataset level on individual data samples.
- abstractmethod load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
- abstractmethod define_augmentations()[source]#
Define augmentations for the dataset and task, that are applied on a batch of data.
Augmentations will be applied in on_after_batch_transfer in the LightningDataModule.
- visualize_geospatial_distribution(split_column='tortilla:data_split', buffer_degrees=5.0, sample_fraction=None, scale='50m', alpha=0.5, s=10)[source]#
Visualize the geospatial distribution of dataset samples on a map.
Creates a plot showing the geographic locations of samples, colored by dataset split (train, validation, test, extra_test). This helps to understand the spatial distribution and potential geographic biases in the dataset.
- Parameters:
split_column (str) – Column name in the metadata DataFrame that indicates the dataset split.
buffer_degrees (float) – Buffer around the data extent in degrees.
sample_fraction (float | None) – Optional fraction of samples to plot (0.0-1.0) for performance with large datasets.
scale (Literal['10m', '50m', '110m']) – Scale of cartopy features (e.g., ‘10m’, ‘50m’, ‘110m’).
alpha (float) – Transparency of plotted points.
s (float) – Size of plotted points.
- Returns:
A matplotlib Figure object with the geospatial distribution plot.
- Return type:
Figure
- abstractmethod visualize_geolocation_distribution()[source]#
Visualize the geolocation distribution of the dataset.
BigEarthNetV2#
- class geobench_v2.datamodules.GeoBenchBENV2DataModule[source]#
Bases:
GeoBenchClassificationDataModuleGeoBench BigEarthNetV2 Data Module.
- __init__(img_size=120, band_order={'s1': ('VV', 'VH'), 's2': ('B01', 'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B8A', 'B09', 'B11', 'B12')}, batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench BigEarthNetV2 dataset module.
- Parameters:
img_size (int) – Image size
band_order (Sequence[float | str] | dict[str, Sequence[float | str]]) – band order
batch_size (int) – Batch size
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
eval_augmentations (Module | None) – augmentations for validation and test splits
train_augmentations (Module | None) – augmentations for train split
pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.benv2.GeoBenchBENV2
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
- visualize_batch(batch=None, split='train')[source]#
Visualize a batch of data.
- Parameters:
- Returns:
The matplotlib figure and the batch of data
- Raises:
AssertionError – If bands needed for plotting are missing
- Return type:
- visualize_geospatial_distribution(split_column='tortilla:data_split', buffer_degrees=5.0, sample_fraction=None, scale='50m', alpha=0.5, s=0.5)[source]#
Visualize the geospatial distribution of dataset samples on a map.
- Parameters:
split_column (str) – Column name in the metadata DataFrame that indicates the dataset split.
buffer_degrees (float) – Buffer around the data extent in degrees.
sample_fraction (float | None) – Optional fraction of samples to plot (0.0-1.0) for performance with large datasets.
scale (Literal['10m', '50m', '110m']) – Scale of cartopy features (e.g., ‘10m’, ‘50m’, ‘110m’).
alpha (float) – Transparency of plotted points.
s (float) – Size of plotted points.
FLAIR2#
- class geobench_v2.datamodules.GeoBenchFLAIR2DataModule[source]#
Bases:
GeoBenchSegmentationDataModuleGeoBench FLAIR2 Data Module.
- __init__(img_size=512, band_order={'aerial': ['red', 'green', 'blue', 'nir'], 'elevation': ['elevation']}, batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench FLAIR2 DataModule.
- Parameters:
img_size (int) – Image size
band_order (Sequence[float | str]) – The order of bands to return in the sample
batch_size (int) – Batch size during training
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.flair2.GeoBenchFLAIR2
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
BioMassters#
- class geobench_v2.datamodules.GeoBenchBioMasstersDataModule[source]#
Bases:
GeoBenchSegmentationDataModuleGeoBench BioMassters Data Module.
- __init__(img_size=256, band_order={'s1': {'VH_asc', 'VH_desc', 'VV_asc', 'VV_desc'}, 's2': {'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B11', 'B12', 'B8A'}}, batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench BioMassters DataModule.
- Parameters:
img_size (int) – Image size, original size is 256
band_order (Sequence[float | str] | dict[str, Sequence[float | str]]) – The order of bands to return in the sample
batch_size (int) – Batch size
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Augmentations to apply during training
eval_augmentations (Module | None) – Augmentations to apply during evaluation
pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.biomassters.GeoBenchBioMassters
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
CaFFe#
- class geobench_v2.datamodules.GeoBenchCaFFeDataModule[source]#
Bases:
GeoBenchSegmentationDataModuleGeoBench CaFFe Data Module.
- __init__(img_size=512, band_order=('gray',), batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench CaFFe dataset module.
- Parameters:
img_size (int) – Image size
band_order (Sequence[float | str]) – The order of bands to return in the sample
batch_size (int) – Batch size during
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.caffe.GeoBenchCaFFe
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
- visualize_geospatial_distribution(split_column='tortilla:data_split', buffer_degrees=5.0, sample_fraction=None, scale='50m', alpha=0.7, s=5)[source]#
Visualize the geospatial distribution of CaFFe samples on polar projections.
CaFFe dataset contains glacier data from high northern and southern latitudes, focusing on Greenland/Canada in the north and West Antarctica in the south. This creates a split view with zoomed polar projections for each region.
- Parameters:
split_column (str) – Column name in the metadata DataFrame that indicates the dataset split.
buffer_degrees (float) – Buffer around the data extent in degrees.
sample_fraction (float | None) – Optional fraction of samples to plot (0.0-1.0) for performance.
scale (Literal['10m', '50m', '110m']) – Scale of cartopy features (e.g., ‘10m’, ‘50m’, ‘110m’).
alpha (float) – Transparency of plotted points.
s (float) – Size of plotted points.
- Returns:
A matplotlib Figure object with the geospatial distribution plot.
- Return type:
Figure
CloudSen12#
- class geobench_v2.datamodules.GeoBenchCloudSen12DataModule[source]#
Bases:
GeoBenchSegmentationDataModuleGeoBench CloudSen12 Data Module.
- __init__(img_size=512, band_order=['B01', 'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B8A', 'B09', 'B11', 'B12'], batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench CloudSen12 DataModule.
- Parameters:
img_size (int) – Image size
band_order (Sequence[float | str]) – The order of bands to return in the sample
batch_size (int) – Batch size during training
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.cloudsen12.GeoBenchCloudSen12
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
Dynamic EarthNet#
- class geobench_v2.datamodules.GeoBenchDynamicEarthNetDataModule[source]#
Bases:
GeoBenchSegmentationDataModuleGeoBench DynamicEarthNet Data Module.
- __init__(img_size=512, band_order={'planet': ('b', 'g', 'r', 'nir'), 's2': ('B01', 'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B8A', 'B10', 'B11', 'B12')}, batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench DynamicEarthNet DataModule.
- Parameters:
img_size (int) – Image size
band_order (Sequence[float | str]) – The order of bands to return in the sample
batch_size (int) – Batch size during training
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.dynamic_earthnet.GeoBenchDynamicEarthNet
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
- visualize_geospatial_distribution(split_column='tortilla:data_split', buffer_degrees=5.0, sample_fraction=None, scale='50m', alpha=0.8, s=10)[source]#
Visualize the geospatial distribution of dataset samples on a map.
Creates a plot showing the geographic locations of samples, colored by dataset split (train, validation, test, extra_test). This helps to understand the spatial distribution and potential geographic biases in the dataset.
- Parameters:
split_column (str) – Column name in the metadata DataFrame that indicates the dataset split.
buffer_degrees (float) – Buffer around the data extent in degrees.
sample_fraction (float | None) – Optional fraction of samples to plot (0.0-1.0) for performance with large datasets.
scale (Literal['10m', '50m', '110m']) – Scale of cartopy features (e.g., ‘10m’, ‘50m’, ‘110m’).
alpha (float) – Transparency of plotted points
s (float) – Size of plotted points.
- Returns:
A matplotlib Figure object with the geospatial distribution plot.
- Return type:
Figure
EverWatch#
- class geobench_v2.datamodules.GeoBenchEverWatchDataModule[source]#
Bases:
GeoBenchObjectDetectionDataModuleGeoBench EverWatch Data Module.
- __init__(img_size=512, band_order=('red', 'green', 'blue'), batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=<function everwatch_collate_fn>, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench DOTAV2 dataset module.
- Parameters:
img_size (int) – Image size
band_order (Sequence[float | str]) – The order of bands to return in the sample
batch_size (int) – Batch size during
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.everwatch.GeoBenchEverWatch
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
Fields of The World (FoTW)#
- class geobench_v2.datamodules.GeoBenchFieldsOfTheWorldDataModule[source]#
Bases:
GeoBenchSegmentationDataModuleGeoBench Fields of the World Data Module.
- __init__(img_size=256, band_order=('red', 'green', 'blue', 'nir'), batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench Fields of the World DataModule.
- Parameters:
img_size (int) – Image size
band_order (Sequence[float | str]) – The order of bands to return in the sample
batch_size (int) – Batch size during training
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
GeoBenchFieldsOfTheWorld.
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
- visualize_batch(batch=None, split='train')[source]#
Visualize a batch of data from the Fields of the World dataset.
- Parameters:
- Returns:
The matplotlib figure and the batch of data
- Raises:
AssertionError – If bands needed for plotting are missing
- Return type:
KuroSiwo#
- class geobench_v2.datamodules.GeoBenchKuroSiwoDataModule[source]#
Bases:
GeoBenchSegmentationDataModuleGeoBench KuroSiwo Data Module.
- __init__(img_size=224, band_order={'dem': ['dem'], 'sar': ['vv', 'vh']}, batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench KuroSiwo dataset module.
- Parameters:
img_size (int) – Image size
band_order (Sequence[float | str]) – The order of bands to return in the sample
batch_size (int) – Batch size during training
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.kuro_siwo.GeoBenchKuroSiwo
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
- visualize_batch(batch=None, split='train')[source]#
Visualize a batch of data.
- Parameters:
- Returns:
The matplotlib figure and the batch of data
- Raises:
AssertionError – If bands needed for plotting are missing
- Return type:
PASTIS#
- class geobench_v2.datamodules.GeoBenchPASTISDataModule[source]#
Bases:
GeoBenchSegmentationDataModuleGeoBench PASIS Data Module.
- __init__(img_size=128, band_order={'s1_asc': ('VV_asc', 'VH_asc', 'VV/VH_asc'), 's1_desc': ('VV_desc', 'VH_desc', 'VV/VH_desc'), 's2': ('B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B8A', 'B11', 'B12')}, batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench PASIS DataModule.
- Parameters:
img_size (int) – Image size
band_order (Sequence[float | str]) – The order of bands to return in the sample
batch_size (int) – Batch size during training
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for:class:~geobench_v2.datasets.pastis.GeoBenchPASTIS.
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
- visualize_batch(batch=None, split='train')[source]#
Visualize a batch of data.
- Parameters:
- Returns:
The matplotlib figure and the batch of data
- Raises:
AssertionError – If bands needed for plotting are missing
- Return type:
PASTIS Panoptic
- class geobench_v2.datamodules.GeoBenchPASTISPanopticDataModule[source]#
Bases:
GeoBenchObjectDetectionDataModuleGeoBench PASTIS Data Module for Panoptic Segmentation.
- __init__(img_size=128, band_order={'s1_asc': ('VV_asc', 'VH_asc', 'VV/VH_asc'), 's1_desc': ('VV_desc', 'VH_desc', 'VV/VH_desc'), 's2': ('B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B8A', 'B11', 'B12')}, batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench PASIS DataModule.
- Parameters:
img_size (int) – Image size
band_order (Sequence[float | str]) – The order of bands to return in the sample
batch_size (int) – Batch size during training
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments to
GeoBenchPASTIS.
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
- visualize_batch(batch=None, split='train')[source]#
Visualize a batch of data.
- Parameters:
- Returns:
The matplotlib figure and the batch of data
- Raises:
AssertionError – If bands needed for plotting are missing
- Return type:
SpaceNet2#
- class geobench_v2.datamodules.GeoBenchSpaceNet2DataModule[source]#
Bases:
GeoBenchSegmentationDataModuleGeoBench SpaceNet2 Data Module.
- __init__(img_size=512, band_order={'pan': ('pan',), 'worldview': ('coastal', 'blue', 'green', 'yellow', 'red', 'red_edge', 'nir1', 'nir2')}, batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench SpaceNet2 dataset module.
- Parameters:
img_size (int) – Image size, created patches are of size 512
band_order (Sequence[float | str]) – The order of bands to return in the sample
batch_size (int) – Batch size during training
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.spacenet2.GeoBenchSpaceNet2
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
- visualize_batch(batch=None, split='train')[source]#
Visualize a batch of data.
- Parameters:
- Returns:
The matplotlib figure and the batch of data
- Raises:
AssertionError – If bands needed for plotting are missing
- Return type:
SpaceNet6#
- class geobench_v2.datamodules.GeoBenchSpaceNet6DataModule[source]#
Bases:
GeoBenchSegmentationDataModuleGeoBench SpaceNet6 Data Module.
- __init__(img_size=450, band_order={'rgbn': ('red', 'green', 'blue', 'nir'), 'sar': ('hh', 'hv', 'vv', 'vh')}, batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench SpaceNet6 dataset module.
- Parameters:
img_size (int) – Image size, in geobench version patches of 450
band_order (dict[str, Sequence[float | str]]) – The order of bands to return in the sample
batch_size (int) – Batch size during training
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.spacenet6.GeoBenchSpaceNet6
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
SpaceNet7#
- class geobench_v2.datamodules.GeoBenchSpaceNet7DataModule[source]#
Bases:
GeoBenchSegmentationDataModuleGeoBench SpaceNet7 Data Module.
- __init__(img_size=512, band_order=('red', 'green', 'blue'), batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench SpaceNet7 dataset module.
- Parameters:
img_size (int) – Image size, created patches are of size 512
band_order (Sequence[float | str]) – The order of bands to return in the sample
batch_size (int) – Batch size during training
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.spacenet7.GeoBenchSpaceNet7
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
- visualize_batch(batch=None, split='train')[source]#
Visualize a batch of data.
- Parameters:
- Returns:
The matplotlib figure and the batch of data
- Raises:
AssertionError – If bands needed for plotting are missing
- Return type:
SpaceNet8#
- class geobench_v2.datamodules.GeoBenchSpaceNet8DataModule[source]#
Bases:
GeoBenchSegmentationDataModuleGeoBench SpaceNet8 Data Module.
- __init__(img_size=512, band_order=('red', 'green', 'blue'), batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench SpaceNet8 dataset module.
- Parameters:
img_size (int) – Image size, created patches are of size 512
band_order (Sequence[float | str]) – The order of bands to return in the sample
batch_size (int) – Batch size during training
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for the dataset class
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
TreeSatAI#
- class geobench_v2.datamodules.GeoBenchTreeSatAIDataModule[source]#
Bases:
GeoBenchClassificationDataModuleGeoBench TreeSatAI Data Module.
- __init__(img_size=304, band_order={'aerial': ['red', 'green', 'blue', 'nir'], 's1': ['vv', 'vh', 'vv/vh'], 's2': ['B02', 'B03', 'B04', 'B08', 'B05', 'B06', 'B07', 'B8A', 'B11', 'B12', 'B01', 'B09']}, batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench TreeSatAI dataset module.
- Parameters:
img_size (int) – Image size originally 304
band_order (Sequence[float | str]) – The order of bands to return in the sample
batch_size (int) – Batch size
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Training augmentations
eval_augmentations (Module | None) – Evaluation augmentations
pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.treesatai.GeoBenchTreeSatAI
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
- visualize_geospatial_distribution(split_column='tortilla:data_split', buffer_degrees=2.0, scale='50m', alpha=0.5, s=0.5)[source]#
Visualize the geospatial distribution of dataset samples on a map.
Creates a plot showing the geographic locations of samples, colored by dataset split (train, validation, test). This helps to understand the spatial distribution and potential geographic biases in the dataset.
- Parameters:
split_column – Column name in the metadata DataFrame that indicates the dataset split.
buffer_degrees (float) – Buffer around the data extent in degrees
sample_fraction – Fraction of samples to plot (0.0-1.0) for performance with large datasets
scale (Literal['10m', '50m', '110m']) – Scale of cartopy features (e.g., ‘10m’, ‘50m’, ‘110m’)
alpha (float) – Transparency of plotted points
s (float) – Size of plotted points
Burn Scars#
- class geobench_v2.datamodules.GeoBenchBurnScarsDataModule[source]#
Bases:
GeoBenchSegmentationDataModuleGeoBench Burn Scars Data Module.
- __init__(img_size=512, band_order=['B02', 'B03', 'B04', 'B8A', 'B11', 'B12'], batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=None, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench Burn Scars dataset module.
- Parameters:
img_size (int) – Image size
band_order (Sequence[float | str]) – The order of bands to return in the sample
batch_size (int) – Batch size during
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.burn_scars.GeoBenchBurnScars
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame
NZCattle#
- class geobench_v2.datamodules.GeoBenchNZCattleDataModule[source]#
Bases:
GeoBenchObjectDetectionDataModuleGeoBench nzCattle Data Module.
- __init__(img_size=512, band_order=('red', 'green', 'blue'), batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=<function nzcattle_collate_fn>, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench nzCattle dataset module.
- Parameters:
img_size (int) – Image size
band_order (Sequence[float | str]) – The order of bands to return, defaults to [‘red’, ‘green’, ‘blue’], if one would specify [‘red’, ‘green’, ‘blue’, ‘blue’], the dataset would return images with 4 channels in that order. This is useful for models that expect a certain band order, or test the impact of band order on model performance.
batch_size (int) – Batch size during
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.nzcattle.GeoBenchNZCattle
Substation#
- class geobench_v2.datamodules.GeoBenchSubstationDataModule[source]#
Bases:
GeoBenchObjectDetectionDataModuleGeoBench Substation Data Module.
- __init__(img_size=228, band_order=['B01', 'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B8A', 'B09', 'B10', 'B11', 'B12'], batch_size=32, eval_batch_size=64, num_workers=0, collate_fn=<function substation_collate_fn>, train_augmentations=None, eval_augmentations=None, pin_memory=False, **kwargs)[source]#
Initialize GeoBench Substation dataset module.
- Parameters:
img_size (int) – Image size
band_order (Sequence[float | str]) – The order of bands to return, defaults to [‘red’, ‘green’, ‘blue’], if one would specify [‘red’, ‘green’, ‘blue’, ‘blue’], the dataset would return images with 4 channels in that order. This is useful for models that expect a certain band order, or test the impact of band order on model performance.
batch_size (int) – Batch size during
eval_batch_size (int) – Evaluation batch size
num_workers (int) – Number of workers
collate_fn (Callable | None) – Collate function
train_augmentations (Module | None) – Transforms/Augmentations to apply during training, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.eval_augmentations (Module | None) – Transforms/Augmentations to apply during evaluation, they will be applied at the sample level and should include normalization. See
define_augmentations()for the default transformation.pin_memory (bool) – Pin memory
**kwargs (Any) – Additional keyword arguments for
geobench_v2.datasets.substation.GeoBenchSubstation
- load_metadata()[source]#
Load metadata file.
- Returns:
pandas DataFrame with metadata.
- Return type:
DataFrame