diff --git a/src/otx/algorithms/detection/adapters/mmdet/datasets/tiling.py b/src/otx/algorithms/detection/adapters/mmdet/datasets/tiling.py index b02a548ca5f..79e0bfd5b53 100644 --- a/src/otx/algorithms/detection/adapters/mmdet/datasets/tiling.py +++ b/src/otx/algorithms/detection/adapters/mmdet/datasets/tiling.py @@ -538,8 +538,8 @@ def merge_maps(self, saliency_maps: Union[List[List[np.ndarray]], List[np.ndarra for orig_image in self.cached_results: img_idx = orig_image["index"] - ratios[img_idx] = np.array([feat_h, feat_w]) / self.tile_size image_h, image_w = orig_image["height"], orig_image["width"] + ratios[img_idx] = np.array([feat_h / min(self.tile_size, image_h), feat_w / min(self.tile_size, image_w)]) image_map_h = int(image_h * ratios[img_idx][0]) image_map_w = int(image_w * ratios[img_idx][1]) diff --git a/tests/unit/algorithms/detection/tiling/test_tiling_tile_classifier.py b/tests/unit/algorithms/detection/tiling/test_tiling_tile_classifier.py index 867dc4b1a79..b6f3ac8b955 100644 --- a/tests/unit/algorithms/detection/tiling/test_tiling_tile_classifier.py +++ b/tests/unit/algorithms/detection/tiling/test_tiling_tile_classifier.py @@ -81,9 +81,18 @@ def test_openvino_sync(self, mocker): mocked_model.return_value = mocker.MagicMock(spec=MaskRCNNModel, model_adapter=adapter_mock) params = DetectionConfig(header=self.hyper_parameters.header) ov_mask_inferencer = OpenVINOMaskInferencer(params, self.label_schema, "") - ov_mask_inferencer.model = mocked_model + original_shape = (self.dataset[0].media.width, self.dataset[0].media.height, 3) ov_mask_inferencer.model.resize_mask = False - ov_mask_inferencer.model.preprocess.return_value = ({"foo": "bar"}, {"baz": "qux"}) + ov_mask_inferencer.model.preprocess.return_value = ( + {"foo": "bar"}, + {"baz": "qux", "original_shape": original_shape}, + ) + ov_mask_inferencer.model.postprocess.return_value = ( + np.array([], dtype=np.float32), + np.array([], dtype=np.uint32), + np.zeros((0, 4), dtype=np.float32), + [], + ) ov_inferencer = OpenVINOTileClassifierWrapper( ov_mask_inferencer, tile_classifier_model_file="", tile_classifier_weight_file="", mode="sync" ) @@ -99,6 +108,10 @@ def test_openvino_sync(self, mocker): [], [np.zeros((0, 4), dtype=np.float32)], np.zeros((0, 4), dtype=np.float32) ), ) + ov_inferencer.tiler.model.infer_sync.return_value = { + "feature_vector": np.zeros((1, 5), dtype=np.float32), + "saliency_map": np.zeros((1, 1, 2, 2), dtype=np.float32), + } mocker.patch.object(OpenVINODetectionTask, "load_inferencer", return_value=ov_inferencer) ov_task = OpenVINODetectionTask(self.task_env) updated_dataset = ov_task.infer(self.dataset)