AlbumentationsX vs PIL/Pillow

Compare AlbumentationsX with PIL/Pillow for image augmentation: API differences, RGB JPEG-to-CUDA benchmark results, and migration examples.

What Is Different?

Pillow is an image toolkit. AlbumentationsX is an augmentation pipeline library. That sounds subtle, but it changes the shape of the code: Pillow gives you image operations; AlbumentationsX gives you randomized, reproducible transforms that keep images, masks, bounding boxes, and keypoints synchronized.

  • Pillow works with PIL Image objects; AlbumentationsX works with NumPy arrays and returns a dictionary of augmented targets.
  • Pillow is great for loading, saving, drawing, and simple image edits; AlbumentationsX is built for training-time augmentation pipelines.
  • AlbumentationsX has first-class random composition, probabilities, target synchronization, and bbox/keypoint parameter handling.
  • Pillow code usually becomes manual orchestration when masks or labels must follow the image; AlbumentationsX keeps that in the pipeline contract.

RGB input pipeline results

Every path reads RGB JPEGs, prepares the recipe, and delivers a synchronized CUDA batch. CPU and GPU labels identify where augmentation runs; normalization runs on GPU for every path.

Mean relative throughput on the same 26 recipes. AlbumentationsX = 1×; higher is faster.
Mean relative throughput on the same 26 recipes. AlbumentationsX = 1×; higher is faster. Scroll horizontally to see the full chart. Open the image for full size.
Same 26 recipes for every row. Throughput is the arithmetic mean of per-recipe ratios to AlbumentationsX; memory is the median of per-recipe peak-memory medians.
Measured pathThroughput / AXGPU memory (MiB)
AlbumentationsX CPU1.00×1,852
Pillow CPU0.71×1,814

Each comparison uses its own shared recipe set. Averages from different sets cannot rank all libraries. The table below includes every measured recipe for these paths, including recipes outside the summary set. Recipe names are shortened; hover over a name for its full pipeline.

Benchmark metric

Higher throughput is better. Values are medians across seeds. Hover for the observed range. A dash means no measured result.

R01Resize2244,7512,390
R02RandomCrop2244,7403,768
R03RandomResizedCrop4,7852,721
R04HorizontalFlip4,7233,759
R05VerticalFlip4,9073,567
R06Pad+RandomCrop2244,3973,659
R07Rotate3,3523,555
R08Affine3,0492,647
R09Perspective2,879
R10Elastic1,990
R11ColorJitter3,523
R12ChannelShuffle5,026
R13Grayscale5,1573,687
R14RGBShift4,348
R15GaussianBlur4,6792,393
R16GaussianNoise3,288
R17Invert5,0763,540
R18Posterize5,1103,493
R19Solarize4,6073,506
R20Sharpen4,223
R21AutoContrast4,2633,513
R22Equalize3,9863,245
R23Erasing4,938
R24JpegCompression4,2323,183
R25RandomGamma4,969
R26PlankianJitter4,538
R27MedianBlur3,805241
R28MotionBlur4,223
R29CLAHE2,373
R30Brightness4,6223,519
R31Contrast4,6423,198
R32Blur4,8213,048
R33ChannelDropout4,972
R34LinearIllumination3,866
R35CornerIllumination4,090
R36GaussianIllumination3,930
R37Hue4,274
R38PlasmaBrightness2,461
R39PlasmaContrast2,162
R40PlasmaShadow2,489
R41Rain4,069
R42SaltAndPepper4,147
R43Saturation4,1363,470
R44Snow3,857
R45OpticalDistortion3,110
R46Shear2,6582,550
R47ThinPlateSpline858
R48PhotoMetricDistort3,369
R49ColorJiggle3,526
R50LongestMaxSize+RandomCrop2243,658
R51SmallestMaxSize+RandomCrop2243,221
R52Transpose4,9423,676
R53RandomRotate905,002
R54RandomJigsaw4,662
R55EnhanceEdge4,3892,601
R56EnhanceDetail4,7202,700
R57UnsharpMask3,1202,132

Measurement setup and limits

Throughput measures batch consumption and final CUDA synchronization. GPU memory is sampled from pipeline construction through cleanup.
Throughput measures batch consumption and final CUDA synchronization. GPU memory is sampled from pipeline construction through cleanup. Scroll horizontally to see the full chart. Open the image for full size.

g2-standard-16, nvidia-l4; 10,000 selected ImageNet JPEGs. Batch size 256, 15 workers, prefetch factor 2; persistent workers enabled. Output: cuda float16, BCHW 256×3×224×224.

Seeds: 137, 138, 139. Each observation follows 1 warm-up batch and times 32 batches, ending with CUDA synchronization. Pipeline construction and worker startup are outside throughput timing; prefetch effects remain. JPEG files are prewarmed, so this measures filesystem reads and decoding with a warm page cache.

NVML samples peak process GPU memory every 50 ms, from pipeline construction through final synchronization and cleanup. Brief peaks can be missed. The measurements include no model and do not establish training speed or augmentation quality. Seeds do not guarantee identical augmentation draws across libraries. Observed ranges describe variation between runs; they are not confidence intervals.

In this published run, DALI Crop includes resizing the short side, and DALI Affine omits rotation and shear.

Run 3f8e2e315710528399b8e82e2359ab85c58c809644595b68a92fb9d83492cc8c · 759 measurements · measured source 5fc35f6 · machine-readable results · paper and methodology. This is the run reported in the paper.

Conversion Guide

The main conversion is to move from calling Pillow methods one at a time to defining an AlbumentationsX Compose pipeline.

  • Convert PIL images to NumPy arrays before augmentation.
  • Replace manual randomness with transform-level p values.
  • Keep image-adjacent targets in the same Compose call instead of transforming them separately.
  • Convert back to PIL only if downstream code specifically needs PIL objects.
Pillow
from PIL import Image, ImageEnhance
import random

image = Image.open("image.jpg").convert("RGB")

if random.random() < 0.5:
    image = image.transpose(Image.Transpose.FLIP_LEFT_RIGHT)

if random.random() < 0.5:
    image = ImageEnhance.Brightness(image).enhance(1.2)
AlbumentationsX
import albumentations as A
import cv2

transform = A.Compose([
    A.HorizontalFlip(p=0.5),
    A.RandomBrightnessContrast(brightness_limit=0.2, contrast_limit=0.0, p=0.5),
])

image = cv2.cvtColor(cv2.imread("image.jpg"), cv2.COLOR_BGR2RGB)
image = transform(image=image)["image"]

Use AlbumentationsX When

  • Training-time augmentation where randomness, replayability, and target synchronization matter.
  • Segmentation, detection, keypoint, OCR, document, satellite, medical, or any multi-target computer vision workflow.
  • CPU data-loader pipelines where augmentation speed can become the training bottleneck.

Use PIL/Pillow When

  • Image IO, format conversion, drawing, thumbnails, and lightweight one-off image manipulation.
  • Small scripts where you only touch a single image and do not need labels, masks, or reproducible random policies.