Albumentations to Kornia Transform Mapping
On this page
- How to Read This Page
- Migration Rules
- Color and Pixel Transforms
- Illumination, Weather, and Procedural Effects
- Geometric Transforms
- Dropout and Annotation-Aware Transforms
- Channel Notes
- Migration Example
- Related Pages
This page maps Albumentations transforms to the closest Kornia API when Kornia has a practical direct equivalent. Use it as a migration and capability guide, not as a performance page.
How to Read This Page
- A named Kornia transform means Kornia has a built-in API for the same broad operation.
-means Kornia does not support that transform as a built-in augmentation primitive.- The table shows built-in Kornia APIs. Custom PyTorch code is not counted as Kornia support.
- Unsupported rows stay visible because transform coverage is part of the library choice.
Migration Rules
- Albumentations expects NumPy arrays, usually per sample in OpenCV-style
H,W,Cchannel-last layout. - Kornia expects PyTorch tensors, usually batched as
B,C,H,W. - Kornia often exposes
same_on_batch,p_batch,align_corners,keepdim, and tensor interpolation settings. - Albumentations exposes target-aware behavior through
A.Compose. - Kornia
AugmentationSequentialcan coordinate configured data keys such as images, masks, boxes, keypoints, classes, and labels; the tensor/data-key setup is part of the migration. - Kornia mix augmentations such as MixUp/CutMix work with image/input keys only. They are useful batch-level tensor policies, not target-aware detection or segmentation policy replacements.
- Albumentations
MosaicandCopyAndPasteare per-sample multi-image policies with target handling. Kornia mix/transplant APIs are tensor/batch policies with different target semantics. - RGB/color-space transforms are not arbitrary-channel transforms in either library.
Color and Pixel Transforms
Illumination, Weather, and Procedural Effects
| Albumentations transform | Kornia transform |
|---|---|
| Illumination with linear mode | RandomLinearIllumination |
| Illumination with corner mode | RandomLinearCornerIllumination |
| Illumination with Gaussian mode | RandomGaussianIllumination |
| PlasmaBrightnessContrast | RandomPlasmaBrightness / RandomPlasmaContrast |
| PlasmaShadow | RandomPlasmaShadow |
| RandomRain | RandomRain |
| RandomFog | - |
| RandomShadow | - |
| RandomSunFlare | - |
| RandomGravel | - |
| AtmosphericFog | - |
| Vignetting | - |
| FilmGrain | - |
| Halftone | - |
| LensFlare | - |
| GridMask | - |
| WaterRefraction | - |
Geometric Transforms
Dropout and Annotation-Aware Transforms
| Albumentations transform | Kornia transform |
|---|---|
| CoarseDropout | - |
| GridDropout | - |
| PixelDropout | - |
| ConstrainedCoarseDropout | - |
| CopyAndPaste | - |
| Mosaic | - |
Channel Notes
Kornia and Albumentations can both operate on non-RGB tensors/arrays for many channel-agnostic transforms. The trap is color semantics: RGBShift, HueSaturationValue, ColorJitter, PlanckianJitter, RandomRain, and RandomSnow are RGB/color transforms.
Blur, crop, resize, flip, affine, perspective, noise, dropout, and normalization are usually safer for arbitrary-channel data. For medical, hyperspectral, remote-sensing, or sensor-fusion inputs, document whether each channel is exchangeable, geometric-only, or color-like before choosing transforms.
Migration Example
Kornia pipelines are tensor-native:
import kornia.augmentation as K
pipeline = K.AugmentationSequential(
K.RandomHorizontalFlip(p=0.5),
K.RandomRotation(degrees=15.0, p=0.5),
K.RandomGaussianNoise(mean=0.0, std=0.1, p=0.2),
data_keys=["input"],
)
The equivalent Albumentations policy is usually applied per sample before tensor conversion:
import albumentations as A
pipeline = A.Compose(
[
A.HorizontalFlip(p=0.5),
A.Rotate(angle_range=(-15, 15), p=0.5),
A.GaussNoise(std_range=(0.05, 0.2), p=0.2),
],
)
For annotation-aware pipelines, Kornia uses AugmentationSequential data keys:
import kornia.augmentation as K
pipeline = K.AugmentationSequential(
K.RandomCrop(size=(512, 512), p=1.0),
K.RandomHorizontalFlip(p=0.5),
data_keys=["input", "bbox"],
)
Albumentations keeps bbox format and label fields in the augmentation policy:
import albumentations as A
pipeline = A.Compose(
[
A.RandomCrop(height=512, width=512, p=1.0),
A.HorizontalFlip(p=0.5),
],
bbox_params=A.BboxParams(coord_format="pascal_voc", label_fields=["labels"]),
)