AlbumentationsPerturber

class nrtk.impls.perturb_image.generic.albumentations_perturber.AlbumentationsPerturber(perturber: str, parameters: dict[str, Any] | None = None, box_alignment_mode: str = 'extent', seed: int | None = None)

AlbumentationsPerturber applies a BasicTransform from Albumentations Methods: perturb: Applies the specified to an input image. __call__: Calls the perturb method with the given input image. get_config: Returns the current configuration of the AlbumentationsPerturber instance.

Methods

from_config

Instantiate a new instance of this class given the configuration JSON-compliant dictionary encapsulating initialization arguments.

get_config

Returns the current configuration of the AlbumentationsPerturber instance.

get_default_config

Generate and return a default configuration dictionary for this class.

get_impls

Discover and return a set of classes that implement the calling class.

get_type_string

Returns the fully qualified type string of the PerturbImage class or its subclass.

is_usable

Checks if the required albumentations module is available.

perturb

Apply a BasicTransform from Albumentations to an image

__init__(perturber: str, parameters: dict[str, Any] | None = None, box_alignment_mode: str = 'extent', seed: int | None = None) None

AlbumentationsPerturber applies a BasicTransform from Albumentations

Attributes:

perturber (string): The name of the BasicTransform perturber to apply parameters (dict): Keyword arguments that should be passed to the given perturber seed (int): An optional seed for reproducible results

get_config() dict[str, Any]

Returns the current configuration of the AlbumentationsPerturber instance.

Returns:

dict[str, Any]: Configuration dictionary with current settings.

classmethod is_usable() bool

Checks if the required albumentations module is available.

Returns:

bool: True if albumentations is installed; False otherwise.

perturb(image: ndarray, boxes: Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None = None, additional_params: dict[str, Any] | None = None) tuple[ndarray, Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None]

Apply a BasicTransform from Albumentations to an image

Parameters:
  • image – Input image as a numpy array of shape (H, W, C).

  • boxes – List of bounding boxes in AxisAlignedBoundingBox format and their corresponding classes.

Returns:

Tuple containing: Image with transform applied as numpy array Bounding boxes with their coordinates adjusted by the transform