Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/anomalib/deploy/inferencers/openvino_inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down