mml.core.data_loading.augmentations.albumentations
- class AlbumentationsAugmentationModule[source]
Bases:
AugmentationModuleAlbumentations augmentation module.
Basic supported dict entries are [‘image’, ‘mask’, ‘bboxes’, ‘keypoints’].
An AutoAlbument generated pipeline is available via the Identifier “ImageNetAA” (no parameters). “RandAugment” with parameters is also provided on top. See
get_rand_augment()for details.Note that once bboxes and keypoints will be supported than composition will include the respective parameters https://albumentations.ai/docs/api_reference/core/composition/. Futhermore “additional_targets” might need to be defined. To check whether a certain augmentation supports a specific target type see https://albumentations.ai/docs/getting_started/transforms_and_targets/.
- __init__(device: str, cfg: ListConfig, is_first: bool, is_last: bool, means: RGBInfo | None, stds: RGBInfo | None, floatify: bool = False, tensorize: bool = True)[source]
- static compose_albumentations_transforms(pp_trans: List[BasicTransform], aug_trans: List[BasicTransform], mean: RGBInfo | None = None, std: RGBInfo | None = None) Compose[source]
Composes transforms from preprocessing, data augmentation, normalization and tensorization.
- Parameters:
pp_trans – list of preprocessing transforms, can be empty
aug_trans – list of data augmentation transforms, can be empty
mean – mean channel values to normalize input data
std – standard deviation values per channel to normalize input data
- Returns:
a composed albumentation pipeline
- static from_cfg(aug_config: ListConfig) List[Callable[[Dict[str, Any]], Dict[str, Any]]][source]
Takes a config and returns a list of corresponding transforms.
- Parameters:
aug_config (DictConfig) – see configs/augmentations/default.yaml for an example, the “cpu” attribute is what has to be passed to this function.
- Returns:
a list of albumentation transforms
- static get_rand_augment(number: int, magnitude: int, p: float = 1.0, mode: str = 'all', cut_out: bool = False) BaseCompose[source]
Gets RandAugment transform. For details see https://arxiv.org/abs/1909.13719.
- Parameters:
number – number of transforms to be applied (excluding cut_out if active)
magnitude – int between 0 and 9 determining strength of transformation
p – probability to apply RandAugment
mode – either ‘geo’ for geometrical transforms, ‘color’ for color transforms or ‘all’ for both of them
cut_out – indicating if cutout should be applied
- Returns:
an albumentations transform