Skip to content

albumentations-team/albumentations_examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Notebooks

If you found errors in the notebooks, please create:

  1. Pull request with the fix or
  2. Submit an issue to the main repository of Albumentations

Usage examples

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"]

Augmentations examples

MultiplicativeNoise

  1. Original image
  2. MultiplicativeNoise(multiplier=0.5, p=1)
  3. MultiplicativeNoise(multiplier=1.5, p=1)
  4. MultiplicativeNoise(multiplier=[0.5, 1.5], per_channel=True, p=1)
  5. MultiplicativeNoise(multiplier=[0.5, 1.5], elementwise=True, p=1)
  6. MultiplicativeNoise(multiplier=[0.5, 1.5], elementwise=True, per_channel=True, p=1)

MultiplicativeNoise image

ToSepia

  1. Original image
  2. ToSepia(p=1)

ToSepia image

ChannelDropout

  1. Original image
  2. ChannelDropout(channel_drop_range=(1, 1), fill_value=0, p=1)
  3. ChannelDropout(channel_drop_range=(1, 1), fill_value=0, p=1)
  4. ChannelDropout(channel_drop_range=(1, 1), fill_value=0, p=1)
  5. ChannelDropout(channel_drop_range=(1, 1), fill_value=0, p=1)
  6. ChannelDropout(channel_drop_range=(1, 1), fill_value=0, p=1)
  7. ChannelDropout(channel_drop_range=(2, 2), fill_value=0, p=1)
  8. ChannelDropout(channel_drop_range=(2, 2), fill_value=0, p=1)
  9. ChannelDropout(channel_drop_range=(2, 2), fill_value=0, p=1)

ChannelDropout image

ChannelShuffle

  1. Original image
  2. ChannelShuffle(p=1)
  3. ChannelShuffle(p=1)
  4. ChannelShuffle(p=1)

ChannelShuffle image

ToGray

  1. Original image
  2. ToGray(p=1)

ToGray image

InvertImg

  1. Original image
  2. InvertImg(p=1)

InvertImg image

VerticalFlip

  1. Original image
  2. VerticalFlip(p=1)

VerticalFlip image

HorizontalFlip

  1. Original image
  2. HorizontalFlip(p=1)

HorizontalFlip image

Flip

  1. Original image
  2. Flip(p=1)
  3. Flip(p=1)
  4. Flip(p=1)

Flip image

RandomGridShuffle

  1. Original image
  2. RandomGridShuffle(grid=(3, 3), p=1)
  3. RandomGridShuffle(grid=(5, 5), p=1)
  4. RandomGridShuffle(grid=(7, 7), p=1)

RandomGridShuffle image

Blur

  1. Original image
  2. Blur(blur_limit=(7, 7), p=1)
  3. Blur(blur_limit=(15, 15), p=1)
  4. Blur(blur_limit=(50, 50), p=1)
  5. Blur(blur_limit=(100, 100), p=1)
  6. Blur(blur_limit=(300, 300), p=1)

Blur image

About

Augmentations usage examples for albumentations library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages