Release notes

parrot_demo_output

Summary

This release adds custom apply targets for transforms, eight new transforms (explore.albumentations.ai), and performance improvements for PiecewiseAffine (vectorization), Affine and ISONoise on videos/volumes.


New features

Custom apply methods (apply_to_X)

Transforms can now define custom data targets that are automatically wired into Compose and ReplayCompose.

  • Mixin: Use CustomTransformsApplyMixin before your base class (e.g. class MyAug(CustomTransformsApplyMixin, A.DualTransform)).
  • Convention: Implement methods named apply_to_<key> (e.g. apply_to_label, apply_to_heatmap). They are discovered at init and registered for the corresponding data key.
  • Behavior: Custom targets receive the same get_params output, respect p=, and work with replay. No need to subclass Compose or use ad-hoc pipelines.

Example:

class Rotate90WithLabel(A.CustomTransformsApplyMixin, A.DualTransform):
    def apply(self, img, k=0, **p):
        return np.rot90(img, k)
    def apply_to_mask(self, mask, k=0, **p):
        return np.rot90(mask, k)
    def apply_to_label(self, label, k=0, **p):
        return (label + k) % 4

aug = A.Compose([Rotate90WithLabel(p=1)], seed=42)
out = aug(image=img, mask=mask, label=my_label)  # label handled automatically

by @batiamida


New transforms

TransformDescription
AtmosphericFogDepth-dependent fog via scattering (linear or radial depth).
ChannelSwapFixed channel permutation (e.g. RGB→BGR).
FilmGrainLuminance-dependent, spatially correlated film-style noise.
HalftoneHalftone dot pattern (printing-style).
LensFlareStarburst and ghost reflections for optical artifacts.
VignettingDarkened edges (intensity and center range).
GridMaskGrid-line dropout (thin stripes); paper-based.
WaterRefractionWave-like refraction distortion (amplitude, wavelength, num_waves).

All support images and (where applicable) volumes/masks; see docstrings and explore.albumentations.ai for parameters and examples.

by @ternaus


Performance

Benchmarks below: baseline = commit 9aa0241 (pre–speedup release), same machine, back-to-back runs.

PiecewiseAffine (vectorization)

  • Change: PiecewiseAffine pipeline was vectorized/optimized for single-image and batch usage.
  • Measured speedup: ~200× for single-image apply (512×512×3, 10 iterations: 15.34 s → 0.076 s).

Affine on videos (volumes)

  • Change: Affine implements apply_to_images (and thus efficient apply_to_volume/apply_to_volumes) with a single matrix for the whole batch and a pre-allocated loop.
  • Measured: ~1.02× vs baseline (no regression; comparable).

ISONoise on videos (volumes)

  • Change: ISONoise gained a vectorized apply_to_images (and hence efficient volume handling) so noise is applied in batch instead of per-frame.

  • Measured speedups (volume 16×H×W×3, 30 iterations):

    SizeBaselineCurrentSpeedup
    256²0.83 s0.28 s2.9×
    512²3.59 s0.96 s3.8×
    1024²11.95 s5.54 s2.2×

by @Dipet


Other changes

  • Docstring and documentation improvements.