Stay updated

News & Insights
utils

albumentations.augmentations.other.lambda_transform


Lambda transform module for creating custom user-defined transformations. This module provides a flexible transform class that allows users to define their own custom transformation functions for different targets (image, mask, keypoints, bboxes). It's particularly useful for implementing custom logic that isn't available in the standard transforms. The Lambda transform accepts different callable functions for each target type and applies them when the transform is executed. This allows for maximum flexibility while maintaining compatibility with the Albumentations pipeline structure. Key features: - Apply different custom functions to different target types - Compatible with all Albumentations pipeline features - Support for all image types and formats - Ability to handle any number of channels - Warning system for lambda expressions and multiprocessing compatibility Note that using actual lambda expressions (rather than named functions) can cause issues with multiprocessing, as lambdas cannot be properly pickled.

Members

Lambdaclass

Lambda(
    image: Callable[..., Any] | None,
    mask: Callable[..., Any] | None,
    keypoints: Callable[..., Any] | None,
    bboxes: Callable[..., Any] | None,
    name: str | None,
    p: float = 1.0
)

A flexible transformation class for using user-defined transformation functions per targets. Function signature must include **kwargs to accept optional arguments like interpolation method, image size, etc: Args: image (Callable[..., Any] | None): Image transformation function. mask (Callable[..., Any] | None): Mask transformation function. keypoints (Callable[..., Any] | None): Keypoints transformation function. bboxes (Callable[..., Any] | None): BBoxes transformation function. p (float): probability of applying the transform. Default: 1.0. Targets: image, mask, bboxes, keypoints, volume, mask3d Image types: uint8, float32 Supported bboxes: hbb, obb Number of channels: Any

Parameters

NameTypeDefaultDescription
image
One of:
  • Callable[..., Any]
  • None
--
mask
One of:
  • Callable[..., Any]
  • None
--
keypoints
One of:
  • Callable[..., Any]
  • None
--
bboxes
One of:
  • Callable[..., Any]
  • None
--
name
One of:
  • str
  • None
--
pfloat1.0-