class_docstr: OpenVINO implementation for the inference.
  
  Args:
      path (str | Path): Path to the openvino onnx, xml or bin file.
      metadata (str | Path | dict, optional): Path to metadata file or a dict object defining the
          metadata. Defaults to None.
      device (str | None, optional): Device to run the inference on. Defaults to "CPU".
      task (TaskType | None, optional): Task type. Defaults to None.
class_docstr_tok: ["OpenVINO","implementation","for","the","inference",".","Args",":","path","(","str","|","Path",")",":","Path","to","the","openvino","onnx",",","xml","or","bin","file",".","metadata","(","str","|","Path","|","dict",",","optional",")",":","Path","to","metadata","file","or","a","dict","object","defining","the","metadata",".","Defaults","to","None",".","device","(","str","|","None",",","optional",")",":","Device","to","run","the","inference","on",".","Defaults","to","``","CPU","''",".","task","(","TaskType","|","None",",","optional",")",":","Task","type",".","Defaults","to","None","."]
docstr: Post process the output predictions.
  
  Args:
      predictions (np.ndarray): Raw output predicted by the model.
      metadata (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:
      dict[str, Any]: Post processed prediction results.
docstr_tok: ["Post","process","the","output","predictions",".","Args",":","predictions","(","np.ndarray",")",":","Raw","output","predicted","by","the","model",".","metadata","(","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",":","dict","[","str",",","Any","]",":","Post","processed","prediction","results","."]
code: def post_process(
      self,
      predictions: np.ndarray,
      metadata: dict | DictConfig | None = None,
  ) -> dict[str, Any]:
      """Post process the output predictions.
  
      Args:
          predictions (np.ndarray): Raw output predicted by the model.
          metadata (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:
          dict[str, Any]: Post processed prediction results.
      """
      if metadata is None:
          metadata = self.metadata
  
      predictions = predictions[self.output_blob]
  
      # Initialize the result variables.
      anomaly_map: np.ndarray | None = None
      pred_label: float | None = None
      pred_mask: float | None = None
  
      # If predictions returns a single value, this means that the task is
      # classification, and the value is the classification prediction score.
      if len(predictions.shape) == 1:
          task = TaskType.CLASSIFICATION
          pred_score = predictions
      else:
          task = TaskType.SEGMENTATION
          anomaly_map = predictions.squeeze()
          pred_score = anomaly_map.reshape(-1).max()
  
      # Common practice in anomaly detection is to assign anomalous
      # label to the prediction if the prediction score is greater
      # than the image threshold.
      if "image_threshold" in metadata:
          pred_label = pred_score >= metadata["image_threshold"]
  
      if task == TaskType.CLASSIFICATION:
          _, pred_score = self._normalize(
              pred_scores=pred_score, metadata=metadata
          )
      elif task in (TaskType.SEGMENTATION, TaskType.DETECTION):
          if "pixel_threshold" in metadata:
              pred_mask = (
                  anomaly_map >= metadata["pixel_threshold"]
              ).astype(np.uint8)
  
          anomaly_map, pred_score = self._normalize(
              pred_scores=pred_score,
              anomaly_maps=anomaly_map,
              metadata=metadata,
          )
          assert anomaly_map is not None
  
          if (
              "image_shape" in metadata
              and anomaly_map.shape != metadata["image_shape"]
          ):
              image_height = metadata["image_shape"][0]
              image_width = metadata["image_shape"][1]
              anomaly_map = cv2.resize(
                  anomaly_map, (image_width, image_height)
              )
  
              if pred_mask is not None:
                  pred_mask = cv2.resize(
                      pred_mask, (image_width, image_height)
                  )
      else:
          raise ValueError(f"Unknown task type: {task}")
  
      if self.task == TaskType.DETECTION:
          pred_boxes = self._get_boxes(pred_mask)
          box_labels = np.ones(pred_boxes.shape[0])
      else:
          pred_boxes = None
          box_labels = None
  
      return {
          "anomaly_map": anomaly_map,
          "pred_label": pred_label,
          "pred_score": pred_score,
          "pred_mask": pred_mask,
          "pred_boxes": pred_boxes,
          "box_labels": box_labels,
      }
  
file_path: anomalib/src/anomalib/deploy/inferencers/openvino_inferencer.py
imports: from __future__ import annotations
  import logging
  from importlib.util import find_spec
  from pathlib import Path
  from typing import Any
  import albumentations
  import cv2
  import numpy
  from omegaconf import DictConfig
  from anomalib.data import TaskType
  from .base_inferencer import Inferencer
label_desc: Use image node_id 5 for calling the OpenVINOInferencer obj's underlying member method code with example usage: obj.post_process(predictions, metadata) and returns: dict