anomalib.deploy.inferencers.openvino

This module contains inference-related abstract class and its Torch and OpenVINO implementations.

Module Contents

Classes

OpenVINOInferencer

OpenVINO implementation for the inference.

class anomalib.deploy.inferencers.openvino.OpenVINOInferencer(config: Union[omegaconf.DictConfig, omegaconf.ListConfig], path: Union[str, pathlib.Path, Tuple[bytes, bytes]], meta_data_path: Union[str, pathlib.Path] = None)[source]

Bases: anomalib.deploy.inferencers.base.Inferencer

OpenVINO implementation for the inference.

Parameters
  • config (DictConfig) – Configurable parameters that are used during the training stage.

  • path (Union[str, Path]) – Path to the openvino onnx, xml or bin file.

  • meta_data_path (Union[str, Path], optional) – Path to metadata file. Defaults to None.

load_model(self, path: Union[str, pathlib.Path, Tuple[bytes, bytes]])[source]

Load the OpenVINO model.

Parameters

path (Union[str, Path, Tuple[bytes, bytes]]) – Path to the onnx or xml and bin files or tuple of .xml and .bin data as bytes.

Returns

Input and Output blob names

together with the Executable network.

Return type

[Tuple[str, str, ExecutableNetwork]]

pre_process(self, image: numpy.ndarray) numpy.ndarray[source]

Pre process the input image by applying transformations.

Parameters

image (np.ndarray) – Input image.

Returns

pre-processed image.

Return type

np.ndarray

forward(self, image: numpy.ndarray) numpy.ndarray[source]

Forward-Pass input tensor to the model.

Parameters

image (np.ndarray) – Input tensor.

Returns

Output predictions.

Return type

np.ndarray

post_process(self, predictions: numpy.ndarray, meta_data: Optional[Union[Dict, omegaconf.DictConfig]] = None) Tuple[numpy.ndarray, float][source]

Post process the output predictions.

Parameters
  • predictions (np.ndarray) – Raw output predicted by the model.

  • meta_data (Dict, optional) – Meta data. Post-processing step sometimes requires additional meta data such as image shape. This variable comprises such info. Defaults to None.

Returns

Post processed predictions that are ready to be visualized.

Return type

np.ndarray