DRISEStack
- class xaitk_saliency.impls.gen_object_detector_blackbox_sal.drise.DRISEStack(*, n: int, s: int, p1: float, seed: int | None = None, fill: int | Sequence[int] | ndarray[Any, Any] | None = None, threads: int | None = 0)
Encapsulation of the perturbation-occlusion method using RISE image perturbation and DRISE scoring algorithms.
This generates visual saliency maps for object detections. See references in the
RISEGridandDRISEScoringdocumentation.- Example:
>>> from xaitk_saliency._fakes import FakeDetectImageObjects >>> n_dets, height, width = 1, 18, 24 >>> ref_image = np.zeros((height, width, 3), dtype=np.uint8) >>> bboxes = np.array([[0, 0, 8, 8]]) >>> scores = np.array([[0.4, 0.6]]) >>> gen = DRISEStack(n=3, s=4, p1=0.5, seed=0) >>> sal = gen.generate(ref_image=ref_image, bboxes=bboxes, scores=scores, blackbox=FakeDetectImageObjects()) >>> sal.shape == (n_dets, height, width) True
Methods
from_configInstantiate a new instance of this class given the configuration JSON-compliant dictionary encapsulating initialization arguments.
generateGenerate per-detection visual saliency heatmaps for some object detector black-box.
get_configReturn a JSON-compliant dictionary that could be passed to this class's
from_configmethod to produce an instance with identical configuration.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.
is_usableCheck whether this class is available for use.
- __init__(*, n: int, s: int, p1: float, seed: int | None = None, fill: int | Sequence[int] | ndarray[Any, Any] | None = None, threads: int | None = 0) None
Encapsulation of the perturbation-occlusion method using RISE image perturbation and DRISE algorithms.
This generates visual saliency maps for object detections.
- Parameters:
n – Number of random masks used in the algorithm.
s – Spatial resolution of the small masking grid. Assumes square grid.
p1 – Probability of the 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 RISEGrid 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.