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 most augmentation stages run. Every path normalizes on GPU.
Each comparison uses its own shared recipe set. Compare paths within each chart. 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.
Higher throughput is better. Values are medians across seeds. Hover for the observed range. A dash means no measured result.
| R01Resize224 | 4,691 | 2,665 | 4,176 |
|---|---|---|---|
| R02RandomCrop224 | 4,421 | 4,319 | 4,197 |
| R03RandomResizedCrop | 4,706 | 2,714 | 3,904 |
| R04HorizontalFlip | 3,955 | 4,287 | 4,291 |
| R05VerticalFlip | 4,279 | 4,255 | 4,146 |
| R06Pad+RandomCrop224 | 4,244 | 3,891 | 4,022 |
| R07Rotate | 4,409 | 4,057 | 4,192 |
| R08Affine | 4,106 | 2,625 | 3,902 |
| R09Perspective | 4,180 | 2,650 | 3,669 |
| R10Elastic | 3,032 | — | — |
| R11ColorJitter | 3,569 | — | — |
| R12ChannelShuffle | 4,751 | 4,184 | 4,192 |
| R13Grayscale | 4,804 | 4,104 | 4,100 |
| R14RGBShift | 4,655 | 3,833 | 4,006 |
| R15GaussianBlur | 4,399 | 2,521 | 3,764 |
| R16GaussianNoise | 3,376 | — | — |
| R17Invert | 4,928 | 3,940 | 4,186 |
| R18Posterize | 4,968 | 3,966 | 4,029 |
| R19Solarize | 4,622 | 3,820 | 4,245 |
| R20Sharpen | 4,481 | — | — |
| R21AutoContrast | 4,160 | 3,724 | 3,882 |
| R22Equalize | 3,976 | 3,750 | 3,872 |
| R23Erasing | 4,726 | — | — |
| R24JpegCompression | 3,868 | 3,511 | 3,611 |
| R25RandomGamma | 4,586 | 4,054 | 4,095 |
| R26PlankianJitter | 4,340 | — | — |
| R27MedianBlur | 3,758 | 243 | 3,916 |
| R28MotionBlur | 4,213 | — | — |
| R29CLAHE | 3,109 | — | — |
| R30Brightness | 4,633 | 3,954 | 3,866 |
| R31Contrast | 4,380 | 3,690 | 2,439 |
| R32Blur | 4,851 | 3,341 | 4,141 |
| R33ChannelDropout | 4,732 | 4,072 | 4,264 |
| R34LinearIllumination | 3,826 | — | — |
| R35CornerIllumination | 3,991 | — | — |
| R36GaussianIllumination | 3,789 | — | — |
| R37Hue | 4,064 | — | — |
| R38PlasmaBrightness | 2,603 | — | — |
| R39PlasmaContrast | 2,202 | — | — |
| R40PlasmaShadow | 2,502 | — | — |
| R41Rain | 3,979 | — | — |
| R42SaltAndPepper | 4,750 | — | — |
| R43Saturation | 4,354 | 3,798 | 4,030 |
| R44Snow | 3,733 | — | — |
| R45OpticalDistortion | 3,817 | — | — |
| R46Shear | 3,756 | 2,643 | 3,822 |
| R47ThinPlateSpline | 3,139 | — | — |
| R48PhotoMetricDistort | 3,482 | — | — |
| R49ColorJiggle | 3,640 | — | — |
| R50LongestMaxSize+RandomCrop224 | 3,729 | 1,236 | 2,950 |
| R51SmallestMaxSize+RandomCrop224 | 3,187 | 848 | 2,403 |
| R52Transpose | 4,945 | 4,158 | 4,342 |
| R53RandomRotate90 | 4,846 | 4,247 | 4,368 |
| R54RandomJigsaw | 4,442 | — | — |
| R55EnhanceEdge | 4,480 | 2,699 | 3,995 |
| R56EnhanceDetail | 4,412 | 2,762 | 4,046 |
| R57UnsharpMask | 4,252 | 2,276 | 3,604 |
| R58CenterCrop | 4,658 | 4,206 | 4,358 |
| R59Resize256+Crop | 4,595 | 2,342 | 3,805 |
| R60Resize224+CropAndPad | 4,284 | 2,673 | 3,979 |
| R61LetterBox | 4,649 | 2,876 | 3,987 |
| R62PadIfNeeded+RandomCrop224 | 4,404 | 4,123 | 4,400 |
| R63Resize224+ChannelSwap | 4,569 | 2,657 | 3,722 |
| R64Resize224+Colorize | 4,267 | 2,409 | 3,531 |
| R65Resize224+Dithering | 895 | 2,451 | 3,137 |
| R66Resize224+MorphologicalDilation | 4,496 | — | — |
| R67Resize224+MorphologicalErosion | 4,429 | — | — |
| R68RandomScale+RandomCrop224 | 3,663 | 1,140 | 2,727 |
| R69Resize224+RandomSizedCrop | 4,313 | 1,872 | 3,512 |
| R70Resize224+CoarseDropout | 4,362 | 2,658 | 3,918 |
| R71Resize224+Emboss | 4,159 | 2,028 | 3,688 |
| R72Resize224+PixelSpread | 3,524 | — | — |
| R73Resize224+ShiftScaleRotate | 3,842 | 1,947 | 3,581 |
Measurement setup and limits
The timeline illustrates input stalls with a fixed model step duration.
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.
Run 03b5fd6c6fab74fd1029fc88012e03cb4b51d0a2e3c4b8be59ead6928efae6ee · 1323 measurements · measured source 3859d93 · machine-readable results · paper and methodology. This selected run differs from the paper's frozen results.
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.
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)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.

