xBD#

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

Bases: NonGeoDataset

xBD dataset.

The xBD dataset is a dataset for building disaster change detection. This dataset object uses the “Challenge training set (~7.8 GB)” and “Challenge test set (~2.6 GB)” data from the xView2 website as the train and test splits. Note, the xView2 website contains other data under the xView2 umbrella that are _not_ included here. E.g. the “Tier3 training data”, the “Challenge holdout set”, and the “full data”.

Dataset format:

  • images are three-channel pngs

  • masks are single-channel pngs where the pixel values represent the class

Dataset classes:

  1. background

  2. no damage

  3. minor damage

  4. major damage

  5. destroyed

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 xBD 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.

Changed in version 0.8: Now returns a single T x C x H x W image, change detection mask.

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.