Skip to content

Commit

Permalink
Changed prediction label assignment for OpenVINO inferencer (#1872)
Browse files Browse the repository at this point in the history
* Update openvino_inferencer.py

Fixed incorrect label assignment.
Was True/False, now it's "Anomalous/Normal" as for the PyTorch inferencer in torch_inferencer.py

* Fix ruff

---------

Co-authored-by: Samet <[email protected]>
  • Loading branch information
TurboJonte and samet-akcay authored Mar 25, 2024
1 parent 8ebfdf5 commit 6be4c80
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/anomalib/deploy/inferencers/openvino_inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from PIL import Image

from anomalib import TaskType
from anomalib.data.utils.label import LabelName
from anomalib.utils.visualization import ImageResult

from .base_inferencer import Inferencer
Expand Down Expand Up @@ -253,7 +254,7 @@ def post_process(self, predictions: np.ndarray, metadata: dict | DictConfig | No

# Initialize the result variables.
anomaly_map: np.ndarray | None = None
pred_label: float | None = None
pred_label: LabelName | None = None
pred_mask: float | None = None

# If predictions returns a single value, this means that the task is
Expand All @@ -270,7 +271,8 @@ def post_process(self, predictions: np.ndarray, metadata: dict | DictConfig | No
# 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"]
pred_idx = pred_score >= metadata["image_threshold"]
pred_label = LabelName.ABNORMAL if pred_idx else LabelName.NORMAL

if task == TaskType.CLASSIFICATION:
_, pred_score = self._normalize(pred_scores=pred_score, metadata=metadata)
Expand Down

0 comments on commit 6be4c80

Please sign in to comment.