Seasonal Contrast#
- class torchgeo.datasets.SeasonalContrastS2(root='data', version='100k', seasons=1, bands=('B4', 'B3', 'B2'), transforms=None, download=False, checksum=False)[source]#
Bases:
NonGeoDatasetSentinel 2 imagery from the Seasonal Contrast paper.
The Seasonal Contrast imagery dataset contains Sentinel 2 imagery patches sampled from different points in time around the 10k most populated cities on Earth.
Dataset features:
Two versions: 100K and 1M patches
12 band Sentinel 2 imagery from 5 points in time at each location
If you use this dataset in your research, please cite the following paper:
- all_bands: tuple[str, ...] = ('B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B8A', 'B9', 'B11', 'B12')#
Names of all available bands in the dataset
- __init__(root='data', version='100k', seasons=1, bands=('B4', 'B3', 'B2'), transforms=None, download=False, checksum=False)[source]#
Initialize a new SeasonalContrastS2 instance.
Added in version 0.5: The seasons parameter.
- Parameters:
root (str | PathLike[str]) – root directory where dataset can be found
version (str) – one of “100k” or “1m” for the version of the dataset to use
seasons (int) – number of seasonal patches to sample per location, 1–5
transforms (Callable[[dict[str, Any]], dict[str, Any]] | None) – a function/transform that takes input sample and its target as entry and returns a transformed version
download (bool) – if True, download dataset and store it in the root directory
checksum (bool) – if True, check the MD5 of the downloaded files (may be slow)
- Raises:
AssertionError – if
versionargument is invalidDatasetNotFoundError – If dataset is not found and download is False.
- __getitem__(index)[source]#
Return an index within the dataset.
- Parameters:
index (int) – index to return
- Returns:
sample with an “image” in SCxHxW format where S is the number of seasons
- Return type:
Changed in version 0.5: Image shape changed from 5xCxHxW to SCxHxW
- __len__()[source]#
Return the number of data points in the dataset.
- Returns:
length of the dataset
- Return type:
- plot(sample, show_titles=True, suptitle=None)[source]#
Plot a sample from the dataset.
- Parameters:
- Returns:
a matplotlib Figure with the rendered sample
- Raises:
RGBBandsMissingError – If bands does not include all RGB bands.
ValueError – if sample contains a “prediction” key
- Return type:
Added in version 0.2.
- __annotate_func__()#
The type of the None singleton.