Skip to content

Albumentations

[source]

aug_tfms

icevision.tfms.albumentations.aug_tfms(
    size,
    presize=None,
    horizontal_flip=HorizontalFlip(always_apply=False, p=0.5),
    shift_scale_rotate=ShiftScaleRotate(
        always_apply=False,
        p=0.5,
        shift_limit_x=(-0.0625, 0.0625),
        shift_limit_y=(-0.0625, 0.0625),
        scale_limit=(-0.09999999999999998, 0.10000000000000009),
        rotate_limit=(-15, 15),
        interpolation=1,
        border_mode=4,
        value=None,
        mask_value=None,
    ),
    rgb_shift=RGBShift(
        always_apply=False, p=0.5, r_shift_limit=(-10, 10), g_shift_limit=(-10, 10), b_shift_limit=(-10, 10)
    ),
    lightning=RandomBrightnessContrast(
        always_apply=False,
        p=0.5,
        brightness_limit=(-0.2, 0.2),
        contrast_limit=(-0.2, 0.2),
        brightness_by_max=True,
    ),
    blur=Blur(always_apply=False, p=0.5, blur_limit=(1, 3)),
    crop_fn=functools.partial(RandomSizedBBoxSafeCrop, p=0.5),
    pad=functools.partial(PadIfNeeded, border_mode=0, value=[124, 116, 104]),
)

Collection of useful augmentation transforms.

Arguments

  • size Union[int, Tuple[int, int]]: The final size of the image. If an int is given, the maximum size of the image is rescaled, maintaing aspect ratio. If a tuple is given, the image is rescaled to have that exact size (width, height).
  • presizing: Rescale the image before applying other transfroms. If None this transform is not applied. First introduced by fastai,this technique is explained in their book in this chapter (tip: search for "Presizing").
  • horizontal_flip Optional[albumentations.augmentations.transforms.HorizontalFlip]: Flip around the y-axis. If None this transform is not applied.
  • shift_scale_rotate Optional[albumentations.augmentations.geometric.transforms.ShiftScaleRotate]: Randomly shift, scale, and rotate. If None this transform is not applied.
  • rgb_shift Optional[albumentations.augmentations.transforms.RGBShift]: Randomly shift values for each channel of RGB image. If None this transform is not applied.
  • lightning Optional[albumentations.augmentations.transforms.RandomBrightnessContrast]: Randomly changes Brightness and Contrast. If None this transform is not applied.
  • blur Optional[albumentations.augmentations.transforms.Blur]: Randomly blur the image. If None this transform is not applied.
  • crop_fn Optional[albumentations.core.transforms_interface.DualTransform]: Randomly crop the image. If None this transform is not applied. Use partial to saturate other parameters of the class.
  • pad Optional[albumentations.core.transforms_interface.DualTransform]: Pad the image to size, squaring the image if size is an int. If None this transform is not applied. Use partial to sature other parameters of the class.

Returns

A list of albumentations transforms.


[source]

Adapter

icevision.tfms.albumentations.Adapter(tfms)

Helper class that provides a standard way to create an ABC using inheritance.