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_configInstantiate a new instance of this class given the configuration JSON-compliant dictionary encapsulating initialization arguments.
Returns the current configuration of the AlbumentationsPerturber instance.
get_default_configGenerate and return a default configuration dictionary for this class.
get_implsDiscover and return a set of classes that implement the calling class.
get_type_stringReturns the fully qualified type string of the PerturbImage class or its subclass.
Checks if the required albumentations module is available.
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: np.ndarray, boxes: Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None = None, additional_params: dict[str, Any] | None = None) tuple[np.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