diff --git a/CHANGELOG.md b/CHANGELOG.md index c3408f87918..e07f0c669e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. ### Bug fixes +- Return raw anomaly map instead of colormap as metadata to prevent applying colormap conversion twice () - Hotfix: use 0 confidence threshold when computing best threshold based on F1 ## \[v1.2.2\] diff --git a/otx/algorithms/anomaly/adapters/anomalib/callbacks/inference.py b/otx/algorithms/anomaly/adapters/anomalib/callbacks/inference.py index ad50c6ed22f..4a3f30a92d4 100644 --- a/otx/algorithms/anomaly/adapters/anomalib/callbacks/inference.py +++ b/otx/algorithms/anomaly/adapters/anomalib/callbacks/inference.py @@ -20,7 +20,6 @@ import pytorch_lightning as pl import torch from anomalib.models import AnomalyModule -from anomalib.post_processing import anomaly_map_to_color_map from pytorch_lightning.callbacks import Callback from torch import Tensor @@ -82,7 +81,7 @@ def on_predict_epoch_end(self, _trainer: pl.Trainer, _pl_module: AnomalyModule, name="Anomaly Map", type="anomaly_map", annotation_scene=dataset_item.annotation_scene, - numpy=anomaly_map_to_color_map(anomaly_map.squeeze().numpy(), normalize=False), + numpy=(anomaly_map * 255).cpu().numpy().astype(np.uint8), ) ) diff --git a/otx/algorithms/anomaly/tasks/openvino.py b/otx/algorithms/anomaly/tasks/openvino.py index 1ed57c96f1e..17b0dc60249 100644 --- a/otx/algorithms/anomaly/tasks/openvino.py +++ b/otx/algorithms/anomaly/tasks/openvino.py @@ -24,7 +24,6 @@ import numpy as np from addict import Dict as ADDict from anomalib.deploy import OpenVINOInferencer -from anomalib.post_processing import anomaly_map_to_color_map from compression.api import DataLoader from compression.engines.ie_engine import IEEngine from compression.graph import load_model, save_model @@ -193,7 +192,7 @@ def infer(self, dataset: DatasetEntity, inference_parameters: InferenceParameter raise ValueError(f"Unknown task type: {self.task_type}") dataset_item.append_labels([ScoredLabel(label=label, probability=float(probability))]) - anomaly_map = anomaly_map_to_color_map(image_result.anomaly_map, normalize=False) + anomaly_map = (image_result.anomaly_map * 255).astype(np.uint8) heatmap_media = ResultMediaEntity( name="Anomaly Map", type="anomaly_map",