Release notes
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
CustomTransformsApplyMixinbefore 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_paramsoutput, respectp=, and work with replay. No need to subclassComposeor 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
| Transform | Description |
|---|---|
| AtmosphericFog | Depth-dependent fog via scattering (linear or radial depth). |
| ChannelSwap | Fixed channel permutation (e.g. RGB→BGR). |
| FilmGrain | Luminance-dependent, spatially correlated film-style noise. |
| Halftone | Halftone dot pattern (printing-style). |
| LensFlare | Starburst and ghost reflections for optical artifacts. |
| Vignetting | Darkened edges (intensity and center range). |
| GridMask | Grid-line dropout (thin stripes); paper-based. |
| WaterRefraction | Wave-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 efficientapply_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):
Size Baseline Current Speedup 256² 0.83 s 0.28 s 2.9× 512² 3.59 s 0.96 s 3.8× 1024² 11.95 s 5.54 s 2.2×
by @Dipet
Other changes
- Docstring and documentation improvements.