Home Knowledge Base Albumentations

Albumentations is a fast, flexible, open-source Python library for image augmentation that has become the de facto standard in computer vision competitions (Kaggle) and production pipelines — providing 70+ augmentation transforms optimized with OpenCV and numpy (2-10× faster than torchvision), with native support for simultaneously transforming images alongside their bounding boxes, segmentation masks, and keypoints, ensuring that spatial labels stay correctly aligned when the image is flipped, rotated, or cropped.

What Is Albumentations?

Core Usage

import albumentations as A
from albumentations.pytorch import ToTensorV2

transform = A.Compose([
    A.RandomCrop(width=256, height=256),
    A.HorizontalFlip(p=0.5),
    A.RandomBrightnessContrast(p=0.2),
    A.Normalize(mean=(0.485, 0.456, 0.406),
                std=(0.229, 0.224, 0.225)),
    ToTensorV2(),
])

transformed = transform(image=image, mask=mask,
                        bboxes=bboxes)

Key Transform Categories

CategoryTransformsExample
SpatialFlip, Rotate, Crop, Resize, Affine, ElasticTransformRandom 90° rotation
ColorBrightness, Contrast, HueSaturation, CLAHE, RGBShiftRandom brightness ±20%
Blur/NoiseGaussianBlur, MotionBlur, GaussNoise, ISONoiseSimulate camera shake
WeatherRandomRain, RandomFog, RandomSnow, RandomSunFlareSimulate weather conditions
DropoutCoarseDropout (Cutout), GridDropout, ChannelDropoutZero out random patches
Medical/HistologyElasticTransform, GridDistortionTissue deformation simulation

Bounding Box Support

TaskWhat Happens When Image Is Flipped
Image onlyImage pixels flip — done
Object detectionImage flips + bounding box coordinates transform (x → width - x)
SegmentationImage flips + mask flips identically
KeypointsImage flips + each keypoint coordinate transforms

Albumentations handles all coordinate transformations automatically — you specify bbox_params and the library ensures labels stay aligned with the augmented image.

Albumentations vs Alternatives

LibrarySpeedBox/Mask SupportTransformsEcosystem
AlbumentationsFastest (OpenCV)Native, automatic70+PyTorch, TF, standalone
torchvisionGoodManual (v2 improving)~20PyTorch only
imgaugModerateYes60+Standalone
KorniaGPU-acceleratedYes40+PyTorch (differentiable)
Augly (Meta)ModerateLimitedSocial media focusedPyTorch

Albumentations is the production-standard image augmentation library — providing the speed, flexibility, and automatic coordinate transformation that computer vision pipelines require, with the broadest set of transforms and native support for detection, segmentation, and keypoint tasks that make it the default choice for both Kaggle competitions and production computer vision systems.

albumentationsfastimage

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.