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 most augmentation stages run. Every path normalizes on GPU.

AX vs Kornia on 67 shared recipes
AX vs Kornia on 67 shared recipes Scroll horizontally to see the full chart. Open the image for full size.

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.

Benchmark metric

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

R01Resize2244,6912,3292,373
R02RandomCrop2244,4212,2562,255
R03RandomResizedCrop4,7061,9231,955
R04HorizontalFlip3,9552,1282,203
R05VerticalFlip4,2792,0732,207
R06Pad+RandomCrop2244,2441,7921,848
R07Rotate4,4091,5202,248
R08Affine4,1061,5332,271
R09Perspective4,1801,5362,306
R10Elastic3,0327932,371
R11ColorJitter3,569968331
R12ChannelShuffle4,7512,1132,158
R13Grayscale4,8042,0212,197
R14RGBShift4,6552,0282,259
R15GaussianBlur4,3991,2262,134
R16GaussianNoise3,3761,7452,213
R17Invert4,9282,0702,182
R18Posterize4,9681,6622,225
R19Solarize4,6221,9112,212
R20Sharpen4,4811,2822,264
R21AutoContrast4,1601,8342,158
R22Equalize3,9761,5142,219
R23Erasing4,7261,7612,123
R24JpegCompression3,8686682,086
R25RandomGamma4,5861,7152,247
R26PlankianJitter4,3401,9722,225
R27MedianBlur3,758405762
R28MotionBlur4,2131,4742,241
R29CLAHE3,1098122,162
R30Brightness4,6332,0552,151
R31Contrast4,3801,9652,178
R32Blur4,8511,0582,211
R33ChannelDropout4,7322,0592,180
R34LinearIllumination3,8261,8162,174
R35CornerIllumination3,9911,5872,115
R36GaussianIllumination3,7891,5272,206
R37Hue4,0641,0892,191
R38PlasmaBrightness2,6034812,127
R39PlasmaContrast2,2024722,154
R40PlasmaShadow2,5027972,225
R41Rain3,9791,5412,154
R42SaltAndPepper4,7501,533800
R43Saturation4,3541,9752,363
R44Snow3,7331,0852,227
R45OpticalDistortion3,8171,3032,306
R46Shear3,7561,5542,274
R47ThinPlateSpline3,1396432,306
R48PhotoMetricDistort3,482——
R49ColorJiggle3,640975333
R50LongestMaxSize+RandomCrop2243,7291,2631,285
R51SmallestMaxSize+RandomCrop2243,187980971
R52Transpose4,9451,6872,130
R53RandomRotate904,8461,3892,204
R54RandomJigsaw4,4421,8782,245
R55EnhanceEdge4,480——
R56EnhanceDetail4,412——
R57UnsharpMask4,252——
R58CenterCrop4,6582,7442,663
R59Resize256+Crop4,5952,0112,092
R60Resize224+CropAndPad4,2842,2102,264
R61LetterBox4,6492,3662,593
R62PadIfNeeded+RandomCrop2244,4042,3282,173
R63Resize224+ChannelSwap4,5692,1302,266
R64Resize224+Colorize4,2671,4172,253
R65Resize224+Dithering895——
R66Resize224+MorphologicalDilation4,4963601,997
R67Resize224+MorphologicalErosion4,4293632,150
R68RandomScale+RandomCrop2243,6631,1861,123
R69Resize224+RandomSizedCrop4,3131,6102,202
R70Resize224+CoarseDropout4,3621,9052,201
R71Resize224+Emboss4,1591,6522,391
R72Resize224+PixelSpread3,524——
R73Resize224+ShiftScaleRotate3,8421,4122,256

Measurement setup and limits

When a batch arrives late, the GPU sits idle and completes fewer steps in the same time.
When a batch arrives late, the GPU sits idle and completes fewer steps in the same time. Scroll horizontally to see the full chart. Open the image for full size.

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 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.