Release 2.6.6

Summary

  • One Affine call can now apply the same sampled rotation, scale, shear, and translation to images, masks, and volumes at different resolutions. #678
  • ReplayCompose checks the recorded height and width of each target when replaying a mixed-size call. #678
  • Saved applied configurations now preserve percentage translations as fractions and record shear in the units and sign accepted by the constructor. #678

Breaking changes

Recapture any applied configurations saved before 2.6.6 from Affine with percentage translation or nonzero shear, or from ShiftScaleRotate with a nonzero shift. The earlier records stored percentage shifts in pixels and saved shear with its sign reversed. This applies to records passed to Compose.from_applied_transforms(). Migration notes

New features

Affine builds one matrix per input height and width when is_check_shapes=False. For example, the same 25% horizontal shift moves a 256-pixel-wide image by 64 pixels and a 128-pixel-wide image by 32. translate_px instead applies the same offset in pixels to both.

import albumentations as A
import numpy as np

augment = A.Compose(
    [A.Affine(translate_percent={"x": (0.25, 0.25), "y": (0, 0)}, p=1)],
    additional_targets={"image_small": "image"},
    is_check_shapes=False,
)
result = augment(
    image=np.zeros((128, 256, 3), dtype=np.uint8),
    image_small=np.zeros((64, 128, 3), dtype=np.uint8),
)

This includes image and mask batches, volumes and their masks, and targets registered through additional_targets. Each batch still has one shape. Volumes use the same warp on every slice. With fit_output=True, each resolution gets its own output bounds. Bounding boxes, keypoints, and vector fields require a common spatial size. Geometry guide

Bug fixes

  • Affine records the sampled percentage translation and shear in constructor form so rebuilding a pipeline from its applied configuration reproduces the warp. ReplayCompose validates each recorded target's spatial size when replaying a mixed-size call. #678

Misc

  • Updated the PyYAML typing stubs used for development. #670

Commits

CommitPRDescription
9d0c867#670Update PyYAML typing stubs
ae7e790#678Support mixed raster sizes in Affine
dac5dc7#679Prepare AlbumentationsX 2.6.6

Full changelog