Skip to content

Commit 7a6317c

Browse files
djdamelnSongki Choi
authored andcommitted
Return raw anomaly maps as metadata (#2217)
* return raw anomaly map instead of colormap * return raw heatmap in openvino inference * Update changelog * convert anomaly map to numpy
1 parent 8207947 commit 7a6317c

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ All notable changes to this project will be documented in this file.
5353

5454
### Bug fixes
5555

56+
- Return raw anomaly map instead of colormap as metadata to prevent applying colormap conversion twice (<https://github.com/openvinotoolkit/training_extensions/pull/2217>)
5657
- Hotfix: use 0 confidence threshold when computing best threshold based on F1
5758

5859
## \[v1.2.2\]

otx/algorithms/anomaly/adapters/anomalib/callbacks/inference.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import pytorch_lightning as pl
2121
import torch
2222
from anomalib.models import AnomalyModule
23-
from anomalib.post_processing import anomaly_map_to_color_map
2423
from pytorch_lightning.callbacks import Callback
2524
from torch import Tensor
2625

@@ -82,7 +81,7 @@ def on_predict_epoch_end(self, _trainer: pl.Trainer, _pl_module: AnomalyModule,
8281
name="Anomaly Map",
8382
type="anomaly_map",
8483
annotation_scene=dataset_item.annotation_scene,
85-
numpy=anomaly_map_to_color_map(anomaly_map.squeeze().numpy(), normalize=False),
84+
numpy=(anomaly_map * 255).cpu().numpy().astype(np.uint8),
8685
)
8786
)
8887

otx/algorithms/anomaly/tasks/openvino.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import numpy as np
2525
from addict import Dict as ADDict
2626
from anomalib.deploy import OpenVINOInferencer
27-
from anomalib.post_processing import anomaly_map_to_color_map
2827
from compression.api import DataLoader
2928
from compression.engines.ie_engine import IEEngine
3029
from compression.graph import load_model, save_model
@@ -193,7 +192,7 @@ def infer(self, dataset: DatasetEntity, inference_parameters: InferenceParameter
193192
raise ValueError(f"Unknown task type: {self.task_type}")
194193

195194
dataset_item.append_labels([ScoredLabel(label=label, probability=float(probability))])
196-
anomaly_map = anomaly_map_to_color_map(image_result.anomaly_map, normalize=False)
195+
anomaly_map = (image_result.anomaly_map * 255).astype(np.uint8)
197196
heatmap_media = ResultMediaEntity(
198197
name="Anomaly Map",
199198
type="anomaly_map",

0 commit comments

Comments
 (0)