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.
pip install albumentationsVerified import paths — ran on the pinned version, not inferred.
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.
Users requiring active development and support should migrate to `AlbumentationsX`. Uninstall `albumentations` and install `albumentationsx` (`pip uninstall albumentations; pip install albumentationsx`). Be aware that `AlbumentationsX` operates under a dual AGPL-3.0 / Commercial license, which may require open-sourcing your project or purchasing a commercial license.
Pass a `seed` argument to `A.Compose(..., seed=your_seed)` for reproducible pipelines. If using PyTorch `DataLoader`, understand that `num_workers` can influence augmentation sequences even with a fixed seed.
Ensure all inputs are converted to `numpy.ndarray` before passing them to any Albumentations transform or pipeline.
Explicitly convert BGR images to RGB using `cv2.cvtColor(image, cv2.COLOR_BGR2RGB)` after loading with OpenCV and before passing them to Albumentations.
For grayscale images, ensure they have a channel dimension. If your image is `(H, W)`, use `np.expand_dims(image, axis=-1)` to convert it to `(H, W, 1)`.
Install the library using pip: `pip install albumentations`.
Import the module correctly: `from albumentations import augmentations`.
Ensure you have the latest version installed: `pip install --upgrade albumentations`.
Refer to the latest documentation for correct usage: https://albumentations.ai/docs/.
Use a valid interpolation method such as 'nearest' or 'bilinear'.