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.

Benchmark vs Kornia

The benchmark below compares single-threaded RGB image augmentation throughput. Kornia receives normalized tensors; AlbumentationsX receives OpenCV-loaded RGB NumPy arrays. Higher images/second is better.

52 / 53
transforms where AlbumentationsX is faster
4.99x
median speedup
2.74x-10.13x IQR
2.2.5 vs 0.8.2
library versions
from generated benchmark metadata
Transform
albumentationsx
2.2.5
CPU · macOS arm64
Kornia
0.8.2
CPU · macOS arm64
Speedup
Albx / best other (range)
MedianBlur1546 ± 167 ± 0231-240x
Elastic453 ± 24 ± 0123-127x
RandomGamma14482 ± 424252 ± 455-60x
RandomCrop12893574 ± 19643223 ± 1728-30x
Posterize28724 ± 32591080 ± 6722-32x
Erasing27849 ± 40281228 ± 819-26x
Solarize13505 ± 442695 ± 1818-21x
RandomRotate908652 ± 167464 ± 218-19x
CenterCrop12895346 ± 12815226 ± 5718-19x
RandomJigsaw9413 ± 136638 ± 214-15x
MotionBlur3847 ± 49322 ± 612-12x
Grayscale19593 ± 3501679 ± 1611-12x
ColorJiggle1208 ± 16107 ± 011-11x
Blur7544 ± 134745 ± 29.9-10x
HorizontalFlip13200 ± 4301352 ± 89.4-10x
Hue1908 ± 18204 ± 19.2-9.5x
VerticalFlip29169 ± 26573409 ± 37.8-9.3x
Invert31753 ± 13273718 ± 238.1-9.0x
ColorJitter1221 ± 10169 ± 17.1-7.3x
Rotate2996 ± 12442 ± 36.7-6.8x
JpegCompression1351 ± 11202 ± 26.6-6.8x
RandomResizedCrop4354 ± 22653 ± 66.6-6.8x
Saturation1389 ± 27216 ± 16.3-6.6x
Perspective1185 ± 9214 ± 25.4-5.6x
Resize3542 ± 11677 ± 75.2-5.3x
Sharpen2221 ± 35434 ± 65.0-5.3x
SmallestMaxSize2676 ± 7537 ± 15.0-5.0x
ChannelShuffle8235 ± 861729 ± 34.7-4.8x
LongestMaxSize3847 ± 62855 ± 74.4-4.6x
ChannelDropout11971 ± 4342878 ± 114.0-4.3x
Snow754 ± 4188 ± 04.0-4.0x
PlasmaBrightness394 ± 9115 ± 03.3-3.5x
GaussianBlur2462 ± 11717 ± 113.4-3.5x
Contrast10045 ± 1192983 ± 113.3-3.4x
Brightness9849 ± 992992 ± 83.2-3.3x
Affine1456 ± 23456 ± 23.1-3.3x
CLAHE644 ± 5206 ± 13.1-3.2x
RGBShift5025 ± 481710 ± 152.9-3.0x
Equalize1086 ± 12390 ± 62.7-2.9x
Shear1322 ± 7482 ± 42.7-2.8x
GaussianNoise328 ± 20133 ± 12.3-2.6x
AutoContrast1619 ± 44739 ± 142.1-2.3x
PlasmaContrast250 ± 6117 ± 02.1-2.2x
PlasmaShadow526 ± 8281 ± 11.8-1.9x
SaltAndPepper946 ± 4510 ± 11.8-1.9x
OpticalDistortion395 ± 4243 ± 11.6-1.6x
CornerIllumination866 ± 28596 ± 31.4-1.5x
Normalize1642 ± 261226 ± 131.3-1.4x
Rain2169 ± 271725 ± 31.2-1.3x
ThinPlateSpline92 ± 178 ± 01.2-1.2x
GaussianIllumination773 ± 21680 ± 131.1-1.2x
PlankianJitter3278 ± 132996 ± 261.1-1.1x
LinearIllumination557 ± 181195 ± 70.4-0.5x
Colorize3858 ± 11
Dithering6 ± 0
Pad34979 ± 3274
PhotoMetricDistort1070 ± 19
Transpose8184 ± 199
UnsharpMask3063 ± 37

See the aggregate image benchmark or inspect the benchmark source code.

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.