AlbumentationsDataset#

class AlbumentationsDataset[source]#

Bases: Dataset

An adapter to use arbitrary datasets with albumentations transforms.

__init__(orig_dataset: Any, transform: Optional[BasicTransform] = None, transform_type: TransformType = TransformType.noop, normalize=True, to_pytorch=True)[source]#

Constructor.

Parameters
  • orig_dataset (Any) – An object with a __getitem__ and __len__.

  • transform (A.BasicTransform, optional) – Albumentations transform to apply to the windows. Defaults to None. Each transform in Albumentations takes images of type uint8, and sometimes other data types. The data type requirements can be seen at https://albumentations.ai/docs/api_reference/augmentations/transforms/ # noqa If there is a mismatch between the data type of imagery and the transform requirements, a RasterTransformer should be set on the RasterSource that converts to uint8, such as MinMaxTransformer or StatsTransformer.

  • transform_type (TransformType) – The type of transform so that its inputs and outputs can be handled correctly. Defaults to TransformType.noop.

  • normalize (bool, optional) – If True, x is normalized to [0, 1] based on its data type. Defaults to True.

  • to_pytorch (bool, optional) – If True, x and y are converted to pytorch tensors. Defaults to True.

Methods

__init__(orig_dataset[, transform, ...])

Constructor.

__contains__(key: str) bool#
Parameters

key (str) –

Return type

bool

__getitem__(key) Tuple[torch.Tensor, torch.Tensor][source]#
Return type

Tuple[torch.Tensor, torch.Tensor]

__init__(orig_dataset: Any, transform: Optional[BasicTransform] = None, transform_type: TransformType = TransformType.noop, normalize=True, to_pytorch=True)[source]#

Constructor.

Parameters
  • orig_dataset (Any) – An object with a __getitem__ and __len__.

  • transform (A.BasicTransform, optional) – Albumentations transform to apply to the windows. Defaults to None. Each transform in Albumentations takes images of type uint8, and sometimes other data types. The data type requirements can be seen at https://albumentations.ai/docs/api_reference/augmentations/transforms/ # noqa If there is a mismatch between the data type of imagery and the transform requirements, a RasterTransformer should be set on the RasterSource that converts to uint8, such as MinMaxTransformer or StatsTransformer.

  • transform_type (TransformType) – The type of transform so that its inputs and outputs can be handled correctly. Defaults to TransformType.noop.

  • normalize (bool, optional) – If True, x is normalized to [0, 1] based on its data type. Defaults to True.

  • to_pytorch (bool, optional) – If True, x and y are converted to pytorch tensors. Defaults to True.

static __new__(cls, *args: Any, **kwargs: Any) Any#
Parameters
  • args (Any) –

  • kwargs (Any) –

Return type

Any