Albumentations (Legacy - MIT Licensed)

2.0.8 · abandoned · verified Thu Apr 09

Albumentations is a Python library for image augmentation, widely adopted in deep learning and computer vision tasks for its speed, flexibility, and extensive collection of transformations. It offers a unified API to work with various data types including images, masks, bounding boxes, and keypoints. **However, the original MIT-licensed Albumentations project is no longer actively maintained. The last update was in June 2025, and no further bug fixes, features, or compatibility updates will be provided.** For active development and support, users are directed to its successor, AlbumentationsX, which maintains the same API but operates under a dual AGPL-3.0 / Commercial license. The current version of this legacy library is 2.0.8.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to define a simple augmentation pipeline using `A.Compose` and apply it to an image. It includes common transforms like random cropping, horizontal flipping, and normalization. Ensure `opencv-python` and `numpy` are installed for this example to run.

import albumentations as A
import cv2
import numpy as np

# Create a dummy image (256x256, 3 channels, uint8)
image = np.random.randint(0, 256, (256, 256, 3), dtype=np.uint8)

# Define an augmentation pipeline
transform = A.Compose([
    A.RandomCrop(width=128, height=128, p=1.0),
    A.HorizontalFlip(p=0.5),
    A.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)),
])

# Apply the transform
transformed_data = transform(image=image)
transformed_image = transformed_data["image"]

print(f"Original image shape: {image.shape}")
print(f"Transformed image shape: {transformed_image.shape}")
print(f"Transformed image dtype: {transformed_image.dtype}")

view raw JSON →