ade20k#

ADE20K Semantic segmentation and scene parsing dataset.

Please refer to the ADE20K dataset for more details about this dataset.

Classes

ADE20k

PyTorch Dataset for ADE20k.

StreamingADE20k

Implementation of the ADE20k dataset using StreamingDataset.

class composer.datasets.ade20k.ADE20k(datadir, split='train', both_transforms=None, image_transforms=None, target_transforms=None)[source]#

Bases: torch.utils.data.dataset.Dataset

PyTorch Dataset for ADE20k.

Parameters
  • datadir (str) โ€“ the path to the ADE20k folder.

  • split (str) โ€“ the dataset split to use, either โ€˜trainโ€™, โ€˜valโ€™, or โ€˜testโ€™. Default: 'train'.

  • both_transforms (Module) โ€“ transformations to apply to the image and target simultaneously. Default: None.

  • image_transforms (Module) โ€“ transformations to apply to the image only. Default: None.

  • target_transforms (Module) โ€“ transformations to apply to the target only. Default None.

class composer.datasets.ade20k.PadToSize(size, fill=0)[source]#

Bases: torch.nn.modules.module.Module

Pad an image to a specified size.

Parameters
  • size (Tuple[int, int]) โ€“ the size (height x width) of the image after padding.

  • fill (Union[int, Tuple[int, int, int]]) โ€“ the value to use for the padded pixels. Default: 0.

class composer.datasets.ade20k.PhotometricDistoration(brightness, contrast, saturation, hue)[source]#

Bases: torch.nn.modules.module.Module

Applies a combination of brightness, contrast, saturation, and hue jitters with random intensity.

This is a less severe form of PyTorchโ€™s ColorJitter used by the mmsegmentation library here: https://github.com/open-mmlab/mmsegmentation/blob/aa50358c71fe9c4cccdd2abe42433bdf702e757b/mmseg/datasets/pipelines/transforms.py#L861

Parameters
  • brightness (float) โ€“ max and min to jitter brightness.

  • contrast (float) โ€“ max and min to jitter contrast.

  • saturation (float) โ€“ max and min to jitter saturation.

  • hue (float) โ€“ max and min to jitter hue.

class composer.datasets.ade20k.RandomCropPair(crop_size, class_max_percent=1.0, num_retry=1)[source]#

Bases: torch.nn.modules.module.Module

Crop the image and target at a randomly sampled position.

Parameters
  • crop_size (Tuple[int, int]) โ€“ the size (height x width) of the crop.

  • class_max_percent (float) โ€“ the maximum percent of the image area a single class should occupy. Default is 1.0.

  • num_retry (int) โ€“ the number of times to resample the crop if class_max_percent threshold is not reached. Default is 1.

class composer.datasets.ade20k.RandomHFlipPair(probability=0.5)[source]#

Bases: torch.nn.modules.module.Module

Flip the image and target horizontally with a specified probability.

Parameters

probability (float) โ€“ the probability of flipping the image and target. Default: 0.5.

class composer.datasets.ade20k.RandomResizePair(min_scale, max_scale, base_size=None)[source]#

Bases: torch.nn.modules.module.Module

Resize the image and target to base_size scaled by a randomly sampled value.

Parameters
  • min_scale (float) โ€“ the minimum value the samples can be rescaled.

  • max_scale (float) โ€“ the maximum value the samples can be rescaled.

  • base_size (Tuple[int, int]) โ€“ a specified base size (height x width) to scale to get the resized dimensions. When this is None, use the input image size. Default: None.

class composer.datasets.ade20k.StreamingADE20k(remote, local, split, shuffle, base_size=512, min_resize_scale=0.5, max_resize_scale=2.0, final_size=512, batch_size=None)[source]#

Bases: composer.datasets.streaming.dataset.StreamingDataset

Implementation of the ADE20k dataset using StreamingDataset.

Parameters
  • remote (str) โ€“ Remote directory (S3 or local filesystem) where dataset is stored.

  • local (str) โ€“ Local filesystem directory where dataset is cached during operation.

  • split (str) โ€“ The dataset split to use, either โ€˜trainโ€™ or โ€˜valโ€™.

  • shuffle (bool) โ€“ Whether to shuffle the samples in this dataset.

  • base_size (int) โ€“ initial size of the image and target before other augmentations. Default: 512.

  • min_resize_scale (float) โ€“ the minimum value the samples can be rescaled. Default: 0.5.

  • max_resize_scale (float) โ€“ the maximum value the samples can be rescaled. Default: 2.0.

  • final_size (int) โ€“ the final size of the image and target. Default: 512.

  • batch_size (Optional[int]) โ€“ Hint the batch_size that will be used on each deviceโ€™s DataLoader. Default: None.