AlbumentationsX vs Kornia

Compare AlbumentationsX with Kornia for image augmentation: CPU/GPU tradeoffs, RGB benchmark results, and conversion examples.

What Is Different?

Kornia is a differentiable computer vision library for PyTorch tensors. AlbumentationsX is a fast CPU augmentation library for NumPy arrays before data reaches the model.

  • Kornia is tensor-first and shines on batched GPU augmentation; AlbumentationsX is NumPy-first and shines in CPU data-loading pipelines.
  • Kornia transforms can be differentiable and participate in model graphs; AlbumentationsX transforms are preprocessing/data augmentation steps.
  • AlbumentationsX has broad task-level target handling for images, masks, boxes, keypoints, volumes, and multiple related inputs.
  • Kornia is a better fit when augmentation must happen on-device after batching; AlbumentationsX is usually simpler before batching.

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 46 recipes. AlbumentationsX = 1×; higher is faster.
Mean relative throughput on the same 46 recipes. AlbumentationsX = 1×; higher is faster. Scroll horizontally to see the full chart. Open the image for full size.
Same 46 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
Kornia GPU0.49×1,926
Kornia CPU0.34×1,776

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,0631,990
R02RandomCrop2244,7402,0732,107
R03RandomResizedCrop4,7851,7761,746
R04HorizontalFlip4,7232,0112,084
R05VerticalFlip4,9071,9802,151
R06Pad+RandomCrop2244,397
R07Rotate3,3521,4662,122
R08Affine3,0491,4452,138
R09Perspective2,8791,303
R10Elastic1,990102271
R11ColorJitter3,5231,0062,047
R12ChannelShuffle5,0261,9442,120
R13Grayscale5,1571,8922,113
R14RGBShift4,3481,8892,149
R15GaussianBlur4,6791,1892,155
R16GaussianNoise3,2881,6622,022
R17Invert5,0761,9202,167
R18Posterize5,1101,7512,135
R19Solarize4,6071,6552,142
R20Sharpen4,2231,2412,144
R21AutoContrast4,2631,6972,092
R22Equalize3,9861,265523
R23Erasing4,9381,558
R24JpegCompression4,2326842,151
R25RandomGamma4,9691,6862,114
R26PlankianJitter4,5381,8572,125
R27MedianBlur3,8051241,015
R28MotionBlur4,2231,2102,127
R29CLAHE2,373692104
R30Brightness4,6221,8722,101
R31Contrast4,6421,8682,092
R32Blur4,8211,2842,147
R33ChannelDropout4,9721,9112,084
R34LinearIllumination3,8661,698
R35CornerIllumination4,0901,481
R36GaussianIllumination3,9301,492247
R37Hue4,2741,1262,100
R38PlasmaBrightness2,4614692,083
R39PlasmaContrast2,1624772,103
R40PlasmaShadow2,4898322,123
R41Rain4,0691,455517
R42SaltAndPepper4,1471,479437
R43Saturation4,1361,1242,083
R44Snow3,8571,1312,059
R45OpticalDistortion3,1101,4332,100
R46Shear2,6581,508
R47ThinPlateSpline8586962,121
R48PhotoMetricDistort3,369
R49ColorJiggle3,5267582,106
R50LongestMaxSize+RandomCrop2243,6581,0731,066
R51SmallestMaxSize+RandomCrop2243,221845834
R52Transpose4,942
R53RandomRotate905,0021,4622,106
R54RandomJigsaw4,6621,7512,117
R55EnhanceEdge4,389
R56EnhanceDetail4,720
R57UnsharpMask3,120

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 conversion usually moves augmentation from tensor batches in the training step into the Dataset/DataLoader preprocessing path.

  • Apply AlbumentationsX before converting the sample to a tensor.
  • Use ToTensorV2 at the end of the pipeline if the model expects PyTorch tensors.
  • Move per-batch GPU-only transforms to AlbumentationsX only when they do not require differentiability or batched tensor semantics.
  • Keep Kornia for model-integrated or differentiable computer vision operations.
Kornia
import kornia.augmentation as K
import torch.nn as nn

augment = nn.Sequential(
    K.RandomHorizontalFlip(p=0.5),
    K.ColorJitter(brightness=0.2, contrast=0.2, p=0.5),
)

batch = augment(batch)
AlbumentationsX
import albumentations as A
from albumentations.pytorch import ToTensorV2

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

sample = transform(image=image_np)
image = sample["image"]

Use AlbumentationsX When

  • CPU-side data augmentation before batching.
  • Classic supervised CV pipelines with masks, bounding boxes, keypoints, or multiple aligned images.
  • Workloads where augmentation speed in the input pipeline matters more than differentiability.

Use Kornia When

  • Differentiable image processing inside PyTorch models.
  • GPU batched augmentation, especially when the input pipeline is already tensor-native.
  • Research code that needs gradients through geometric or photometric image operations.