AlbumentationsPerturber#
- class nrtk.impls.perturb_image.AlbumentationsPerturber(*, perturber: str = 'NoOp', parameters: dict[str, Any] | None = None, seed: int | None = None, is_static: bool = False)#
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 | None):
Random seed for reproducibility. None for non-deterministic behavior.
- is_static (bool):
If True, resets seed after each call for consistent results.
- _transform (albumentations.Compose):
albumentations pipeline for the transformation
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 plugins, skipping any entrypoints that fail to load.
get_type_stringReturns the fully qualified type string of the PerturbImage class or its subclass.
is_usableCheck whether this class is available for use.
Apply a BasicTransform from Albumentations to an image.
- __init__(*, perturber: str = 'NoOp', parameters: dict[str, Any] | None = None, seed: int | None = None, is_static: bool = False) None#
AlbumentationsPerturber applies a BasicTransform from Albumentations.
- Args:
- perturber:
The name of the BasicTransform perturber to apply. Will apply a NoOp if not provided.
- parameters:
Keyword arguments that should be passed to the given perturber.
- seed:
Random seed for reproducible results. Defaults to None for non-deterministic behavior.
- is_static:
If True and seed is provided, resets seed after each perturb call for consistent results across multiple calls (useful for video frame processing).
- Raises:
- ValueError:
Given perturber is not available in Albumentations.
- ValueError:
Given perturber does not inherit BasicTransform.
- get_config() dict[str, Any]#
Returns the current configuration of the AlbumentationsPerturber instance.
- perturb(*, image: ndarray[Any, Any], boxes: Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None = None, **kwargs: Any) tuple[ndarray[Any, Any], Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None]#
Apply a BasicTransform from Albumentations to an image.
- Args:
- image:
Input image as a numpy array of shape (H, W, C).
- boxes:
List of bounding boxes in AxisAlignedBoundingBox format and their corresponding classes.
- kwargs:
Additional perturbation keyword arguments.
- Returns:
Image with transform applied and bounding boxes with their coordinates adjusted by the transform.