PerturberMultivariateFactory#

class nrtk.impls.perturb_image_factory.PerturberMultivariateFactory(*, perturber: type[PerturbImage], theta_keys: Iterable[str], thetas: Sequence[Any], perturber_kwargs: dict[str, Any] | None = None)#

Base factory for creating PerturbImage instances with customizable parameters.

This factory generates multiple PerturbImage instances, each configured with a unique combination of specified perturbation parameters (theta_keys and thetas). These instances allow for flexible image perturbation.

Attributes:

perturber (type[PerturbImage]): Type of the PerturbImage interface to produce. theta_keys (Iterable[str]): Names of parameters to vary across instances. _thetas (Sequence[Any]): Values to vary for each parameter in theta_keys. sets (Sequence[list[int]]): Index combinations for each parameter variation.

Methods

from_config

Instantiates a PerturbImageFactory from a configuration dictionary.

get_config

Returns the current configuration of the PerturberMultivariateFactory instance.

get_default_config

Returns the default configuration for the PerturbImageFactory.

get_impls

Discover plugins, skipping any entrypoints that fail to load.

is_usable

Check whether this class is available for use.

__getitem__(idx: int) PerturbImage#

Retrieves a specific PerturbImage instance by index.

Args:

idx: Index of the desired perturbation configuration (supports negative indices).

Returns:

PerturbImage: The configured PerturbImage instance.

__init__(*, perturber: type[PerturbImage], theta_keys: Iterable[str], thetas: Sequence[Any], perturber_kwargs: dict[str, Any] | None = None) None#

Initializes the PerturberMultivariateFactory.

Args:
perturber:

Python implementation type of the PerturbImage interface to produce.

theta_keys:

Names of perturbation parameters to vary

thetas:

Values to use for each perturbation parameter.

perturber_kwargs:

Default kwargs to be used by the perturber. Defaults to {}.

Raises:
TypeError:

If perturber is an instance instead of a type.

ValueError:

If theta_keys is empty or theta_keys and thetas have different lengths.

__iter__() Iterator[PerturbImage]#

Resets the iterator and returns itself for use in for-loops.

__len__() int#

Returns the number of possible perturbation instances.

__next__() PerturbImage#

Returns the next PerturbImage instance with a unique parameter configuration.

Raises:
StopIteration:

When all configurations have been iterated over.

get_config() dict[str, Any]#

Returns the current configuration of the PerturberMultivariateFactory instance.

property theta_key: str#

Returns the parameter key associated with the perturbation settings.

Returns:

str: The parameter key name, “params”.

property thetas: Sequence[Sequence[Any]]#

Returns the current values for each parameter to be varied.