SimplePybsmGenerator

class nrtk.impls.gen_object_detector_blackbox_response.simple_pybsm_generator.SimplePybsmGenerator(images: Sequence[ndarray], img_gsds: Sequence[float], ground_truth: Sequence[Sequence[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]]])

Example implementation of the GenerateObjectDetectorBlackboxResponse interface.

This class generates detection response data for a sequence of images, using ground truth bounding boxes and configurable scoring and perturbation methods.

Attributes:

images (Sequence[np.ndarray]): Sequence of images to process. img_gsds (Sequence[float]): Ground sample distances for each image. ground_truth (Sequence[Sequence[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]]]):

Ground truth bounding boxes with associated labels and scores.

Methods:

generate_response(): Generates a response for each image based on ground truth and scoring.

Methods

from_config

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

generate

Generate item-response curves for given parameters.

get_config

Generates a serializable configuration for the 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.

is_usable

Checks if the required pybsm module is available.

__getitem__(idx: int) tuple[ndarray, Sequence[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]], dict[str, Any]]

Get the image and ground truth pair for a specific index.

Args:

idx (int): Index of the desired data pair.

Raises:

IndexError: If the given index is out of range.

Returns:

tuple: A tuple containing the image, ground truth data, and metadata for the specified index.

__init__(images: Sequence[ndarray], img_gsds: Sequence[float], ground_truth: Sequence[Sequence[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]]]) None

Initializes the SimplePybsmGenerator with input images, ground sample distances, and ground truth.

Args:

images (Sequence[np.ndarray]): Sequence of images for detection. img_gsds (Sequence[float]): Ground sample distances (GSD) for each image. ground_truth (Sequence[Sequence[tuple[AxisAlignedBoundingBox, dict[Hashable, float]]]]):

Ground truth data, containing bounding boxes and associated labels and scores.

Raises:

ImportError: If pybsm library is not available. ValueError: If images and ground_truth do not have the same length.

__len__() int
Returns:

Number of image/ground_truth pairs this generator holds.

generate(blackbox_perturber_factories: Sequence[PerturbImageFactory], blackbox_detector: DetectImageObjects, blackbox_scorer: ScoreDetections, img_batch_size: int, verbose: bool = False) tuple[Sequence[tuple[dict[str, Any], float]], Sequence[Sequence[float]]]

Generate item-response curves for given parameters.

Parameters:
  • blackbox_perturber_factories – Sequence of factories to perturb stimuli.

  • blackbox_detector – Detector to generate detections for perturbed stimuli.

  • blackbox_scorer – Scorer to score detections.

  • img_batch_size – The number of images to predict and score upon at once.

  • verbose – Increases the verbosity of progress updates.

Returns:

Item-response curve

Returns:

Scores for each input stimuli

get_config() dict[str, Any]

Generates a serializable configuration for the instance.

Returns:

dict[str, Any]: Configuration dictionary containing instance parameters.

classmethod is_usable() bool

Checks if the required pybsm module is available.

Returns:

bool: True if pybsm is installed; False otherwise.