diff --git a/develop/_modules/openvino_xai/explainer/explanation.html b/develop/_modules/openvino_xai/explainer/explanation.html index 278d1f4e..3e9f5781 100644 --- a/develop/_modules/openvino_xai/explainer/explanation.html +++ b/develop/_modules/openvino_xai/explainer/explanation.html @@ -535,21 +535,58 @@

Source code for openvino_xai.explainer.explanation

[docs] - def save(self, dir_path: Path | str, name: str | None = None) -> None: - """Dumps saliency map.""" + def save( + self, + dir_path: Path | str, + prefix: str = "", + postfix: str = "", + confidence_scores: Dict[int, float] | None = None, + ) -> None: + """ + Dumps saliency map images to the specified directory. + + Allows flexibly name the files with the prefix and postfix. + {prefix} + target_id + {postfix}.jpg + + Also allows to add confidence scores to the file names. + {prefix} + target_id + {postfix} + confidence.jpg + + save(output_dir) -> aeroplane.jpg + save(output_dir, prefix="image_name_target_") -> image_name_target_aeroplane.jpg + save(output_dir, postfix="_class_map") -> aeroplane_class_map.jpg + save( + output_dir, prefix="image_name_", postfix="_conf_", confidence_scores=scores + ) -> image_name_aeroplane_conf_0.85.jpg + + Parameters: + :param dir_path: The directory path where the saliency maps will be saved. + :type dir_path: Path | str + :param prefix: Optional prefix for the saliency map names. Default is an empty string. + :type prefix: str + :param postfix: Optional postfix for the saliency map names. Default is an empty string. + :type postfix: str + :param confidence_scores: Dict with confidence scores for each class index. Default is None. + :type confidence_scores: Dict[int, float] | None + + """ + os.makedirs(dir_path, exist_ok=True) - save_name = name if name else "" - for cls_idx, map_to_save in self._saliency_map.items(): + + template = f"{prefix}{{target_name}}{postfix}{{conf_score}}.jpg" + for target_idx, map_to_save in self._saliency_map.items(): + conf_score = "" map_to_save = cv2.cvtColor(map_to_save, code=cv2.COLOR_RGB2BGR) - if isinstance(cls_idx, str): - cv2.imwrite(os.path.join(dir_path, f"{save_name}.jpg"), img=map_to_save) - return + if isinstance(target_idx, str): + target_name = "activation_map" + elif self.label_names and isinstance(target_idx, np.int64): + target_name = self.label_names[target_idx] else: - if self.label_names: - target_name = self.label_names[cls_idx] - else: - target_name = str(cls_idx) - image_name = f"{save_name}_target_{target_name}.jpg" if save_name else f"target_{target_name}.jpg" + target_name = str(target_idx) + + if confidence_scores and target_idx in confidence_scores: + conf_score = f"{confidence_scores[int(target_idx)]:.2f}" + + image_name = template.format(target_name=target_name, conf_score=conf_score) cv2.imwrite(os.path.join(dir_path, image_name), img=map_to_save)
diff --git a/develop/_modules/openvino_xai/methods/black_box/aise.html b/develop/_modules/openvino_xai/methods/black_box/aise.html index abafbb80..49888653 100644 --- a/develop/_modules/openvino_xai/methods/black_box/aise.html +++ b/develop/_modules/openvino_xai/methods/black_box/aise.html @@ -400,11 +400,10 @@

Source code for openvino_xai.methods.black_box.aise

import collections import math -from typing import Callable, Dict, List, Tuple +from typing import Callable, Dict, List, Mapping, Tuple import numpy as np import openvino.runtime as ov -from openvino.runtime.utils.data_helpers.wrappers import OVDict from scipy.optimize import Bounds, direct from openvino_xai.common.utils import ( @@ -427,7 +426,7 @@

Source code for openvino_xai.methods.black_box.aise

:param model: OpenVINO model. :type model: ov.Model :param postprocess_fn: Post-processing function that extract scores from IR model output. - :type postprocess_fn: Callable[[OVDict], np.ndarray] + :type postprocess_fn: Callable[[Mapping], np.ndarray] :param preprocess_fn: Pre-processing function, identity function by default (assume input images are already preprocessed by user). :type preprocess_fn: Callable[[np.ndarray], np.ndarray] @@ -440,7 +439,7 @@

Source code for openvino_xai.methods.black_box.aise

def __init__( self, model: ov.Model, - postprocess_fn: Callable[[OVDict], np.ndarray], + postprocess_fn: Callable[[Mapping], np.ndarray], preprocess_fn: Callable[[np.ndarray], np.ndarray] = IdentityPreprocessFN(), device_name: str = "CPU", prepare_model: bool = True, diff --git a/develop/_modules/openvino_xai/methods/black_box/rise.html b/develop/_modules/openvino_xai/methods/black_box/rise.html index b0062297..87f256cc 100644 --- a/develop/_modules/openvino_xai/methods/black_box/rise.html +++ b/develop/_modules/openvino_xai/methods/black_box/rise.html @@ -419,7 +419,7 @@

Source code for openvino_xai.methods.black_box.rise

:param model: OpenVINO model. :type model: ov.Model :param postprocess_fn: Post-processing function that extract scores from IR model output. - :type postprocess_fn: Callable[[OVDict], np.ndarray] + :type postprocess_fn: Callable[[Mapping], np.ndarray] :param preprocess_fn: Pre-processing function, identity function by default (assume input images are already preprocessed by user). :type preprocess_fn: Callable[[np.ndarray], np.ndarray] diff --git a/develop/_sources/user-guide.md.txt b/develop/_sources/user-guide.md.txt index 23db8cf4..8916e046 100644 --- a/develop/_sources/user-guide.md.txt +++ b/develop/_sources/user-guide.md.txt @@ -23,6 +23,7 @@ Content: - [Black-Box mode](#black-box-mode) - [XAI insertion (white-box usage)](#xai-insertion-white-box-usage) - [Plot saliency maps](#plot-saliency-maps) + - [Saving saliency maps](#saving-saliency-maps) - [Example scripts](#example-scripts) @@ -100,8 +101,8 @@ Here's the example how we can avoid passing `preprocess_fn` by preprocessing dat ```python import cv2 import numpy as np +from typing import Mapping import openvino.runtime as ov -from from typing import Mapping import openvino_xai as xai @@ -137,7 +138,7 @@ explanation = explainer( ) # Save saliency maps -explanation.save("output_path", "name") +explanation.save("output_path", "name_") ``` ### Specifying `preprocess_fn` @@ -146,8 +147,8 @@ explanation.save("output_path", "name") ```python import cv2 import numpy as np -import openvino.runtime as ov from typing import Mapping +import openvino.runtime as ov import openvino_xai as xai @@ -184,7 +185,7 @@ explanation = explainer( ) # Save saliency maps -explanation.save("output_path", "name") +explanation.save("output_path", "name_") ``` @@ -242,7 +243,7 @@ explanation = explainer( ) # Save saliency maps -explanation.save("output_path", "name") +explanation.save("output_path", "name_") ``` @@ -298,7 +299,7 @@ explanation = explainer( ) # Save saliency maps -explanation.save("output_path", "name") +explanation.save("output_path", "name_") ``` @@ -343,7 +344,9 @@ The `cv` backend is better for visualization in Python scripts, as it opens extr import cv2 import numpy as np import openvino.runtime as ov + import openvino_xai as xai +from openvino_xai.explainer import ExplainMode def preprocess_fn(image: np.ndarray) -> np.ndarray: """Preprocess the input image.""" @@ -391,6 +394,97 @@ explanation.plot(targets=[7], backend="cv") explanation.plot(targets=["cat"], backend="cv") ``` +## Saving saliency maps + +You can easily save saliency maps with flexible naming options by using a `prefix` and `postfix`. The `prefix` allows saliency maps from the same image to have consistent naming. + +The format for naming is: + +`{prefix} + target_id + {postfix}.jpg` + +Additionally, you can include the confidence score for each class in the saved saliency map's name. + +`{prefix} + target_id + {postfix} + confidence.jpg` + +```python +import cv2 +import numpy as np +import openvino.runtime as ov +from typing import Mapping + +import openvino_xai as xai +from openvino_xai.explainer import ExplainMode + +def preprocess_fn(image: np.ndarray) -> np.ndarray: + """Preprocess the input image.""" + x = cv2.resize(src=image, dsize=(224, 224)) + x = x.transpose((2, 0, 1)) + processed_image = np.expand_dims(x, 0) + return processed_image + +def postprocess_fn(output: Mapping): + """Postprocess the model output.""" + output = softmax(output) + return output[0] + +def softmax(x: np.ndarray) -> np.ndarray: + """Compute softmax values of x.""" + e_x = np.exp(x - np.max(x)) + return e_x / e_x.sum() + +# Generate and process saliency maps (as many as required, sequentially) +image = cv2.imread("path/to/image.jpg") + +# Create ov.Model +MODEL_PATH = "path/to/model.xml" +model = ov.Core().read_model(MODEL_PATH) # type: ov.Model + +# The Explainer object will prepare and load the model once in the beginning +explainer = xai.Explainer( + model, + task=xai.Task.CLASSIFICATION, + preprocess_fn=preprocess_fn, +) + +voc_labels = [ + 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', + 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor' +] + +# Get predicted confidences for the image +compiled_model = core.compile_model(model=model, device_name="AUTO") +logits = compiled_model(preprocess_fn(image))[0] +result_infer = postprocess_fn(logits) + +# Generate list of predicted class indices and scores +result_idxs = np.argwhere(result_infer > 0.4).flatten() +result_scores = result_infer[result_idxs] + +# Generate dict {class_index: confidence} to save saliency maps +scores_dict = {i: score for i, score in zip(result_idxs, result_scores)} + +# Run explanation +explanation = explainer( + image, + explain_mode=ExplainMode.WHITEBOX, + label_names=voc_labels, + target_explain_labels=result_idxs, # target classes to explain +) + +# Save saliency maps flexibly +OUTPUT_PATH = "output_path" +explanation.save(OUTPUT_PATH) # aeroplane.jpg +explanation.save(OUTPUT_PATH, "image_name_target_") # image_name_target_aeroplane.jpg +explanation.save(OUTPUT_PATH, prefix="image_name_target_") # image_name_target_aeroplane.jpg +explanation.save(OUTPUT_PATH, postfix="_class_map") # aeroplane_class_map.jpg +explanation.save(OUTPUT_PATH, prefix="image_name_", postfix="_class_map") # image_name_aeroplane_class_map.jpg + +# Save saliency maps with confidence scores +explanation.save( + OUTPUT_PATH, prefix="image_name_", postfix="_conf_", confidence_scores=scores_dict +) # image_name_aeroplane_conf_0.85.jpg +``` + ## Example scripts More usage scenarios that can be used with your own models and images as arguments are available in [examples](../../examples). diff --git a/develop/api-manual.html b/develop/api-manual.html index 7add6137..86c70c5b 100644 --- a/develop/api-manual.html +++ b/develop/api-manual.html @@ -617,8 +617,49 @@

Explanation
-save(dir_path: Path | str, name: str | None = None) None[source]#
-

Dumps saliency map.

+save(dir_path: Path | str, prefix: str = '', postfix: str = '', confidence_scores: Dict[int, float] | None = None) None[source]# +

Dumps saliency map images to the specified directory.

+

Allows flexibly name the files with the prefix and postfix. +{prefix} + target_id + {postfix}.jpg

+

Also allows to add confidence scores to the file names. +{prefix} + target_id + {postfix} + confidence.jpg

+

save(output_dir) -> aeroplane.jpg +save(output_dir, prefix=”image_name_target_”) -> image_name_target_aeroplane.jpg +save(output_dir, postfix=”_class_map”) -> aeroplane_class_map.jpg +save(

+
+

output_dir, prefix=”image_name_”, postfix=”_conf_”, confidence_scores=scores

+
+

) -> image_name_aeroplane_conf_0.85.jpg

+
+
Parameters:
+
param dir_path:
+

The directory path where the saliency maps will be saved.

+
+
type dir_path:
+

Path | str

+
+
param prefix:
+

Optional prefix for the saliency map names. Default is an empty string.

+
+
type prefix:
+

str

+
+
param postfix:
+

Optional postfix for the saliency map names. Default is an empty string.

+
+
type postfix:
+

str

+
+
param confidence_scores:
+

Dict with confidence scores for each class index. Default is None.

+
+
type confidence_scores:
+

Dict[int, float] | None

+
+
+
+
@@ -717,7 +758,7 @@

Methods#<

XAI algorithms.

-class openvino_xai.methods.AISE(model: ~openvino.runtime.ie_api.Model, postprocess_fn: ~typing.Callable[[~openvino.runtime.utils.data_helpers.wrappers.OVDict], ~numpy.ndarray], preprocess_fn: ~typing.Callable[[~numpy.ndarray], ~numpy.ndarray] = <openvino_xai.common.utils.IdentityPreprocessFN object>, device_name: str = 'CPU', prepare_model: bool = True)[source]#
+class openvino_xai.methods.AISE(model: ~openvino.runtime.ie_api.Model, postprocess_fn: ~typing.Callable[[~typing.Mapping], ~numpy.ndarray], preprocess_fn: ~typing.Callable[[~numpy.ndarray], ~numpy.ndarray] = <openvino_xai.common.utils.IdentityPreprocessFN object>, device_name: str = 'CPU', prepare_model: bool = True)[source]#

Bases: BlackBoxXAIMethod

AISE explains classification models in black-box mode using AISE: Adaptive Input Sampling for Explanation of Black-box Models @@ -726,7 +767,7 @@

Methods#<
Parameters:
  • model (ov.Model) – OpenVINO model.

  • -
  • postprocess_fn (Callable[[OVDict], np.ndarray]) – Post-processing function that extract scores from IR model output.

  • +
  • postprocess_fn (Callable[[Mapping], np.ndarray]) – Post-processing function that extract scores from IR model output.

  • preprocess_fn (Callable[[np.ndarray], np.ndarray]) – Pre-processing function, identity function by default (assume input images are already preprocessed by user).

  • device_name (str) – Device type name.

  • @@ -847,7 +888,7 @@

    Methods#<
    Parameters:
    diff --git a/develop/objects.inv b/develop/objects.inv index 682051d2..619192cf 100644 Binary files a/develop/objects.inv and b/develop/objects.inv differ diff --git a/develop/searchindex.js b/develop/searchindex.js index ebe7b824..c169719e 100644 --- a/develop/searchindex.js +++ b/develop/searchindex.js @@ -1 +1 @@ -Search.setIndex({"alltitles": {"1 Introduction": [[1, "introduction"]], "2 Automating Code Formatting": [[1, "automating-code-formatting"]], "3 Python Language Rules": [[1, "python-language-rules"]], "3.1 Type Annotated Code": [[1, "type-annotated-code"]], "3.2 Avoid using mutable default arguments": [[1, "avoid-using-mutable-default-arguments"]], "4 Python Style Rules": [[1, "python-style-rules"]], "API": [[0, "api"]], "Basic usage: Auto mode": [[4, "basic-usage-auto-mode"]], "Black-Box mode": [[4, "black-box-mode"]], "Common": [[0, "common"]], "Contents:": [[3, null]], "Contributing": [[2, "contributing"]], "Create Explainer for OpenVINO Model instance": [[4, "create-explainer-for-openvino-model-instance"]], "Create Explainer from ONNX model file": [[4, "create-explainer-from-onnx-model-file"]], "Create Explainer from OpenVINO IR file": [[4, "create-explainer-from-openvino-ir-file"]], "Disclaimer": [[2, "disclaimer"]], "Example scripts": [[4, "example-scripts"]], "Explainer: the main interface to XAI algorithms": [[4, "explainer-the-main-interface-to-xai-algorithms"]], "Explanation": [[0, "explanation"]], "Features": [[2, "features"]], "Hello, OpenVINO XAI": [[2, "hello-openvino-xai"]], "Indices and tables": [[3, "indices-and-tables"]], "Installation": [[2, "installation"]], "License": [[2, "license"]], "Methods": [[0, "methods"]], "More advanced use-cases": [[2, "more-advanced-use-cases"]], "OpenVINO XAI Architecture": [[4, "openvino-xai-architecture"]], "OpenVINO-XAI Python API": [[0, null]], "OpenVINO\u2122 Explainable AI Toolkit - OpenVINO XAI": [[2, null]], "OpenVINO\u2122 Explainable AI Toolkit User Guide": [[4, null]], "Playing with the examples": [[2, "playing-with-the-examples"]], "Plot saliency maps": [[4, "plot-saliency-maps"]], "Quick Start": [[2, "quick-start"]], "Running without preprocess_fn": [[4, "running-without-preprocess-fn"]], "Specifying preprocess_fn": [[4, "specifying-preprocess-fn"]], "Style Guide for Python Code": [[1, null]], "Supported XAI methods": [[2, "supported-xai-methods"]], "Supported explainable models": [[2, "supported-explainable-models"]], "Welcome to OpenVINO\u2122 Explainable AI Toolkit\u2019s documentation!": [[3, null]], "What\u2019s new in v1.0.0": [[2, "what-s-new-in-v1-0-0"]], "White-Box mode": [[4, "white-box-mode"]], "XAI insertion (white-box usage)": [[4, "xai-insertion-white-box-usage"]]}, "docnames": ["api-manual", "coding-guide", "getting-started", "index", "user-guide"], "envversion": {"sphinx": 63, "sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.intersphinx": 1, "sphinx.ext.viewcode": 1}, "filenames": ["api-manual.rst", "coding-guide.md", "getting-started.md", "index.rst", "user-guide.md"], "indexentries": {"__call__() (openvino_xai.explainer.explainer method)": [[0, "openvino_xai.explainer.Explainer.__call__", false]], "__call__() (openvino_xai.explainer.visualizer method)": [[0, "openvino_xai.explainer.Visualizer.__call__", false]], "activationmap (class in openvino_xai.methods)": [[0, "openvino_xai.methods.ActivationMap", false]], "aise (class in openvino_xai.methods)": [[0, "openvino_xai.methods.AISE", false]], "colormap() (in module openvino_xai.explainer)": [[0, "openvino_xai.explainer.colormap", false]], "create_method() (openvino_xai.explainer.explainer method)": [[0, "openvino_xai.explainer.Explainer.create_method", false]], "detclassprobabilitymap (class in openvino_xai.methods)": [[0, "openvino_xai.methods.DetClassProbabilityMap", false]], "explain() (openvino_xai.explainer.explainer method)": [[0, "openvino_xai.explainer.Explainer.explain", false]], "explainer (class in openvino_xai.explainer)": [[0, "openvino_xai.explainer.Explainer", false]], "explainmode (class in openvino_xai.explainer)": [[0, "openvino_xai.explainer.ExplainMode", false]], "explanation (class in openvino_xai.explainer)": [[0, "openvino_xai.explainer.Explanation", false]], "featuremapperturbationbase (class in openvino_xai.methods)": [[0, "openvino_xai.methods.FeatureMapPerturbationBase", false]], "generate_saliency_map() (openvino_xai.methods.aise method)": [[0, "openvino_xai.methods.AISE.generate_saliency_map", false]], "generate_saliency_map() (openvino_xai.methods.rise method)": [[0, "openvino_xai.methods.RISE.generate_saliency_map", false]], "generate_saliency_map() (openvino_xai.methods.whiteboxmethod method)": [[0, "openvino_xai.methods.WhiteBoxMethod.generate_saliency_map", false]], "generate_xai_branch() (openvino_xai.methods.activationmap method)": [[0, "openvino_xai.methods.ActivationMap.generate_xai_branch", false]], "generate_xai_branch() (openvino_xai.methods.detclassprobabilitymap method)": [[0, "openvino_xai.methods.DetClassProbabilityMap.generate_xai_branch", false]], "generate_xai_branch() (openvino_xai.methods.featuremapperturbationbase method)": [[0, "openvino_xai.methods.FeatureMapPerturbationBase.generate_xai_branch", false]], "generate_xai_branch() (openvino_xai.methods.whiteboxmethod method)": [[0, "openvino_xai.methods.WhiteBoxMethod.generate_xai_branch", false]], "has_xai() (in module openvino_xai.common)": [[0, "openvino_xai.common.has_xai", false]], "insert_xai() (in module openvino_xai.api)": [[0, "openvino_xai.api.insert_xai", false]], "layout (class in openvino_xai.explainer)": [[0, "openvino_xai.explainer.Layout", false]], "method (class in openvino_xai.common)": [[0, "openvino_xai.common.Method", false]], "model_forward() (openvino_xai.explainer.explainer method)": [[0, "openvino_xai.explainer.Explainer.model_forward", false]], "module": [[0, "module-openvino_xai.api", false], [0, "module-openvino_xai.common", false], [0, "module-openvino_xai.explainer", false], [0, "module-openvino_xai.methods", false]], "openvino_xai.api": [[0, "module-openvino_xai.api", false]], "openvino_xai.common": [[0, "module-openvino_xai.common", false]], "openvino_xai.explainer": [[0, "module-openvino_xai.explainer", false]], "openvino_xai.methods": [[0, "module-openvino_xai.methods", false]], "overlay() (in module openvino_xai.explainer)": [[0, "openvino_xai.explainer.overlay", false]], "plot() (openvino_xai.explainer.explanation method)": [[0, "openvino_xai.explainer.Explanation.plot", false]], "prepare_model() (openvino_xai.methods.whiteboxmethod method)": [[0, "openvino_xai.methods.WhiteBoxMethod.prepare_model", false]], "reciprocam (class in openvino_xai.methods)": [[0, "openvino_xai.methods.ReciproCAM", false]], "resize() (in module openvino_xai.explainer)": [[0, "openvino_xai.explainer.resize", false]], "rise (class in openvino_xai.methods)": [[0, "openvino_xai.methods.RISE", false]], "saliency_map (openvino_xai.explainer.explanation property)": [[0, "openvino_xai.explainer.Explanation.saliency_map", false]], "save() (openvino_xai.explainer.explanation method)": [[0, "openvino_xai.explainer.Explanation.save", false]], "scaling() (in module openvino_xai.common)": [[0, "openvino_xai.common.scaling", false]], "shape (openvino_xai.explainer.explanation property)": [[0, "openvino_xai.explainer.Explanation.shape", false]], "targets (openvino_xai.explainer.explanation property)": [[0, "openvino_xai.explainer.Explanation.targets", false]], "task (class in openvino_xai.common)": [[0, "openvino_xai.common.Task", false]], "visualize() (openvino_xai.explainer.visualizer method)": [[0, "openvino_xai.explainer.Visualizer.visualize", false]], "visualizer (class in openvino_xai.explainer)": [[0, "openvino_xai.explainer.Visualizer", false]], "vitreciprocam (class in openvino_xai.methods)": [[0, "openvino_xai.methods.ViTReciproCAM", false]], "whiteboxmethod (class in openvino_xai.methods)": [[0, "openvino_xai.methods.WhiteBoxMethod", false]]}, "objects": {"openvino_xai": [[0, 0, 0, "-", "api"], [0, 0, 0, "-", "common"], [0, 0, 0, "-", "explainer"], [0, 0, 0, "-", "methods"]], "openvino_xai.api": [[0, 1, 1, "", "insert_xai"]], "openvino_xai.common": [[0, 2, 1, "", "Method"], [0, 2, 1, "", "Task"], [0, 1, 1, "", "has_xai"], [0, 1, 1, "", "scaling"]], "openvino_xai.explainer": [[0, 2, 1, "", "ExplainMode"], [0, 2, 1, "", "Explainer"], [0, 2, 1, "", "Explanation"], [0, 2, 1, "", "Layout"], [0, 2, 1, "", "Visualizer"], [0, 1, 1, "", "colormap"], [0, 1, 1, "", "overlay"], [0, 1, 1, "", "resize"]], "openvino_xai.explainer.Explainer": [[0, 3, 1, "", "__call__"], [0, 3, 1, "", "create_method"], [0, 3, 1, "", "explain"], [0, 3, 1, "", "model_forward"]], "openvino_xai.explainer.Explanation": [[0, 3, 1, "", "plot"], [0, 4, 1, "", "saliency_map"], [0, 3, 1, "", "save"], [0, 4, 1, "", "shape"], [0, 4, 1, "", "targets"]], "openvino_xai.explainer.Visualizer": [[0, 3, 1, "", "__call__"], [0, 3, 1, "", "visualize"]], "openvino_xai.methods": [[0, 2, 1, "", "AISE"], [0, 2, 1, "", "ActivationMap"], [0, 2, 1, "", "DetClassProbabilityMap"], [0, 2, 1, "", "FeatureMapPerturbationBase"], [0, 2, 1, "", "RISE"], [0, 2, 1, "", "ReciproCAM"], [0, 2, 1, "", "ViTReciproCAM"], [0, 2, 1, "", "WhiteBoxMethod"]], "openvino_xai.methods.AISE": [[0, 3, 1, "", "generate_saliency_map"]], "openvino_xai.methods.ActivationMap": [[0, 3, 1, "", "generate_xai_branch"]], "openvino_xai.methods.DetClassProbabilityMap": [[0, 3, 1, "", "generate_xai_branch"]], "openvino_xai.methods.FeatureMapPerturbationBase": [[0, 3, 1, "", "generate_xai_branch"]], "openvino_xai.methods.RISE": [[0, 3, 1, "", "generate_saliency_map"]], "openvino_xai.methods.WhiteBoxMethod": [[0, 3, 1, "", "generate_saliency_map"], [0, 3, 1, "", "generate_xai_branch"], [0, 3, 1, "", "prepare_model"]]}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "function", "Python function"], "2": ["py", "class", "Python class"], "3": ["py", "method", "Python method"], "4": ["py", "property", "Python property"]}, "objtypes": {"0": "py:module", "1": "py:function", "2": "py:class", "3": "py:method", "4": "py:property"}, "terms": {"": [0, 1, 4], "0": [0, 4], "07421": 0, "1": [0, 3, 4], "10": 2, "11": 4, "14": 4, "1806": 0, "2": [0, 2, 3, 4], "2024": 2, "224": [2, 4], "23": 0, "24": 0, "255": [0, 4], "26": 2, "29": 2, "293": 2, "3": [2, 3], "30": 2, "4": [0, 3, 4], "484": 1, "5": [0, 4], "604": 1, "7": 4, "8": [0, 1], "A": [0, 2], "As": 4, "At": 2, "By": [0, 2, 4], "For": [2, 4], "If": [0, 1, 4], "In": [2, 4], "Not": 0, "The": [0, 4], "There": 4, "To": [0, 1, 4], "With": 0, "__call__": 0, "ab": 0, "about": 4, "abov": 4, "abstract": 0, "abus": 2, "accept": 2, "access": 0, "accord": [1, 2], "activ": 2, "activationmap": [0, 2], "actual": 2, "ad": 4, "adapt": 0, "add": 0, "add_to_list": 1, "addit": [2, 4], "aeroplan": 4, "affect": 4, "after": [0, 4], "aggreg": 0, "agjust": 4, "agnost": 2, "agre": 2, "ai": 1, "ais": [0, 2, 4], "algorithm": [0, 2, 3], "all": [0, 1, 2, 4], "alreadi": [0, 4], "also": [1, 2, 4], "altern": 4, "among": 0, "an": [2, 4], "analysi": 2, "analyz": [2, 4], "anchor": 0, "ani": [1, 2, 4], "anim": 2, "apach": 2, "api": [2, 3, 4], "append": 1, "appli": [0, 4], "applic": 2, "appreci": 2, "approach": 4, "ar": [0, 2, 4], "architectur": [2, 3], "area": 2, "arg": 0, "argument": [2, 4], "around": 2, "arrai": 0, "arxiv": [0, 2], "asset": [2, 4], "assum": 0, "atss": 0, "augment": 2, "auto": [0, 2, 3], "autom": 3, "automat": [1, 2], "avail": [0, 4], "avoid": [0, 2, 4], "backbon": 4, "backend": [0, 4], "balanc": 0, "bandwidth": 0, "base": [0, 2, 4], "basic": [2, 3], "batch": 4, "befor": [0, 1], "beforehand": 4, "begin": 4, "behavior": 2, "below": 4, "best": 2, "better": 4, "bhw": 0, "bhwc": 0, "bias": 0, "bicycl": 4, "bin": 2, "bird": 4, "black": [0, 1, 2, 3], "blackbox": [0, 4], "blackboxxaimethod": 0, "block": 0, "bnhw": 0, "bnhwc": 0, "boat": 4, "bodi": 2, "bool": 0, "bottl": 4, "box": [0, 2, 3], "branch": [0, 2, 4], "bu": 4, "budget": 0, "build": 1, "built": 4, "bunch": [2, 4], "call": [0, 2, 4], "callabl": 0, "cam": 0, "can": [0, 1, 2, 4], "car": 4, "case": [1, 4], "cast_to_uint8": 0, "cat": 4, "caus": 2, "cd": 2, "cell": 0, "chair": 4, "chang": [1, 2, 4], "check": [0, 1, 2], "cheetah": 2, "cheetah_person": [2, 4], "cl": 0, "class": [0, 2, 4], "classif": [0, 2, 4], "classprobabilitymap": 2, "clone": 2, "cls_token": 0, "cnn": [0, 2, 4], "code": [2, 3, 4], "codebas": 1, "colormap": 0, "colormap_typ": 0, "column": 0, "com": 2, "command": 1, "commit": [1, 2], "common": 3, "compil": 0, "complex": 2, "complic": 2, "compris": 1, "comput": [0, 2, 4], "con": 4, "configur": [0, 1], "consist": 1, "contain": [0, 2], "content": 4, "contribut": 3, "conveni": 4, "convent": 1, "convers": 2, "convert": 2, "convolut": 4, "copyright": 2, "core": [2, 4], "correspond": [2, 4], "could": 2, "count": 0, "cow": 4, "cpu": 0, "creat": [0, 2], "create_method": 0, "current": 4, "custom": [0, 2, 4], "cv": [0, 4], "cv2": [2, 4], "data": [0, 2, 4], "data_help": 0, "debug": 2, "decid": 2, "deep": 2, "def": [1, 4], "default": [0, 2, 4], "defin": 0, "depend": [0, 4], "describ": 0, "detail": [2, 4], "detclassprobabilitymap": 0, "detect": [0, 2], "detector": 0, "dev": 2, "develop": 2, "devic": 0, "device_nam": 0, "dict": 0, "differ": [0, 2], "dimens": 4, "dimension": 0, "diningt": 4, "dir_path": [0, 2], "direct": 0, "directli": [2, 4], "directori": [2, 4], "disabl": 1, "disclaim": 3, "displai": 4, "dive": 2, "divers": 2, "do": [1, 2, 4], "document": [1, 2, 4], "doe": 4, "dog": 4, "domain": 2, "don": 1, "download": [2, 4], "downstream": 4, "dsize": [2, 4], "dump": 0, "dure": 4, "e": [0, 2], "easiest": 4, "edit": 2, "effcient": 0, "effect": 4, "either": [0, 4], "embed": [0, 4], "embed_sc": [0, 4], "enabl": 2, "ensur": 1, "enum": 0, "enumer": 2, "env": 2, "environ": 2, "epsilon": 0, "error": 2, "even": 2, "exampl": 3, "exist": 2, "expand_dim": [2, 4], "expanded_imag": 4, "expect": 2, "experiment": 2, "explain": [0, 1], "explain_method": [0, 4], "explain_mod": [0, 4], "explainmod": [0, 4], "explainresult": 0, "explan": [2, 3, 4], "expos": 2, "extra": [2, 4], "extract": 0, "fail": 4, "fals": [0, 2, 4], "fast": [2, 4], "featur": 3, "featuremapperturb": 0, "featuremapperturbationbas": 0, "feed": 2, "few": [2, 4], "file": [0, 1, 2], "fill": 0, "final_norm": 0, "finction": 0, "find": 2, "first": 4, "flag": 0, "flexibl": 4, "float": 0, "focus": 2, "follow": [0, 1, 2, 4], "format": [3, 4], "forward": [0, 4], "found": [1, 4], "from": [0, 2], "full": 2, "fulli": 2, "func": 1, "function": [0, 2, 4], "g": 0, "gaussian": 0, "genai": 2, "gener": [0, 2, 4], "generate_saliency_map": 0, "generate_xai_branch": 0, "get": [0, 2, 3], "git": 2, "github": 2, "give": [1, 2], "given": 2, "global": 2, "graph": [0, 4], "grayscal": 0, "grid": [0, 4], "guid": [2, 3], "guidelin": 1, "ha": [0, 4], "has_xai": 0, "have": [0, 2], "head": [0, 2], "help": [2, 4], "here": [0, 4], "higher": 2, "highlight": 2, "hint": 1, "histori": 2, "hold": 0, "hood": 4, "hors": 4, "how": 4, "howev": 4, "http": [0, 2], "human": 2, "hundr": 4, "i": [0, 1, 2, 4], "id": 1, "ident": 0, "identifi": 4, "identitypreprocessfn": 0, "ie_api": 0, "imag": [0, 2, 4], "imagin": 2, "implement": [0, 4], "import": [1, 2, 4], "imread": [2, 4], "includ": 2, "increment": 2, "index": [0, 3], "indic": [0, 2, 4], "infer": [0, 2, 4], "inner": 4, "input": [0, 2, 4], "input_imag": 0, "insert": [0, 2, 3], "insert_xai": [0, 2, 4], "instal": 3, "instead": 4, "int": [0, 1], "integ": 0, "intel": 2, "intend": 2, "interest": 2, "interfac": [0, 2, 3], "intermedi": [2, 3, 4], "internation": 2, "introduct": 3, "involv": 4, "ir": [0, 2, 3], "isort": 1, "issu": [0, 2], "item": 1, "iter": 0, "its": 0, "jpg": [2, 4], "jupyt": [0, 4], "k": 0, "kernel": 0, "kernel_width": 0, "know": 2, "known": 2, "kwarg": 0, "label": [0, 2, 4], "label_nam": [0, 2, 4], "languag": 3, "larg": 0, "last": [0, 4], "last_conv_node_nam": 4, "later": 0, "layer": [0, 4], "layout": 0, "learn": 4, "let": 2, "librari": [2, 4], "licens": 3, "like": [1, 2, 4], "limit": 2, "line": 2, "link": [0, 2], "list": [0, 1], "llm": 2, "load": [0, 2, 4], "load_model": 0, "local": 0, "locally_bias": 0, "log": 2, "logic": 0, "logit": 4, "look": [2, 4], "low": 0, "m": 2, "machin": 4, "mai": 2, "main": [2, 3], "maintain": 1, "major": 4, "make": 4, "manag": 0, "mandatori": 1, "mani": 4, "manual": 3, "map": [0, 2, 3], "mask": 0, "matplotlib": [0, 4], "max": 0, "max_num_plot": 0, "mean": 0, "measur": 4, "memori": 0, "mention": 4, "method": [3, 4], "methodbas": 0, "might": 2, "mlc_mobilenetv3_large_voc": [2, 4], "mobilenet_v3": 2, "mode": [0, 2, 3], "model": 0, "model_forward": 0, "model_path": 4, "model_xai": [0, 4], "modif": 4, "modifi": 0, "modul": 3, "moment": 2, "more": 4, "mosaic": 0, "most": 2, "motorbik": 4, "multipl": [0, 2], "multiple_maps_per_image_color": 0, "multiple_maps_per_image_grai": 0, "mypi": 1, "name": [0, 2, 4], "ndarrai": [0, 2, 4], "need": [2, 4], "negvet": 0, "new": 4, "node": [0, 4], "none": [0, 1], "normal": [0, 2], "note": [2, 4], "notebook": [2, 4], "np": [0, 2, 4], "num": 1, "num_anchor": 0, "num_cel": 0, "num_collumn": 4, "num_column": [0, 4], "num_iterations_per_kernel": 0, "num_mask": 0, "number": 0, "numpi": [0, 2, 4], "nutshel": 4, "o": 0, "object": [0, 2, 4], "observ": 2, "older": 2, "omit": 0, "onc": 4, "one": [0, 4], "one_map_per_image_color": 0, "one_map_per_image_grai": 0, "onli": 2, "onnx": [0, 2], "op": 0, "open": 4, "opencv": 4, "openvino": 1, "openvino_xai": [0, 2, 4], "openvinotoolkit": 2, "oper": [0, 4], "optim": 0, "option": [0, 2, 4], "order": 0, "org": 0, "origin": [0, 2, 4], "original_input_imag": [0, 4], "otherwis": 0, "otx_model": [2, 4], "our": [2, 4], "output": [0, 2, 4], "output_path": 4, "output_s": 0, "ov": [0, 2, 4], "ov_model": 2, "ovc": 2, "ovdict": 0, "over": [0, 2], "overhead": 4, "overlai": [0, 2, 4], "overlay_weight": 0, "ovxai": 2, "own": 4, "p": 0, "packag": 2, "page": 3, "paper": 0, "paramet": [0, 4], "part": 4, "pass": [0, 2, 4], "path": [0, 2, 4], "pathlik": 0, "pep": 1, "per": [0, 2, 4], "perform": 4, "person": 4, "perspect": 2, "perturb": 4, "pick": 4, "pip": 2, "pipelin": [2, 4], "pleas": 2, "plot": [0, 3], "possibl": 4, "post": [0, 2, 4], "postprocess": 0, "postprocess_fn": [0, 4], "pottedpl": 4, "pre": [0, 1, 2, 4], "predefin": 0, "predict": [0, 4], "prepar": [0, 2, 4], "prepare_model": 0, "preprocess": [0, 4], "preprocess_fn": 0, "preprocessed_imag": 4, "preset": 0, "primarili": 4, "principl": 2, "prior": 0, "pro": 4, "prob": 0, "process": [0, 2, 4], "product": 2, "project": 2, "properli": 1, "properti": 0, "provid": [0, 2, 3, 4], "purpos": 2, "py": [2, 4], "pypi": 2, "pytest": [2, 4], "python": [2, 3, 4], "python3": 2, "pytorch": 2, "qualiti": [0, 2], "question": 2, "quick": 3, "quit": 4, "random": 0, "rang": [0, 4], "raw": 0, "re": 0, "read_model": [2, 4], "readabl": 1, "reason": 2, "recipro": 0, "reciprocam": [0, 2, 4], "recogn": 2, "recommend": [0, 1, 4], "refer": 2, "region": 2, "rel": 4, "releas": 2, "repositori": 2, "repres": [0, 4], "represent": [2, 3, 4], "request": 2, "requir": [0, 1, 4], "resiz": [0, 2, 4], "resized_imag": 4, "respect": 2, "respons": [2, 4], "result": [0, 4], "retriev": 4, "return": [0, 1, 4], "right": 2, "rise": [0, 2, 4], "row": 4, "rule": 3, "run": [1, 2], "run_classif": [2, 4], "runnabl": 2, "runtim": [0, 2, 4], "salienc": [0, 2, 3], "saliency_map": [0, 4], "saliency_map_s": 0, "same": 2, "sampl": 0, "save": [0, 1, 2, 4], "scale": [0, 4], "scale_output": 0, "scenario": [2, 4], "score": 0, "script": [0, 2, 3], "search": 3, "see": 2, "seed": 0, "select": [0, 2], "self": 0, "sequenti": 4, "set": [0, 1, 2, 4], "shape": 0, "sheep": 4, "should": [1, 4], "simpl": 2, "sinc": 4, "singl": 0, "size": 0, "skin": 2, "slow": 2, "small": 4, "so": 4, "sofa": 4, "softwar": 2, "solver": 0, "solver_epsilon": 0, "some": 0, "sourc": [0, 2], "specif": [0, 1, 2, 4], "specifi": 0, "speed": 0, "src": [2, 4], "ssd": 0, "stage": 0, "start": 3, "state": 2, "step": [0, 4], "store": [2, 4], "str": [0, 1, 2], "string": 4, "style": 3, "suit": [2, 3, 4], "supplement": 1, "support": 4, "t": 1, "tab": 2, "target": [0, 2, 4], "target_explain_label": 4, "target_id": 0, "target_indic": 0, "target_lay": [0, 4], "task": [0, 2, 4], "tbd": 1, "tell": 2, "term": 2, "test": [2, 4], "test_classif": [2, 4], "thank": 2, "them": [0, 2], "therefor": 0, "therein": 2, "thi": [0, 1, 2, 4], "those": 2, "thousand": 4, "throughout": 1, "time": [1, 2], "timm": 2, "todo": 0, "token": 0, "tool": 1, "toolkit": 1, "top": 2, "torch": 2, "tradeoff": 0, "train": 4, "transform": [0, 2], "treat": 4, "true": [0, 2, 4], "try": [2, 4], "tupl": 0, "tutori": 4, "tvmonitor": 4, "tweak": 2, "two": 4, "type": [0, 2, 4], "u": 2, "under": [2, 4], "understand": 2, "unit": 2, "unsupport": 2, "up": [0, 2], "upcom": 2, "updat": [1, 4], "us": [0, 4], "usag": [0, 3], "use_gaussian": 0, "user": [0, 2, 3], "usual": 4, "util": 0, "v": 2, "valid": [2, 4], "valu": [0, 1], "vari": 4, "venv": 2, "verifi": 2, "version": 2, "via": 2, "violat": 2, "virtual": 2, "vision": 2, "visual": [0, 2, 4], "visualizationparamet": 0, "vitrecipro": 0, "vitreciprocam": [0, 2], "voc_label": 4, "wa": 4, "wai": 4, "want": 2, "warn": 2, "watch": 2, "we": [1, 2, 4], "weight": 0, "well": 2, "were": 1, "when": [0, 1], "whether": 0, "which": [0, 2, 4], "while": 2, "white": [0, 2, 3], "whitebox": [0, 4], "whiteboxmethod": 0, "who": 2, "whole": 0, "why": 2, "wide": 4, "window": 4, "work": [2, 4], "workaround": 2, "would": 2, "wrapper": 0, "x": [0, 4], "xai": 3, "xml": [0, 2, 4], "yolox": 0, "you": [1, 2, 4], "your": [1, 2, 4]}, "titles": ["OpenVINO-XAI Python API", "Style Guide for Python Code", "OpenVINO\u2122 Explainable AI Toolkit - OpenVINO XAI", "Welcome to OpenVINO\u2122 Explainable AI Toolkit\u2019s documentation!", "OpenVINO\u2122 Explainable AI Toolkit User Guide"], "titleterms": {"": [2, 3], "0": 2, "1": 1, "2": 1, "3": 1, "4": 1, "advanc": 2, "ai": [2, 3, 4], "algorithm": 4, "annot": 1, "api": 0, "architectur": 4, "argument": 1, "auto": 4, "autom": 1, "avoid": 1, "basic": 4, "black": 4, "box": 4, "case": 2, "code": 1, "common": 0, "content": 3, "contribut": 2, "creat": 4, "default": 1, "disclaim": 2, "document": 3, "exampl": [2, 4], "explain": [2, 3, 4], "explan": 0, "featur": 2, "file": 4, "format": 1, "from": 4, "guid": [1, 4], "hello": 2, "indic": 3, "insert": 4, "instal": 2, "instanc": 4, "interfac": 4, "introduct": 1, "ir": 4, "languag": 1, "licens": 2, "main": 4, "map": 4, "method": [0, 2], "mode": 4, "model": [2, 4], "more": 2, "mutabl": 1, "new": 2, "onnx": 4, "openvino": [0, 2, 3, 4], "plai": 2, "plot": 4, "preprocess_fn": 4, "python": [0, 1], "quick": 2, "rule": 1, "run": 4, "salienc": 4, "script": 4, "specifi": 4, "start": 2, "style": 1, "support": 2, "tabl": 3, "toolkit": [2, 3, 4], "type": 1, "us": [1, 2], "usag": 4, "user": 4, "v1": 2, "welcom": 3, "what": 2, "white": 4, "without": 4, "xai": [0, 2, 4]}}) \ No newline at end of file +Search.setIndex({"alltitles": {"1 Introduction": [[1, "introduction"]], "2 Automating Code Formatting": [[1, "automating-code-formatting"]], "3 Python Language Rules": [[1, "python-language-rules"]], "3.1 Type Annotated Code": [[1, "type-annotated-code"]], "3.2 Avoid using mutable default arguments": [[1, "avoid-using-mutable-default-arguments"]], "4 Python Style Rules": [[1, "python-style-rules"]], "API": [[0, "api"]], "Basic usage: Auto mode": [[4, "basic-usage-auto-mode"]], "Black-Box mode": [[4, "black-box-mode"]], "Common": [[0, "common"]], "Contents:": [[3, null]], "Contributing": [[2, "contributing"]], "Create Explainer for OpenVINO Model instance": [[4, "create-explainer-for-openvino-model-instance"]], "Create Explainer from ONNX model file": [[4, "create-explainer-from-onnx-model-file"]], "Create Explainer from OpenVINO IR file": [[4, "create-explainer-from-openvino-ir-file"]], "Disclaimer": [[2, "disclaimer"]], "Example scripts": [[4, "example-scripts"]], "Explainer: the main interface to XAI algorithms": [[4, "explainer-the-main-interface-to-xai-algorithms"]], "Explanation": [[0, "explanation"]], "Features": [[2, "features"]], "Hello, OpenVINO XAI": [[2, "hello-openvino-xai"]], "Indices and tables": [[3, "indices-and-tables"]], "Installation": [[2, "installation"]], "License": [[2, "license"]], "Methods": [[0, "methods"]], "More advanced use-cases": [[2, "more-advanced-use-cases"]], "OpenVINO XAI Architecture": [[4, "openvino-xai-architecture"]], "OpenVINO-XAI Python API": [[0, null]], "OpenVINO\u2122 Explainable AI Toolkit - OpenVINO XAI": [[2, null]], "OpenVINO\u2122 Explainable AI Toolkit User Guide": [[4, null]], "Playing with the examples": [[2, "playing-with-the-examples"]], "Plot saliency maps": [[4, "plot-saliency-maps"]], "Quick Start": [[2, "quick-start"]], "Running without preprocess_fn": [[4, "running-without-preprocess-fn"]], "Saving saliency maps": [[4, "saving-saliency-maps"]], "Specifying preprocess_fn": [[4, "specifying-preprocess-fn"]], "Style Guide for Python Code": [[1, null]], "Supported XAI methods": [[2, "supported-xai-methods"]], "Supported explainable models": [[2, "supported-explainable-models"]], "Welcome to OpenVINO\u2122 Explainable AI Toolkit\u2019s documentation!": [[3, null]], "What\u2019s new in v1.0.0": [[2, "what-s-new-in-v1-0-0"]], "White-Box mode": [[4, "white-box-mode"]], "XAI insertion (white-box usage)": [[4, "xai-insertion-white-box-usage"]]}, "docnames": ["api-manual", "coding-guide", "getting-started", "index", "user-guide"], "envversion": {"sphinx": 63, "sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.intersphinx": 1, "sphinx.ext.viewcode": 1}, "filenames": ["api-manual.rst", "coding-guide.md", "getting-started.md", "index.rst", "user-guide.md"], "indexentries": {"__call__() (openvino_xai.explainer.explainer method)": [[0, "openvino_xai.explainer.Explainer.__call__", false]], "__call__() (openvino_xai.explainer.visualizer method)": [[0, "openvino_xai.explainer.Visualizer.__call__", false]], "activationmap (class in openvino_xai.methods)": [[0, "openvino_xai.methods.ActivationMap", false]], "aise (class in openvino_xai.methods)": [[0, "openvino_xai.methods.AISE", false]], "colormap() (in module openvino_xai.explainer)": [[0, "openvino_xai.explainer.colormap", false]], "create_method() (openvino_xai.explainer.explainer method)": [[0, "openvino_xai.explainer.Explainer.create_method", false]], "detclassprobabilitymap (class in openvino_xai.methods)": [[0, "openvino_xai.methods.DetClassProbabilityMap", false]], "explain() (openvino_xai.explainer.explainer method)": [[0, "openvino_xai.explainer.Explainer.explain", false]], "explainer (class in openvino_xai.explainer)": [[0, "openvino_xai.explainer.Explainer", false]], "explainmode (class in openvino_xai.explainer)": [[0, "openvino_xai.explainer.ExplainMode", false]], "explanation (class in openvino_xai.explainer)": [[0, "openvino_xai.explainer.Explanation", false]], "featuremapperturbationbase (class in openvino_xai.methods)": [[0, "openvino_xai.methods.FeatureMapPerturbationBase", false]], "generate_saliency_map() (openvino_xai.methods.aise method)": [[0, "openvino_xai.methods.AISE.generate_saliency_map", false]], "generate_saliency_map() (openvino_xai.methods.rise method)": [[0, "openvino_xai.methods.RISE.generate_saliency_map", false]], "generate_saliency_map() (openvino_xai.methods.whiteboxmethod method)": [[0, "openvino_xai.methods.WhiteBoxMethod.generate_saliency_map", false]], "generate_xai_branch() (openvino_xai.methods.activationmap method)": [[0, "openvino_xai.methods.ActivationMap.generate_xai_branch", false]], "generate_xai_branch() (openvino_xai.methods.detclassprobabilitymap method)": [[0, "openvino_xai.methods.DetClassProbabilityMap.generate_xai_branch", false]], "generate_xai_branch() (openvino_xai.methods.featuremapperturbationbase method)": [[0, "openvino_xai.methods.FeatureMapPerturbationBase.generate_xai_branch", false]], "generate_xai_branch() (openvino_xai.methods.whiteboxmethod method)": [[0, "openvino_xai.methods.WhiteBoxMethod.generate_xai_branch", false]], "has_xai() (in module openvino_xai.common)": [[0, "openvino_xai.common.has_xai", false]], "insert_xai() (in module openvino_xai.api)": [[0, "openvino_xai.api.insert_xai", false]], "layout (class in openvino_xai.explainer)": [[0, "openvino_xai.explainer.Layout", false]], "method (class in openvino_xai.common)": [[0, "openvino_xai.common.Method", false]], "model_forward() (openvino_xai.explainer.explainer method)": [[0, "openvino_xai.explainer.Explainer.model_forward", false]], "module": [[0, "module-openvino_xai.api", false], [0, "module-openvino_xai.common", false], [0, "module-openvino_xai.explainer", false], [0, "module-openvino_xai.methods", false]], "openvino_xai.api": [[0, "module-openvino_xai.api", false]], "openvino_xai.common": [[0, "module-openvino_xai.common", false]], "openvino_xai.explainer": [[0, "module-openvino_xai.explainer", false]], "openvino_xai.methods": [[0, "module-openvino_xai.methods", false]], "overlay() (in module openvino_xai.explainer)": [[0, "openvino_xai.explainer.overlay", false]], "plot() (openvino_xai.explainer.explanation method)": [[0, "openvino_xai.explainer.Explanation.plot", false]], "prepare_model() (openvino_xai.methods.whiteboxmethod method)": [[0, "openvino_xai.methods.WhiteBoxMethod.prepare_model", false]], "reciprocam (class in openvino_xai.methods)": [[0, "openvino_xai.methods.ReciproCAM", false]], "resize() (in module openvino_xai.explainer)": [[0, "openvino_xai.explainer.resize", false]], "rise (class in openvino_xai.methods)": [[0, "openvino_xai.methods.RISE", false]], "saliency_map (openvino_xai.explainer.explanation property)": [[0, "openvino_xai.explainer.Explanation.saliency_map", false]], "save() (openvino_xai.explainer.explanation method)": [[0, "openvino_xai.explainer.Explanation.save", false]], "scaling() (in module openvino_xai.common)": [[0, "openvino_xai.common.scaling", false]], "shape (openvino_xai.explainer.explanation property)": [[0, "openvino_xai.explainer.Explanation.shape", false]], "targets (openvino_xai.explainer.explanation property)": [[0, "openvino_xai.explainer.Explanation.targets", false]], "task (class in openvino_xai.common)": [[0, "openvino_xai.common.Task", false]], "visualize() (openvino_xai.explainer.visualizer method)": [[0, "openvino_xai.explainer.Visualizer.visualize", false]], "visualizer (class in openvino_xai.explainer)": [[0, "openvino_xai.explainer.Visualizer", false]], "vitreciprocam (class in openvino_xai.methods)": [[0, "openvino_xai.methods.ViTReciproCAM", false]], "whiteboxmethod (class in openvino_xai.methods)": [[0, "openvino_xai.methods.WhiteBoxMethod", false]]}, "objects": {"openvino_xai": [[0, 0, 0, "-", "api"], [0, 0, 0, "-", "common"], [0, 0, 0, "-", "explainer"], [0, 0, 0, "-", "methods"]], "openvino_xai.api": [[0, 1, 1, "", "insert_xai"]], "openvino_xai.common": [[0, 2, 1, "", "Method"], [0, 2, 1, "", "Task"], [0, 1, 1, "", "has_xai"], [0, 1, 1, "", "scaling"]], "openvino_xai.explainer": [[0, 2, 1, "", "ExplainMode"], [0, 2, 1, "", "Explainer"], [0, 2, 1, "", "Explanation"], [0, 2, 1, "", "Layout"], [0, 2, 1, "", "Visualizer"], [0, 1, 1, "", "colormap"], [0, 1, 1, "", "overlay"], [0, 1, 1, "", "resize"]], "openvino_xai.explainer.Explainer": [[0, 3, 1, "", "__call__"], [0, 3, 1, "", "create_method"], [0, 3, 1, "", "explain"], [0, 3, 1, "", "model_forward"]], "openvino_xai.explainer.Explanation": [[0, 3, 1, "", "plot"], [0, 4, 1, "", "saliency_map"], [0, 3, 1, "", "save"], [0, 4, 1, "", "shape"], [0, 4, 1, "", "targets"]], "openvino_xai.explainer.Visualizer": [[0, 3, 1, "", "__call__"], [0, 3, 1, "", "visualize"]], "openvino_xai.methods": [[0, 2, 1, "", "AISE"], [0, 2, 1, "", "ActivationMap"], [0, 2, 1, "", "DetClassProbabilityMap"], [0, 2, 1, "", "FeatureMapPerturbationBase"], [0, 2, 1, "", "RISE"], [0, 2, 1, "", "ReciproCAM"], [0, 2, 1, "", "ViTReciproCAM"], [0, 2, 1, "", "WhiteBoxMethod"]], "openvino_xai.methods.AISE": [[0, 3, 1, "", "generate_saliency_map"]], "openvino_xai.methods.ActivationMap": [[0, 3, 1, "", "generate_xai_branch"]], "openvino_xai.methods.DetClassProbabilityMap": [[0, 3, 1, "", "generate_xai_branch"]], "openvino_xai.methods.FeatureMapPerturbationBase": [[0, 3, 1, "", "generate_xai_branch"]], "openvino_xai.methods.RISE": [[0, 3, 1, "", "generate_saliency_map"]], "openvino_xai.methods.WhiteBoxMethod": [[0, 3, 1, "", "generate_saliency_map"], [0, 3, 1, "", "generate_xai_branch"], [0, 3, 1, "", "prepare_model"]]}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "function", "Python function"], "2": ["py", "class", "Python class"], "3": ["py", "method", "Python method"], "4": ["py", "property", "Python property"]}, "objtypes": {"0": "py:module", "1": "py:function", "2": "py:class", "3": "py:method", "4": "py:property"}, "terms": {"": [0, 1, 4], "0": [0, 4], "07421": 0, "1": [0, 3, 4], "10": 2, "11": 4, "14": 4, "1806": 0, "2": [0, 2, 3, 4], "2024": 2, "224": [2, 4], "23": 0, "24": 0, "255": [0, 4], "26": 2, "29": 2, "293": 2, "3": [2, 3], "30": 2, "4": [0, 3, 4], "484": 1, "5": [0, 4], "604": 1, "7": 4, "8": [0, 1], "85": [0, 4], "A": [0, 2], "As": 4, "At": 2, "By": [0, 2, 4], "For": [2, 4], "If": [0, 1, 4], "In": [2, 4], "Not": 0, "The": [0, 4], "There": 4, "To": [0, 1, 4], "With": 0, "__call__": 0, "_class_map": [0, 4], "_conf_": [0, 4], "ab": 0, "about": 4, "abov": 4, "abstract": 0, "abus": 2, "accept": 2, "access": 0, "accord": [1, 2], "activ": 2, "activationmap": [0, 2], "actual": 2, "ad": 4, "adapt": 0, "add": 0, "add_to_list": 1, "addit": [2, 4], "addition": 4, "aeroplan": [0, 4], "aeroplane_class_map": [0, 4], "affect": 4, "after": [0, 4], "aggreg": 0, "agjust": 4, "agnost": 2, "agre": 2, "ai": 1, "ais": [0, 2, 4], "algorithm": [0, 2, 3], "all": [0, 1, 2, 4], "allow": [0, 4], "alreadi": [0, 4], "also": [0, 1, 2, 4], "altern": 4, "among": 0, "an": [0, 2, 4], "analysi": 2, "analyz": [2, 4], "anchor": 0, "ani": [1, 2, 4], "anim": 2, "apach": 2, "api": [2, 3, 4], "append": 1, "appli": [0, 4], "applic": 2, "appreci": 2, "approach": 4, "ar": [0, 2, 4], "architectur": [2, 3], "area": 2, "arg": 0, "argument": [2, 4], "argwher": 4, "around": 2, "arrai": 0, "arxiv": [0, 2], "asset": [2, 4], "assum": 0, "atss": 0, "augment": 2, "auto": [0, 2, 3], "autom": 3, "automat": [1, 2], "avail": [0, 4], "avoid": [0, 2, 4], "backbon": 4, "backend": [0, 4], "balanc": 0, "bandwidth": 0, "base": [0, 2, 4], "basic": [2, 3], "batch": 4, "befor": [0, 1], "beforehand": 4, "begin": 4, "behavior": 2, "below": 4, "best": 2, "better": 4, "bhw": 0, "bhwc": 0, "bias": 0, "bicycl": 4, "bin": 2, "bird": 4, "black": [0, 1, 2, 3], "blackbox": [0, 4], "blackboxxaimethod": 0, "block": 0, "bnhw": 0, "bnhwc": 0, "boat": 4, "bodi": 2, "bool": 0, "bottl": 4, "box": [0, 2, 3], "branch": [0, 2, 4], "bu": 4, "budget": 0, "build": 1, "built": 4, "bunch": [2, 4], "call": [0, 2, 4], "callabl": 0, "cam": 0, "can": [0, 1, 2, 4], "car": 4, "case": [1, 4], "cast_to_uint8": 0, "cat": 4, "caus": 2, "cd": 2, "cell": 0, "chair": 4, "chang": [1, 2, 4], "check": [0, 1, 2], "cheetah": 2, "cheetah_person": [2, 4], "cl": 0, "class": [0, 2, 4], "class_index": 4, "classif": [0, 2, 4], "classprobabilitymap": 2, "clone": 2, "cls_token": 0, "cnn": [0, 2, 4], "code": [2, 3, 4], "codebas": 1, "colormap": 0, "colormap_typ": 0, "column": 0, "com": 2, "command": 1, "commit": [1, 2], "common": 3, "compil": 0, "compile_model": 4, "compiled_model": 4, "complex": 2, "complic": 2, "compris": 1, "comput": [0, 2, 4], "con": 4, "confid": [0, 4], "confidence_scor": [0, 4], "configur": [0, 1], "consist": [1, 4], "contain": [0, 2], "content": 4, "contribut": 3, "conveni": 4, "convent": 1, "convers": 2, "convert": 2, "convolut": 4, "copyright": 2, "core": [2, 4], "correspond": [2, 4], "could": 2, "count": 0, "cow": 4, "cpu": 0, "creat": [0, 2], "create_method": 0, "current": 4, "custom": [0, 2, 4], "cv": [0, 4], "cv2": [2, 4], "data": [0, 2, 4], "debug": 2, "decid": 2, "deep": 2, "def": [1, 4], "default": [0, 2, 4], "defin": 0, "depend": [0, 4], "describ": 0, "detail": [2, 4], "detclassprobabilitymap": 0, "detect": [0, 2], "detector": 0, "dev": 2, "develop": 2, "devic": 0, "device_nam": [0, 4], "dict": [0, 4], "differ": [0, 2], "dimens": 4, "dimension": 0, "diningt": 4, "dir_path": [0, 2], "direct": 0, "directli": [2, 4], "directori": [0, 2, 4], "disabl": 1, "disclaim": 3, "displai": 4, "dive": 2, "divers": 2, "do": [1, 2, 4], "document": [1, 2, 4], "doe": 4, "dog": 4, "domain": 2, "don": 1, "download": [2, 4], "downstream": 4, "dsize": [2, 4], "dump": 0, "dure": 4, "e": [0, 2], "e_x": 4, "each": [0, 4], "easiest": 4, "easili": 4, "edit": 2, "effcient": 0, "effect": 4, "either": [0, 4], "embed": [0, 4], "embed_sc": [0, 4], "empti": 0, "enabl": 2, "ensur": 1, "enum": 0, "enumer": 2, "env": 2, "environ": 2, "epsilon": 0, "error": 2, "even": 2, "exampl": 3, "exist": 2, "exp": 4, "expand_dim": [2, 4], "expanded_imag": 4, "expect": 2, "experiment": 2, "explain": [0, 1], "explain_method": [0, 4], "explain_mod": [0, 4], "explainmod": [0, 4], "explainresult": 0, "explan": [2, 3, 4], "expos": 2, "extra": [2, 4], "extract": 0, "fail": 4, "fals": [0, 2, 4], "fast": [2, 4], "featur": 3, "featuremapperturb": 0, "featuremapperturbationbas": 0, "feed": 2, "few": [2, 4], "file": [0, 1, 2], "fill": 0, "final_norm": 0, "finction": 0, "find": 2, "first": 4, "flag": 0, "flatten": 4, "flexibl": 4, "flexibli": [0, 4], "float": 0, "focus": 2, "follow": [0, 1, 2, 4], "format": [3, 4], "forward": [0, 4], "found": [1, 4], "from": [0, 2], "full": 2, "fulli": 2, "func": 1, "function": [0, 2, 4], "g": 0, "gaussian": 0, "genai": 2, "gener": [0, 2, 4], "generate_saliency_map": 0, "generate_xai_branch": 0, "get": [0, 2, 3, 4], "git": 2, "github": 2, "give": [1, 2], "given": 2, "global": 2, "graph": [0, 4], "grayscal": 0, "grid": [0, 4], "guid": [2, 3], "guidelin": 1, "ha": [0, 4], "has_xai": 0, "have": [0, 2, 4], "head": [0, 2], "help": [2, 4], "here": [0, 4], "higher": 2, "highlight": 2, "hint": 1, "histori": 2, "hold": 0, "hood": 4, "hors": 4, "how": 4, "howev": 4, "http": [0, 2], "human": 2, "hundr": 4, "i": [0, 1, 2, 4], "id": 1, "ident": 0, "identifi": 4, "identitypreprocessfn": 0, "ie_api": 0, "imag": [0, 2, 4], "image_name_": [0, 4], "image_name_aeroplane_class_map": 4, "image_name_aeroplane_conf_0": [0, 4], "image_name_target_": [0, 4], "image_name_target_aeroplan": [0, 4], "imagin": 2, "implement": [0, 4], "import": [1, 2, 4], "imread": [2, 4], "includ": [2, 4], "increment": 2, "index": [0, 3], "indic": [0, 2, 4], "infer": [0, 2, 4], "inner": 4, "input": [0, 2, 4], "input_imag": 0, "insert": [0, 2, 3], "insert_xai": [0, 2, 4], "instal": 3, "instead": 4, "int": [0, 1], "integ": 0, "intel": 2, "intend": 2, "interest": 2, "interfac": [0, 2, 3], "intermedi": [2, 3, 4], "internation": 2, "introduct": 3, "involv": 4, "ir": [0, 2, 3], "isort": 1, "issu": [0, 2], "item": 1, "iter": 0, "its": 0, "jpg": [0, 2, 4], "jupyt": [0, 4], "k": 0, "kernel": 0, "kernel_width": 0, "know": 2, "known": 2, "kwarg": 0, "label": [0, 2, 4], "label_nam": [0, 2, 4], "languag": 3, "larg": 0, "last": [0, 4], "last_conv_node_nam": 4, "later": 0, "layer": [0, 4], "layout": 0, "learn": 4, "let": 2, "librari": [2, 4], "licens": 3, "like": [1, 2, 4], "limit": 2, "line": 2, "link": [0, 2], "list": [0, 1, 4], "llm": 2, "load": [0, 2, 4], "load_model": 0, "local": 0, "locally_bias": 0, "log": 2, "logic": 0, "logit": 4, "look": [2, 4], "low": 0, "m": 2, "machin": 4, "mai": 2, "main": [2, 3], "maintain": 1, "major": 4, "make": 4, "manag": 0, "mandatori": 1, "mani": 4, "manual": 3, "map": [0, 2, 3], "mask": 0, "matplotlib": [0, 4], "max": [0, 4], "max_num_plot": 0, "mean": 0, "measur": 4, "memori": 0, "mention": 4, "method": [3, 4], "methodbas": 0, "might": 2, "mlc_mobilenetv3_large_voc": [2, 4], "mobilenet_v3": 2, "mode": [0, 2, 3], "model": 0, "model_forward": 0, "model_path": 4, "model_xai": [0, 4], "modif": 4, "modifi": 0, "modul": 3, "moment": 2, "more": 4, "mosaic": 0, "most": 2, "motorbik": 4, "multipl": [0, 2], "multiple_maps_per_image_color": 0, "multiple_maps_per_image_grai": 0, "mypi": 1, "name": [0, 2, 4], "name_": 4, "ndarrai": [0, 2, 4], "need": [2, 4], "negvet": 0, "new": 4, "node": [0, 4], "none": [0, 1], "normal": [0, 2], "note": [2, 4], "notebook": [2, 4], "np": [0, 2, 4], "num": 1, "num_anchor": 0, "num_cel": 0, "num_collumn": 4, "num_column": [0, 4], "num_iterations_per_kernel": 0, "num_mask": 0, "number": 0, "numpi": [0, 2, 4], "nutshel": 4, "o": 0, "object": [0, 2, 4], "observ": 2, "older": 2, "omit": 0, "onc": 4, "one": [0, 4], "one_map_per_image_color": 0, "one_map_per_image_grai": 0, "onli": 2, "onnx": [0, 2], "op": 0, "open": 4, "opencv": 4, "openvino": 1, "openvino_xai": [0, 2, 4], "openvinotoolkit": 2, "oper": [0, 4], "optim": 0, "option": [0, 2, 4], "order": 0, "org": 0, "origin": [0, 2, 4], "original_input_imag": [0, 4], "otherwis": 0, "otx_model": [2, 4], "our": [2, 4], "output": [0, 2, 4], "output_dir": 0, "output_path": 4, "output_s": 0, "ov": [0, 2, 4], "ov_model": 2, "ovc": 2, "over": [0, 2], "overhead": 4, "overlai": [0, 2, 4], "overlay_weight": 0, "ovxai": 2, "own": 4, "p": 0, "packag": 2, "page": 3, "paper": 0, "param": 0, "paramet": [0, 4], "part": 4, "pass": [0, 2, 4], "path": [0, 2, 4], "pathlik": 0, "pep": 1, "per": [0, 2, 4], "perform": 4, "person": 4, "perspect": 2, "perturb": 4, "pick": 4, "pip": 2, "pipelin": [2, 4], "pleas": 2, "plot": [0, 3], "possibl": 4, "post": [0, 2, 4], "postfix": [0, 4], "postprocess": [0, 4], "postprocess_fn": [0, 4], "pottedpl": 4, "pre": [0, 1, 2, 4], "predefin": 0, "predict": [0, 4], "prefix": [0, 4], "prepar": [0, 2, 4], "prepare_model": 0, "preprocess": [0, 4], "preprocess_fn": 0, "preprocessed_imag": 4, "preset": 0, "primarili": 4, "principl": 2, "prior": 0, "pro": 4, "prob": 0, "process": [0, 2, 4], "processed_imag": 4, "product": 2, "project": 2, "properli": 1, "properti": 0, "provid": [0, 2, 3, 4], "purpos": 2, "py": [2, 4], "pypi": 2, "pytest": [2, 4], "python": [2, 3, 4], "python3": 2, "pytorch": 2, "qualiti": [0, 2], "question": 2, "quick": 3, "quit": 4, "random": 0, "rang": [0, 4], "raw": 0, "re": 0, "read_model": [2, 4], "readabl": 1, "reason": 2, "recipro": 0, "reciprocam": [0, 2, 4], "recogn": 2, "recommend": [0, 1, 4], "refer": 2, "region": 2, "rel": 4, "releas": 2, "repositori": 2, "repres": [0, 4], "represent": [2, 3, 4], "request": 2, "requir": [0, 1, 4], "resiz": [0, 2, 4], "resized_imag": 4, "respect": 2, "respons": [2, 4], "result": [0, 4], "result_idx": 4, "result_inf": 4, "result_scor": 4, "retriev": 4, "return": [0, 1, 4], "right": 2, "rise": [0, 2, 4], "row": 4, "rule": 3, "run": [1, 2], "run_classif": [2, 4], "runnabl": 2, "runtim": [0, 2, 4], "salienc": [0, 2, 3], "saliency_map": [0, 4], "saliency_map_s": 0, "same": [2, 4], "sampl": 0, "save": [0, 1, 2, 3], "scale": [0, 4], "scale_output": 0, "scenario": [2, 4], "score": [0, 4], "scores_dict": 4, "script": [0, 2, 3], "search": 3, "see": 2, "seed": 0, "select": [0, 2], "self": 0, "sequenti": 4, "set": [0, 1, 2, 4], "shape": 0, "sheep": 4, "should": [1, 4], "simpl": 2, "sinc": 4, "singl": 0, "size": 0, "skin": 2, "slow": 2, "small": 4, "so": 4, "sofa": 4, "softmax": 4, "softwar": 2, "solver": 0, "solver_epsilon": 0, "some": 0, "sourc": [0, 2], "specif": [0, 1, 2, 4], "specifi": 0, "speed": 0, "src": [2, 4], "ssd": 0, "stage": 0, "start": 3, "state": 2, "step": [0, 4], "store": [2, 4], "str": [0, 1, 2], "string": [0, 4], "style": 3, "suit": [2, 3, 4], "sum": 4, "supplement": 1, "support": 4, "t": 1, "tab": 2, "target": [0, 2, 4], "target_explain_label": 4, "target_id": [0, 4], "target_indic": 0, "target_lay": [0, 4], "task": [0, 2, 4], "tbd": 1, "tell": 2, "term": 2, "test": [2, 4], "test_classif": [2, 4], "thank": 2, "them": [0, 2], "therefor": 0, "therein": 2, "thi": [0, 1, 2, 4], "those": 2, "thousand": 4, "throughout": 1, "time": [1, 2], "timm": 2, "todo": 0, "token": 0, "tool": 1, "toolkit": 1, "top": 2, "torch": 2, "tradeoff": 0, "train": 4, "transform": [0, 2], "transpos": 4, "treat": 4, "true": [0, 2, 4], "try": [2, 4], "tupl": 0, "tutori": 4, "tvmonitor": 4, "tweak": 2, "two": 4, "type": [0, 2, 4], "u": 2, "under": [2, 4], "understand": 2, "unit": 2, "unsupport": 2, "up": [0, 2], "upcom": 2, "updat": [1, 4], "us": [0, 4], "usag": [0, 3], "use_gaussian": 0, "user": [0, 2, 3], "usual": 4, "util": 0, "v": 2, "valid": [2, 4], "valu": [0, 1, 4], "vari": 4, "venv": 2, "verifi": 2, "version": 2, "via": 2, "violat": 2, "virtual": 2, "vision": 2, "visual": [0, 2, 4], "visualizationparamet": 0, "vitrecipro": 0, "vitreciprocam": [0, 2], "voc_label": 4, "wa": 4, "wai": 4, "want": 2, "warn": 2, "watch": 2, "we": [1, 2, 4], "weight": 0, "well": 2, "were": 1, "when": [0, 1], "where": 0, "whether": 0, "which": [0, 2, 4], "while": 2, "white": [0, 2, 3], "whitebox": [0, 4], "whiteboxmethod": 0, "who": 2, "whole": 0, "why": 2, "wide": 4, "window": 4, "work": [2, 4], "workaround": 2, "would": 2, "x": [0, 4], "xai": 3, "xml": [0, 2, 4], "yolox": 0, "you": [1, 2, 4], "your": [1, 2, 4], "zip": 4}, "titles": ["OpenVINO-XAI Python API", "Style Guide for Python Code", "OpenVINO\u2122 Explainable AI Toolkit - OpenVINO XAI", "Welcome to OpenVINO\u2122 Explainable AI Toolkit\u2019s documentation!", "OpenVINO\u2122 Explainable AI Toolkit User Guide"], "titleterms": {"": [2, 3], "0": 2, "1": 1, "2": 1, "3": 1, "4": 1, "advanc": 2, "ai": [2, 3, 4], "algorithm": 4, "annot": 1, "api": 0, "architectur": 4, "argument": 1, "auto": 4, "autom": 1, "avoid": 1, "basic": 4, "black": 4, "box": 4, "case": 2, "code": 1, "common": 0, "content": 3, "contribut": 2, "creat": 4, "default": 1, "disclaim": 2, "document": 3, "exampl": [2, 4], "explain": [2, 3, 4], "explan": 0, "featur": 2, "file": 4, "format": 1, "from": 4, "guid": [1, 4], "hello": 2, "indic": 3, "insert": 4, "instal": 2, "instanc": 4, "interfac": 4, "introduct": 1, "ir": 4, "languag": 1, "licens": 2, "main": 4, "map": 4, "method": [0, 2], "mode": 4, "model": [2, 4], "more": 2, "mutabl": 1, "new": 2, "onnx": 4, "openvino": [0, 2, 3, 4], "plai": 2, "plot": 4, "preprocess_fn": 4, "python": [0, 1], "quick": 2, "rule": 1, "run": 4, "salienc": 4, "save": 4, "script": 4, "specifi": 4, "start": 2, "style": 1, "support": 2, "tabl": 3, "toolkit": [2, 3, 4], "type": 1, "us": [1, 2], "usag": 4, "user": 4, "v1": 2, "welcom": 3, "what": 2, "white": 4, "without": 4, "xai": [0, 2, 4]}}) \ No newline at end of file diff --git a/develop/user-guide.html b/develop/user-guide.html index b209009c..195d250d 100644 --- a/develop/user-guide.html +++ b/develop/user-guide.html @@ -347,6 +347,7 @@

    Table of Contents

  • Black-Box mode
  • XAI insertion (white-box usage)
  • Plot saliency maps
  • +
  • Saving saliency maps
  • Example scripts
@@ -434,6 +435,7 @@

OpenVINO™ Explainable AI Toolkit User GuideBlack-Box mode

  • XAI insertion (white-box usage)

  • Plot saliency maps

  • +
  • Saving saliency maps

  • Example scripts

  • @@ -502,8 +504,8 @@

    Running without Here’s the example how we can avoid passing preprocess_fn by preprocessing data beforehand (like resizing and adding a batch dimension).

    import cv2
     import numpy as np
    +from typing import Mapping
     import openvino.runtime as ov
    -from from typing import Mapping
     
     import openvino_xai as xai
     
    @@ -539,7 +541,7 @@ 

    Running without ) # Save saliency maps -explanation.save("output_path", "name") +explanation.save("output_path", "name_")

    @@ -547,8 +549,8 @@

    Running without Specifying preprocess_fn#

    import cv2
     import numpy as np
    -import openvino.runtime as ov
     from typing import Mapping
    +import openvino.runtime as ov
     
     import openvino_xai as xai
     
    @@ -585,7 +587,7 @@ 

    Specifying prep ) # Save saliency maps -explanation.save("output_path", "name") +explanation.save("output_path", "name_")

    @@ -640,7 +642,7 @@

    White-Box mode) # Save saliency maps -explanation.save("output_path", "name") +explanation.save("output_path", "name_")

    @@ -693,7 +695,7 @@

    Black-Box mode) # Save saliency maps -explanation.save("output_path", "name") +explanation.save("output_path", "name_")

    @@ -731,7 +733,9 @@

    Plot saliency maps
    import cv2
     import numpy as np
     import openvino.runtime as ov
    +
     import openvino_xai as xai
    +from openvino_xai.explainer import ExplainMode
     
     def preprocess_fn(image: np.ndarray) -> np.ndarray:
         """Preprocess the input image."""
    @@ -780,6 +784,92 @@ 

    Plot saliency maps +

    Saving saliency maps#

    +

    You can easily save saliency maps with flexible naming options by using a prefix and postfix. The prefix allows saliency maps from the same image to have consistent naming.

    +

    The format for naming is:

    +

    {prefix} + target_id + {postfix}.jpg

    +

    Additionally, you can include the confidence score for each class in the saved saliency map’s name.

    +

    {prefix} + target_id + {postfix} + confidence.jpg

    +
    import cv2
    +import numpy as np
    +import openvino.runtime as ov
    +from typing import Mapping
    +
    +import openvino_xai as xai
    +from openvino_xai.explainer import ExplainMode
    +
    +def preprocess_fn(image: np.ndarray) -> np.ndarray:
    +    """Preprocess the input image."""
    +    x = cv2.resize(src=image, dsize=(224, 224))
    +    x = x.transpose((2, 0, 1))
    +    processed_image = np.expand_dims(x, 0)
    +    return processed_image
    +
    +def postprocess_fn(output: Mapping):
    +    """Postprocess the model output."""
    +    output = softmax(output)
    +    return output[0]
    +
    +def softmax(x: np.ndarray) -> np.ndarray:
    +    """Compute softmax values of x."""
    +    e_x = np.exp(x - np.max(x))
    +    return e_x / e_x.sum()
    +
    +# Generate and process saliency maps (as many as required, sequentially)
    +image = cv2.imread("path/to/image.jpg")
    +
    +# Create ov.Model
    +MODEL_PATH = "path/to/model.xml"
    +model = ov.Core().read_model(MODEL_PATH)  # type: ov.Model
    +
    +# The Explainer object will prepare and load the model once in the beginning
    +explainer = xai.Explainer(
    +    model,
    +    task=xai.Task.CLASSIFICATION,
    +    preprocess_fn=preprocess_fn,
    +)
    +
    +voc_labels = [
    +    'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable',
    +    'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor'
    +]
    +
    +# Get predicted confidences for the image
    +compiled_model = core.compile_model(model=model, device_name="AUTO")
    +logits = compiled_model(preprocess_fn(image))[0]
    +result_infer = postprocess_fn(logits)
    +
    +# Generate list of predicted class indices and scores
    +result_idxs = np.argwhere(result_infer > 0.4).flatten()
    +result_scores = result_infer[result_idxs]
    +
    +# Generate dict {class_index: confidence} to save saliency maps
    +scores_dict = {i: score for i, score in zip(result_idxs, result_scores)}
    +
    +# Run explanation
    +explanation = explainer(
    +    image,
    +    explain_mode=ExplainMode.WHITEBOX,
    +    label_names=voc_labels,
    +    target_explain_labels=result_idxs,  # target classes to explain
    +)
    +
    +# Save saliency maps flexibly
    +OUTPUT_PATH = "output_path"
    +explanation.save(OUTPUT_PATH)  # aeroplane.jpg
    +explanation.save(OUTPUT_PATH, "image_name_target_")  # image_name_target_aeroplane.jpg
    +explanation.save(OUTPUT_PATH, prefix="image_name_target_")  # image_name_target_aeroplane.jpg
    +explanation.save(OUTPUT_PATH, postfix="_class_map")  # aeroplane_class_map.jpg
    +explanation.save(OUTPUT_PATH, prefix="image_name_", postfix="_class_map")  # image_name_aeroplane_class_map.jpg
    +
    +# Save saliency maps with confidence scores
    +explanation.save(
    +    OUTPUT_PATH, prefix="image_name_", postfix="_conf_", confidence_scores=scores_dict
    +)  # image_name_aeroplane_conf_0.85.jpg
    +
    +
    +

    Example scripts#

    More usage scenarios that can be used with your own models and images as arguments are available in examples.

    @@ -858,6 +948,7 @@

    Example scriptsBlack-Box mode
  • XAI insertion (white-box usage)
  • Plot saliency maps
  • +
  • Saving saliency maps
  • Example scripts