RandomGridStack
- class xaitk_saliency.impls.gen_object_detector_blackbox_sal.drise.RandomGridStack(n: int, s: tuple[int, int], p1: float, seed: int | None = None, fill: int | Sequence[int] | ndarray | None = None, threads: int = 0)
Encapsulation of the perturbation-occlusion method using the RandomGrid image perturbation and DRISE scoring algorithms to generate visual saliency maps for object detection. See references in the
RandomGrid
andDRISEScoring
documentation.Methods
from_config
Instantiate a new instance of this class given the configuration JSON-compliant dictionary encapsulating initialization arguments.
generate
Generate per-detection visual saliency heatmaps for some object detector black-box over some input reference detections from some input reference image.
get_config
Return a JSON-compliant dictionary that could be passed to this class's
from_config
method to produce an instance with identical configuration.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
Check whether this class is available for use.
- __init__(n: int, s: tuple[int, int], p1: float, seed: int | None = None, fill: int | Sequence[int] | ndarray | None = None, threads: int = 0) None
Encapsulation of the perturbation-occlusion method using the RandomGrid image perturbation and DRISE scoring algorithms to generate visual saliency maps for object detection.
- Parameters:
n – Number of random masks.
s – Dimensions of each grid cell in pixels. E.g. (3, 4) would use a grid of 3x4 pixel cells.
p1 – Probability of a grid cell being set to 1 (not occluded). This should be a float value in the [0, 1] range.
seed – A seed to pass to the constructed random number generator to allow for reproducibility.
fill – Optional fill for alpha-blending the occluded regions based on the masks generated by the RandomGrid perturber. Can be a scalar value, a per-channel sequence or a shape-matched image.
threads – The number of threads to utilize when generating masks. If this is <=0 or None, no threading is used and processing is performed in-line serially.