If you found errors in the notebooks, please create:
- Pull request with the fix or
- Submit an issue to the main repository of Albumentations
- example.ipynb. Defining a simple augmentation pipeline for image augmentation.
- example_16_bit_tiff.ipynb. Working with non-8-bit images.
- example_bboxes.ipynb. Using Albumentations to augment bounding boxes for object detection tasks.
- example_bboxes2.ipynb. How to use Albumentations for detection tasks if you need to keep all bounding boxes.
- example_kaggle_salt.ipynb. Using Albumentations for a semantic segmentation task.
- example_keypoints.ipynb. Using Albumentations to augment keypoints.
- example_multi_target.ipynb. Applying the same augmentation with the same parameters to multiple images, masks, bounding boxes, or keypoints.
- example_weather_transforms.ipynb. Weather augmentations in Albumentations.
- migrating_from_torchvision_to_albumentations.ipynb. Migrating from torchvision to Albumentations.
- replay.ipynb. Debugging an augmentation pipeline with ReplayCompose.
- serialization.ipynb. How to save and load parameters of an augmentation pipeline.
- showcase.ipynb. Showcase. Cool augmentation examples on diverse set of images from various real-world tasks.
- tensorflow-example.ipynb. Using Albumentations with Tensorflow.
- pytorch_classification.ipynb. PyTorch and Albumentations for image classification.
- pytorch_semantic_segmentation.ipynb. PyTorch and Albumentations for semantic segmentation.
- xy_transform.ipynb. How to apply XYMasking.
- example_chromatic_aberration.ipynb. How to apply ChromaticAberration.
- example_d4.ipynb. How to apply D4 transform.
- example_gridshuffle.ipynb. How to apply RandomGridShuffle transform.
- example_documents.ipynb. How to apply Morphological, both erosion and dilation.
- example_hfhub.ipynb. How to load and save augmentation pipeline to HuggungFace Hub.
- example_documents.ipynb. How to apply OverlayElements to update text on the image
- example_textimage.ipynb. How to add text to the image
For detailed examples, see notebooks.
from albumentations import (
Affine, CLAHE,Blur, OpticalDistortion, GridDistortion, HueSaturationValue,
GaussNoise, MotionBlur, MedianBlur,
RandomBrightnessContrast, D4, OneOf, Compose
)
import numpy as np
def strong_aug(p=0.5):
return Compose([
D4(),
GaussNoise(),
OneOf([
MotionBlur(p=0.2),
MedianBlur(blur_limit=3, p=0.1),
Blur(blur_limit=3, p=0.1),
], p=0.2),
Affine(translate_percent=0.0625, scale=(0.8, 1.2), rotate=(-45, 45), p=0.2),
OneOf([
OpticalDistortion(p=0.3),
GridDistortion(p=0.1)
], p=0.2),
OneOf([
CLAHE(clip_limit=2),
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
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
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)