Seasonal Contrast#

class torchgeo.datasets.SeasonalContrastS2(root='data', version='100k', seasons=1, bands=('B4', 'B3', 'B2'), transforms=None, download=False, checksum=False)[source]#

Bases: NonGeoDataset

Sentinel 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

rgb_bands: tuple[str, ...] = ('B4', 'B3', 'B2')#

Names of RGB 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

  • bands (Sequence[str]) – list of bands to load

  • 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:
__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:

dict[str, Any]

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:

int

plot(sample, show_titles=True, suptitle=None)[source]#

Plot a sample from the dataset.

Parameters:
  • sample (dict[str, Any]) – a sample returned by __getitem__()

  • show_titles (bool) – flag indicating whether to show titles above each panel

  • suptitle (str | None) – optional string to use as a suptitle

Returns:

a matplotlib Figure with the rendered sample

Raises:
Return type:

Figure

Added in version 0.2.

__annotate_func__()#

The type of the None singleton.