For detailed examples see notebooks.
from albumentations import (
HorizontalFlip, IAAPerspective, ShiftScaleRotate, CLAHE, RandomRotate90,
Transpose, ShiftScaleRotate, Blur, OpticalDistortion, GridDistortion, HueSaturationValue,
IAAAdditiveGaussianNoise, GaussNoise, MotionBlur, MedianBlur, IAAPiecewiseAffine,
IAASharpen, IAAEmboss, RandomBrightnessContrast, Flip, OneOf, Compose
)
import numpy as np
def strong_aug(p=0.5):
return Compose([
RandomRotate90(),
Flip(),
Transpose(),
OneOf([
IAAAdditiveGaussianNoise(),
GaussNoise(),
], p=0.2),
OneOf([
MotionBlur(p=0.2),
MedianBlur(blur_limit=3, p=0.1),
Blur(blur_limit=3, p=0.1),
], p=0.2),
ShiftScaleRotate(shift_limit=0.0625, scale_limit=0.2, rotate_limit=45, p=0.2),
OneOf([
OpticalDistortion(p=0.3),
GridDistortion(p=0.1),
IAAPiecewiseAffine(p=0.3),
], p=0.2),
OneOf([
CLAHE(clip_limit=2),
IAASharpen(),
IAAEmboss(),
RandomBrightnessContrast(),
], p=0.3),
HueSaturationValue(p=0.3),
], p=p)
image = np.ones((300, 300, 3), dtype=np.uint8)
mask = np.ones((300, 300), dtype=np.uint8)
whatever_data = "my name"
augmentation = strong_aug(p=0.9)
data = {"image": image, "mask": mask, "whatever_data": whatever_data, "additional": "hello"}
augmented = augmentation(**data)
image, mask, whatever_data, additional = augmented["image"], augmented["mask"], augmented["whatever_data"], augmented["additional"]
- Original image
MultiplicativeNoise(multiplier=0.5, p=1)
MultiplicativeNoise(multiplier=1.5, p=1)
MultiplicativeNoise(multiplier=[0.5, 1.5], per_channel=True, p=1)
MultiplicativeNoise(multiplier=[0.5, 1.5], elementwise=True, p=1)
MultiplicativeNoise(multiplier=[0.5, 1.5], elementwise=True, per_channel=True, p=1)
- Original image
ToSepia(p=1)
- Original image
JpegCompression(quality_lower=99, quality_upper=100, p=1)
JpegCompression(quality_lower=59, quality_upper=60, p=1)
JpegCompression(quality_lower=39, quality_upper=40, p=1)
JpegCompression(quality_lower=19, quality_upper=20, p=1)
JpegCompression(quality_lower=0, quality_upper=1, p=1)
- Original image
ChannelDropout(channel_drop_range=(1, 1), fill_value=0, p=1)
ChannelDropout(channel_drop_range=(1, 1), fill_value=0, p=1)
ChannelDropout(channel_drop_range=(1, 1), fill_value=0, p=1)
ChannelDropout(channel_drop_range=(1, 1), fill_value=0, p=1)
ChannelDropout(channel_drop_range=(1, 1), fill_value=0, p=1)
ChannelDropout(channel_drop_range=(2, 2), fill_value=0, p=1)
ChannelDropout(channel_drop_range=(2, 2), fill_value=0, p=1)
ChannelDropout(channel_drop_range=(2, 2), fill_value=0, p=1)
- Original image
ChannelShuffle(p=1)
ChannelShuffle(p=1)
ChannelShuffle(p=1)
- Original image
Cutout(num_holes=8, max_h_size=8, max_w_size=8, fill_value=0, p=1)
Cutout(num_holes=10, max_h_size=20, max_w_size=20, fill_value=0, p=1)
Cutout(num_holes=30, max_h_size=30, max_w_size=30, fill_value=64, p=1)
Cutout(num_holes=50, max_h_size=40, max_w_size=40, fill_value=128, p=1)
Cutout(num_holes=100, max_h_size=50, max_w_size=50, fill_value=255, p=1)
- Original image
ToGray(p=1)
- Original image
InvertImg(p=1)
- Original image
VerticalFlip(p=1)
- Original image
HorizontalFlip(p=1)
- Original image
Flip(p=1)
Flip(p=1)
Flip(p=1)
- Original image
RandomGridShuffle(grid=(3, 3), p=1)
RandomGridShuffle(grid=(5, 5), p=1)
RandomGridShuffle(grid=(7, 7), p=1)
- Original image
Blur(blur_limit=(7, 7), p=1)
Blur(blur_limit=(15, 15), p=1)
Blur(blur_limit=(50, 50), p=1)
Blur(blur_limit=(100, 100), p=1)
Blur(blur_limit=(300, 300), p=1)