diff --git a/src/anomalib/deploy/inferencers/openvino_inferencer.py b/src/anomalib/deploy/inferencers/openvino_inferencer.py index 3e8f18540e..3206b39e30 100644 --- a/src/anomalib/deploy/inferencers/openvino_inferencer.py +++ b/src/anomalib/deploy/inferencers/openvino_inferencer.py @@ -201,7 +201,7 @@ def predict( # Resize image to model input size if not dynamic if self.input_blob.partial_shape[2].is_static and self.input_blob.partial_shape[3].is_static: - image = cv2.resize(image, tuple(self.input_blob.shape[2:][::-1])) + image = cv2.resize(image, tuple(list(self.input_blob.shape)[2:][::-1])) # Normalize numpy array to range [0, 1] if image.dtype != np.float32: diff --git a/src/anomalib/models/image/reverse_distillation/anomaly_map.py b/src/anomalib/models/image/reverse_distillation/anomaly_map.py index 4d4edffdf3..94e591cdfe 100644 --- a/src/anomalib/models/image/reverse_distillation/anomaly_map.py +++ b/src/anomalib/models/image/reverse_distillation/anomaly_map.py @@ -13,11 +13,12 @@ from enum import Enum import torch -from kornia.filters import gaussian_blur2d from omegaconf import ListConfig from torch import nn from torch.nn import functional as F # noqa: N812 +from anomalib.models.components import GaussianBlur2d + class AnomalyMapGenerationMode(str, Enum): """Type of mode when generating anomaly imape.""" @@ -87,8 +88,9 @@ def forward(self, student_features: list[torch.Tensor], teacher_features: list[t elif self.mode == AnomalyMapGenerationMode.ADD: anomaly_map += distance_map - return gaussian_blur2d( - anomaly_map, + gaussian_blur = GaussianBlur2d( kernel_size=(self.kernel_size, self.kernel_size), sigma=(self.sigma, self.sigma), - ) + ).to(student_features[0].device) + + return gaussian_blur(anomaly_map) diff --git a/tests/integration/model/test_models.py b/tests/integration/model/test_models.py index e49cc11e6b..ec58d29dfa 100644 --- a/tests/integration/model/test_models.py +++ b/tests/integration/model/test_models.py @@ -143,10 +143,10 @@ def test_export( dataset_path (Path): Root to dataset from fixture. project_path (Path): Path to temporary project folder from fixture. """ - if model_name in ("reverse_distillation", "rkde"): + if model_name == "rkde": # TODO(ashwinvaidya17): Restore this test after fixing the issue # https://github.com/openvinotoolkit/anomalib/issues/1513 - pytest.skip(f"{model_name} fails to convert to ONNX and OpenVINO") + pytest.skip(f"{model_name} fails to convert to OpenVINO") model, dataset, engine = self._get_objects( model_name=model_name,