Search before asking
Bug
Twelve of the transform names listed under Transform Categories in aug_configs.py raise ValueError on the Kornia backend while working on Albumentations. Because "cpu"/"auto" resolves to Kornia when it is installed and CUDA is available, the same aug_config can train fine on a CPU box and hard-fail on a GPU box.
I built every documented name on both backends on a700efc:
| documented name |
kornia |
albumentations |
HorizontalFlip |
OK |
OK |
VerticalFlip |
OK |
OK |
Rotate |
OK |
OK |
Affine |
OK |
OK |
ShiftScaleRotate |
ValueError |
OK |
RandomCrop |
ValueError |
OK |
CenterCrop |
ValueError |
OK |
RandomResizedCrop |
ValueError |
OK |
Perspective |
ValueError |
OK |
ElasticTransform |
ValueError |
OK |
GridDistortion |
ValueError |
OK |
ColorJitter |
OK |
OK |
HueSaturationValue |
ValueError |
OK |
RandomBrightnessContrast |
OK |
OK |
GaussianBlur |
OK |
OK |
GaussNoise |
OK |
OK |
Blur |
ValueError |
OK |
CLAHE |
ValueError |
OK |
Sharpen |
ValueError |
OK |
Equalize |
ValueError |
OK |
To be fair to the docstring: the Kornia GPU Backend section right below lists exactly the eight that do work, and it is accurate. The mismatch is that the categories list above it reads as the menu of available transforms with no backend caveat, and the two lists disagree. All four shipped presets stay inside the supported eight, so nothing is broken out of the box.
The reason it bites is the failure mode. AlbumentationsWrapper resolves names dynamically (getattr(alb, name, None)), so it picks up anything Albumentations ships. kornia_transforms._REGISTRY is a fixed eight-entry dict, and an unlisted key is a hard ValueError at pipeline-build time, not a warning or a fallback.
#1227 is one instance of this (ToGray, PR #1249).
Environment
- rfdetr at
a700efc (1.9.0), installed with -e .
- kornia 0.8.3, albumentations 2.0.8, torch 2.13.0+cpu
- Windows, CPU only. Kornia builds pipelines identically on CPU, so no GPU is needed to reproduce.
Minimal reproducible example
from rfdetr.datasets.kornia_transforms import build_kornia_pipeline
from rfdetr.datasets.transforms import AlbumentationsWrapper
cfg = {"HueSaturationValue": {"p": 0.5}}
AlbumentationsWrapper.from_config(cfg) # fine
build_kornia_pipeline(cfg, 560) # ValueError: Unknown augmentation key 'HueSaturationValue'
Possible directions
Roughly in increasing order of effort, and entirely your call which is wanted:
- Caveat the categories list, so it says which names are Albumentations-only and points at the Kornia table.
- Map the ones with a direct Kornia equivalent:
Perspective -> K.RandomPerspective, Blur -> K.RandomBoxBlur, Sharpen -> K.RandomSharpness, Equalize -> K.RandomEqualize, HueSaturationValue -> K.ColorJiggle (hue/saturation only).
- Leave the crops and
ElasticTransform/GridDistortion alone, or treat them separately: they interact with boxes and masks, so the semantics need a decision rather than a mapping.
I am happy to send PRs for any of these, sequenced rather than all at once. I would rather not guess at the box-interaction semantics for group 3 without a steer from you.
Are you willing to submit a PR?
Search before asking
Bug
Twelve of the transform names listed under Transform Categories in
aug_configs.pyraiseValueErroron the Kornia backend while working on Albumentations. Because"cpu"/"auto"resolves to Kornia when it is installed and CUDA is available, the sameaug_configcan train fine on a CPU box and hard-fail on a GPU box.I built every documented name on both backends on
a700efc:HorizontalFlipVerticalFlipRotateAffineShiftScaleRotateRandomCropCenterCropRandomResizedCropPerspectiveElasticTransformGridDistortionColorJitterHueSaturationValueRandomBrightnessContrastGaussianBlurGaussNoiseBlurCLAHESharpenEqualizeTo be fair to the docstring: the Kornia GPU Backend section right below lists exactly the eight that do work, and it is accurate. The mismatch is that the categories list above it reads as the menu of available transforms with no backend caveat, and the two lists disagree. All four shipped presets stay inside the supported eight, so nothing is broken out of the box.
The reason it bites is the failure mode.
AlbumentationsWrapperresolves names dynamically (getattr(alb, name, None)), so it picks up anything Albumentations ships.kornia_transforms._REGISTRYis a fixed eight-entry dict, and an unlisted key is a hardValueErrorat pipeline-build time, not a warning or a fallback.#1227 is one instance of this (
ToGray, PR #1249).Environment
a700efc(1.9.0), installed with-e .Minimal reproducible example
Possible directions
Roughly in increasing order of effort, and entirely your call which is wanted:
Perspective->K.RandomPerspective,Blur->K.RandomBoxBlur,Sharpen->K.RandomSharpness,Equalize->K.RandomEqualize,HueSaturationValue->K.ColorJiggle(hue/saturation only).ElasticTransform/GridDistortionalone, or treat them separately: they interact with boxes and masks, so the semantics need a decision rather than a mapping.I am happy to send PRs for any of these, sequenced rather than all at once. I would rather not guess at the box-interaction semantics for group 3 without a steer from you.
Are you willing to submit a PR?