fast image augmentation library and easy to use wrapper around other libraries
Project description
Albumentations
- Great fast augmentations based on highly-optimized OpenCV library
- Super simple yet powerful interface for different tasks like (segmentation, detection, etc.)
- Easy to customize
- Easy to add other frameworks
Example usage:
from albumentations import (
HorizontalFlip, IAAPerspective, ShiftScaleRotate, CLAHE, RandomRotate90,
Transpose, ShiftScaleRotate, Blur, OpticalDistortion, GridDistortion, HueSaturationValue,
IAAAdditiveGaussianNoise, GaussNoise, MotionBlur, MedianBlur, IAAPiecewiseAffine,
IAASharpen, IAAEmboss, RandomContrast, RandomBrightness, Flip, OneOf, Compose
)
import numpy as np
def strong_aug(p=.5):
return Compose([
RandomRotate90(),
Flip(),
Transpose(),
OneOf([
IAAAdditiveGaussianNoise(),
GaussNoise(),
], p=0.2),
OneOf([
MotionBlur(p=.2),
MedianBlur(blur_limit=3, p=.1),
Blur(blur_limit=3, p=.1),
], p=0.2),
ShiftScaleRotate(shift_limit=0.0625, scale_limit=0.2, rotate_limit=45, p=.2),
OneOf([
OpticalDistortion(p=0.3),
GridDistortion(p=.1),
IAAPiecewiseAffine(p=0.3),
], p=0.2),
OneOf([
CLAHE(clip_limit=2),
IAASharpen(),
IAAEmboss(),
RandomContrast(),
RandomBrightness(),
], p=0.3),
HueSaturationValue(p=0.3),
], p=p)
image = np.ones((300, 300))
mask = np.ones((300, 300))
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"]
See example.ipynb
Installation
You can use pip to install the latest version from GitHub:
pip install -U git+https://github.com/albu/albumentations
Documentation
The full documentation is available at albumentations.readthedocs.io.
Benchmarking results
To run the benchmark yourself follow the instructions in benchmark/README.md
Results for running the benchmark on first 2000 images from the ImageNet validation set using an Intel Core i7-7800X CPU. All times are in seconds, lower is better.
| albumentations | imgaug | torchvision (Pillow backend) |
torchvision (Pillow-SIMD backend) |
Keras | |
|---|---|---|---|---|---|
| RandomCrop64 | 0.0017 | - | 0.0182 | 0.0182 | - |
| PadToSize512 | 0.2413 | - | 2.493 | 2.3682 | - |
| HorizontalFlip | 0.7765 | 2.2299 | 0.3031 | 0.3054 | 2.0508 |
| VerticalFlip | 0.178 | 0.3899 | 0.2326 | 0.2308 | 0.1799 |
| Rotate | 3.8538 | 4.0581 | 16.16 | 9.5011 | 50.8632 |
| ShiftScaleRotate | 2.0605 | 2.4478 | 18.5401 | 10.6062 | 47.0568 |
| Brightness | 2.1018 | 2.3607 | 4.6854 | 3.4814 | 9.9237 |
| ShiftHSV | 10.3925 | 14.2255 | 34.7778 | 27.0215 | - |
| ShiftRGB | 2.6159 | 2.1989 | - | - | 3.0598 |
| Gamma | 1.4832 | - | 1.1397 | 1.1447 | - |
| Grayscale | 1.2048 | 5.3895 | 1.6826 | 1.2721 | - |
Contributing
- Clone the repository:
git clone git@github.com:albu/albumentations.git
cd albumentations
- Install the library in development mode:
pip install -e .[tests]
- Run tests:
pytest
Building the documentation
- Go to
docs/directory
cd docs
- Install required libraries
pip install -r requirements.txt
- Build html files
make html
- Open
_build/html/index.htmlin browser.
Alternatively, you can start a web server that rebuilds the documentation
automatically when a change is detected by running make livehtml
Thanks:
Special thanks to @creafz for refactoring, documentation, tests, CI and benchmarks. Awesome work!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file albumentations-0.0.4.tar.gz.
File metadata
- Download URL: albumentations-0.0.4.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c19532e246993a188fbbca07f0ae6c385acc4c10a1771e54f07ea09f28f6af89
|
|
| MD5 |
3169b3e0889a8405d1bdc5772f0c4b33
|
|
| BLAKE2b-256 |
27d99335d3138a8921fbf6c773698da3dd2658935022fb31a25baa4eed733ff2
|
File details
Details for the file albumentations-0.0.4-py3.6.egg.
File metadata
- Download URL: albumentations-0.0.4-py3.6.egg
- Upload date:
- Size: 44.6 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/38.4.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b7dcf066a8ac21225396fcbe01f88fbcfe87bf58cca65165e1a3491b5060e7a
|
|
| MD5 |
c25b3ae8b15ea08b1cc2e1995cc1a7fc
|
|
| BLAKE2b-256 |
a394d5d21b01c27478b8e8bf18c1e438c2bef84848b4a8f95139439907229c57
|