composer.datasets.ade20k#
composer.datasets.ade20k
Functions
Returns the same class as was passed in, with dunder methods added based on the fields defined in the class. |
|
Constructs a |
Classes
PyTorch Dataset for ADE20k. |
|
Specifications for operating and training on data. |
|
|
An abstract class representing a |
Normalizes input data and removes the background class from target data if desired. |
|
Pad an image to a specified size. |
|
Applies a combination of brightness, contrast, saturation, and hue jitters with random intensity. |
|
Crop the image and target at a randomly sampled position. |
|
Flip the image and target horizontally with a specified probability. |
|
Resize the image and target to base_size scaled by a randomly sampled value. |
|
Emulates a dataset of provided size and shape. |
Hparams
These classes are used with yahp
for YAML
-based configuration.
Defines an instance of the ADE20k dataset for semantic segmentation. |
|
Abstract base class for hyperparameters to initialize a dataset. |
|
Synthetic dataset parameter mixin for |
Attributes
IMAGENET_CHANNEL_MEAN
IMAGENET_CHANNEL_STD
Optional
Tuple
Union
ceil
- 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 is โtrainโ.
both_transforms (Module) โ transformations to apply to the image and target simultaneously. Default is None.
image_transforms (Module) โ transformations to apply to the image only. Default is None.
target_transforms (Module) โ transformations to apply to the target only. Default is None.
- class composer.datasets.ade20k.ADE20kDatasetHparams(use_synthetic=False, synthetic_num_unique_samples=100, synthetic_device='cpu', synthetic_memory_format=MemoryFormat.CONTIGUOUS_FORMAT, is_train=True, drop_last=True, shuffle=True, datadir=None, split='train', base_size=512, min_resize_scale=0.5, max_resize_scale=2.0, final_size=512, ignore_background=True)[source]#
Bases:
composer.datasets.hparams.DatasetHparams
,composer.datasets.hparams.SyntheticHparamsMixin
Defines an instance of the ADE20k dataset for semantic segmentation.
- Parameters
use_synthetic (bool, optional) โ Whether to use synthetic data. (Default:
False
)synthetic_num_unique_samples (int, optional) โ The number of unique samples to allocate memory for. Ignored if
use_synthetic
is False. (Default:100
)synthetic_device (str, optonal) โ The device to store the sample pool. Set to
cuda
to store samples on the GPU and eliminate PCI-e bandwidth with the dataloader. Set tocpu
to move data between host memory and the device on every batch. Ignored ifuse_synthetic
is False. (Default:cpu
)synthetic_memory_format โ The
MemoryFormat
to use. Ignored ifuse_synthetic
is False. (Default:CONTIGUOUS_FORMAT
)datadir (str) โ The path to the data directory.
is_train (bool) โ Whether to load the training data (the default) or validation data.
drop_last (bool) โ If the number of samples is not divisible by the batch size, whether to drop the last batch (the default) or pad the last batch with zeros.
shuffle (bool) โ Whether to shuffle the dataset. Defaults to True.
split (str) โ the dataset split to use either โtrainโ, โvalโ, or โtestโ. Default is train.
base_size (int) โ initial size of the image and target before other augmentations. Default is 512.
min_resize_scale (float) โ the minimum value the samples can be rescaled. Default is 0.5.
max_resize_scale (float) โ the maximum value the samples can be rescaled. Default is 2.0.
final_size (int) โ the final size of the image and target. Default is 512.
ignore_background (bool) โ if true, ignore the background class when calculating the training loss. Default is true.
- initialize_object(batch_size, dataloader_hparams)[source]#
Creates a
DataLoader
orDataloaderSpec
for this dataset.- Parameters
batch_size (int) โ The size of the batch the dataloader should yield. This batch size is device-specific and already incorporates the world size.
dataloader_hparams (DataloaderHparams) โ The dataset-independent hparams for the dataloader
- Returns
Dataloader or DataSpec โ The dataloader, or if the dataloader yields batches of custom types,
a :class:`DataSpec`.
- class composer.datasets.ade20k.PadToSize(size, fill=0)[source]#
Bases:
torch.nn.modules.module.Module
Pad an image to a specified size.
- 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/master/mmseg/datasets/pipelines/transforms.py#L837
- class composer.datasets.ade20k.RandomCropPair(crop_size)[source]#
Bases:
torch.nn.modules.module.Module
Crop the image and target at a randomly sampled position.
- 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 is 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 (default), use the input image size.