diff --git a/src/anomalib/deploy/inferencers/openvino_inferencer.py b/src/anomalib/deploy/inferencers/openvino_inferencer.py index 91970a0adf..6211797a81 100644 --- a/src/anomalib/deploy/inferencers/openvino_inferencer.py +++ b/src/anomalib/deploy/inferencers/openvino_inferencer.py @@ -147,7 +147,7 @@ def load_model(self, path: str | Path | tuple[bytes, bytes]) -> tuple[Any, Any, compile_model = core.compile_model(model=model, device_name=self.device, config=self.config) input_blob = compile_model.input(0) - output_blob = compile_model.output(0) + output_blob = compile_model.outputs return input_blob, output_blob, compile_model @@ -254,7 +254,7 @@ def post_process(self, predictions: np.ndarray, metadata: dict | DictConfig | No if metadata is None: metadata = self.metadata - predictions = predictions[self.output_blob] + predictions = [predictions[i] for i in self.output_blob] # Initialize the result variables. anomaly_map: np.ndarray | None = None @@ -263,13 +263,16 @@ def post_process(self, predictions: np.ndarray, metadata: dict | DictConfig | No # 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: + if len(predictions) == 1: task = TaskType.CLASSIFICATION - pred_score = predictions + pred_score = predictions[0] else: - task = TaskType.SEGMENTATION - anomaly_map = predictions.squeeze() - pred_score = anomaly_map.reshape(-1).max() + task = TaskType.SEGMENTATION if self.task is None else self.task + for item in predictions: + if len(item.shape) == 1: + pred_score = item[0] + else: + anomaly_map = item.squeeze() # Common practice in anomaly detection is to assign anomalous # label to the prediction if the prediction score is greater