AlbumentationsPerturber
- class nrtk.impls.perturb_image.generic.albumentations_perturber.AlbumentationsPerturber(perturber: str = 'NoOp', parameters: dict[str, Any] | None = None, seed: int | 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.
- 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 = 'NoOp', parameters: dict[str, Any] | None = None, seed: int | None = None) 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 (int):
An optional seed for reproducible results.
- Raises:
- raises ValueError:
Given perturber is not available in Albumentations.
- raises ValueError:
Given perturber does not inherit BasicTransform.
- get_config() dict[str, Any]
Returns the current configuration of the AlbumentationsPerturber instance.
- Returns:
- return dict[str, Any]:
Configuration dictionary with current settings.
- classmethod is_usable() bool
Checks if the required albumentations module is available.
- Returns:
- return bool:
True if albumentations is installed; False otherwise.
- perturb(image: ndarray[Any, Any], boxes: Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None = None, additional_params: dict[str, Any] | None = None) 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.
- additional_params:
Additional parameters for perturbation.
- Returns:
- return tuple[np.ndarray, Iterable[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]] | None]:
Image with transform applied and bounding boxes with their coordinates adjusted by the transform.