LoveDA#

class torchgeo.datasets.LoveDA(root='data', split='train', scene=['urban', 'rural'], transforms=None, download=False, checksum=False)[source]#

Bases: NonGeoDataset

LoveDA dataset.

The LoveDA datataset is a semantic segmentation dataset.

Dataset features:

  • 2713 urban scene and 3274 rural scene HSR images, spatial resolution of 0.3m

  • image source is Google Earth platform

  • total of 166768 annotated objects from Nanjing, Changzhou and Wuhan cities

  • dataset comes with predefined train, validation, and test set

  • dataset differentiates between ‘rural’ and ‘urban’ images

Dataset format:

  • images are three-channel pngs with dimension 1024x1024

  • segmentation masks are single-channel pngs

Dataset classes:

  1. background

  2. building

  3. road

  4. water

  5. barren

  6. forest

  7. agriculture

No-data regions assigned with 0 and should be ignored.

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

Added in version 0.2.

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

Initialize a new LoveDA dataset instance.

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

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

  • scene (Sequence[str]) – specify whether to load only ‘urban’, only ‘rural’ or both

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

image and mask at that index with image of dimension 3x1024x1024 and mask of dimension 1024x1024

Return type:

dict[str, Any]

__len__()[source]#

Return the number of datapoints in the dataset.

Returns:

length of dataset

Return type:

int

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

Plot a sample from the dataset.

Parameters:
Returns:

a matplotlib Figure with the rendered sample

Return type:

Figure

__annotate_func__()#

The type of the None singleton.