Potsdam#

class torchgeo.datasets.Potsdam2D(root='data', split='train', transforms=None, checksum=False)[source]#

Bases: NonGeoDataset

Potsdam 2D Semantic Segmentation dataset.

The Potsdam dataset is a dataset for urban semantic segmentation used in the 2D Semantic Labeling Contest - Potsdam. This dataset uses the “4_Ortho_RGBIR.zip” and “5_Labels_all.zip” files to create the train/test sets used in the challenge. The dataset can be requested at the challenge homepage. Note, the server contains additional data for 3D Semantic Labeling which are currently not supported.

Dataset format:

  • images are 4-channel geotiffs

  • masks are 3-channel geotiffs with unique RGB values representing the class

Dataset classes:

  1. Clutter/background

  2. Impervious surfaces

  3. Building

  4. Low Vegetation

  5. Tree

  6. Car

If you use this dataset in your research, please cite the following paper:

Added in version 0.2.

__init__(root='data', split='train', transforms=None, checksum=False)[source]#

Initialize a new Potsdam dataset instance.

Parameters:
  • root (str | PathLike[str]) – root directory where dataset can be found

  • split (str) – one of “train” or “test”

  • 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

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

data and label at that index

Return type:

dict[str, Any]

__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, alpha=0.5)[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

  • alpha (float) – opacity with which to render predictions on top of the imagery

Returns:

a matplotlib Figure with the rendered sample

Return type:

Figure

__annotate_func__()#

The type of the None singleton.