File size: 2,595 Bytes
7419c11
 
 
 
 
 
 
8734271
7419c11
 
8734271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
title: README
emoji: 👁
colorFrom: red
colorTo: yellow
sdk: static
pinned: false
license: mit
---

![image/png](https://cdn-uploads.huggingface.co/production/uploads/6328b534b0910efc278133ba/iXsFX9ZfyKbn8JSH_ohi_.png)

# Albumentations

Efficient Image Augmentation for Machine Learning in Python

[Albumentations](https://albumentations.ai/) is a fast, flexible image augmentation library designed for machine learning practitioners working on computer vision tasks. Our aim is simple: provide a comprehensive set of tools that can transform any image to augment your datasets, thereby improving model accuracy and robustness.

Features:

- [Wide Range of Augmentations](https://albumentations.ai/docs/api_reference/full_reference/): Supports geometric transforms, color augmentations, flips, rotations, and more, tailored for classification, segmentation, object detection, and working with key points.
- [Easy Integration](https://albumentations.ai/docs/#examples): Designed to easily fit into any machine learning pipeline.
- [Performance Optimized](https://albumentations.ai/docs/benchmarking_results/): Minimizes CPU/GPU load with efficient implementation.
- Community Driven: Open to contributions and feedback. We evolve with your needs.

```python
from albumentations import (
    HorizontalFlip, Affine, CLAHE, RandomRotate90,
    Transpose, ShiftScaleRotate, Blur, OpticalDistortion, GridDistortion, HueSaturationValue,
    GaussNoise, MotionBlur, MedianBlur,
    RandomBrightnessContrast, Flip, OneOf, Compose
)
import numpy as np

def strong_aug(p=0.5):
    return Compose([
        RandomRotate90(),
        Flip(),
        Transpose(),
        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_limit=(-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"]

```