Skip to content

Commit 251eb42

Browse files
yunchusovrasov
andauthored
Mergeback 1.4.4 to 1.5.0 (#2745)
* Update MAPI version (#2730) * Update anomaly ov inference task * Update reqs in exportable code * Fix one more place of conversion of anomaly map * Update dependency for exportable code (#2732) * Fix unsupported dtype in ov graph constant converter --------- Co-authored-by: Vladislav Sovrasov <[email protected]>
1 parent a49d58f commit 251eb42

File tree

8 files changed

+16
-7
lines changed

8 files changed

+16
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ results/
1818
build/
1919
dist/
2020
!src/otx/recipes/**
21+
src/otx/recipes/**/__pycache__/
2122
*egg-info
2223

2324
*.pth

requirements/openvino.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# OpenVINO Requirements. #
33
nncf==2.6.0
44
onnx==1.13.0
5-
openvino-model-api==0.1.6
5+
openvino-model-api==0.1.8
66
openvino==2023.0
77
openvino-dev==2023.0
88
openvino-telemetry==2023.2.*

src/otx/algorithms/anomaly/tasks/openvino.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,27 +188,30 @@ def infer(self, dataset: DatasetEntity, inference_parameters: InferenceParameter
188188
label = self.anomalous_label if image_result.pred_score >= 0.5 else self.normal_label
189189
elif self.task_type == TaskType.ANOMALY_SEGMENTATION:
190190
annotations = create_annotation_from_segmentation_map(
191-
pred_mask, image_result.anomaly_map.squeeze(), {0: self.normal_label, 1: self.anomalous_label}
191+
pred_mask,
192+
image_result.anomaly_map.squeeze() / 255.0,
193+
{0: self.normal_label, 1: self.anomalous_label},
192194
)
193195
dataset_item.append_annotations(annotations)
194196
label = self.normal_label if len(annotations) == 0 else self.anomalous_label
195197
elif self.task_type == TaskType.ANOMALY_DETECTION:
196198
annotations = create_detection_annotation_from_anomaly_heatmap(
197-
pred_mask, image_result.anomaly_map.squeeze(), {0: self.normal_label, 1: self.anomalous_label}
199+
pred_mask,
200+
image_result.anomaly_map.squeeze() / 255.0,
201+
{0: self.normal_label, 1: self.anomalous_label},
198202
)
199203
dataset_item.append_annotations(annotations)
200204
label = self.normal_label if len(annotations) == 0 else self.anomalous_label
201205
else:
202206
raise ValueError(f"Unknown task type: {self.task_type}")
203207

204208
dataset_item.append_labels([ScoredLabel(label=label, probability=float(probability))])
205-
anomaly_map = (image_result.anomaly_map * 255).astype(np.uint8)
206209
heatmap_media = ResultMediaEntity(
207210
name="Anomaly Map",
208211
type="anomaly_map",
209212
label=label,
210213
annotation_scene=dataset_item.annotation_scene,
211-
numpy=anomaly_map,
214+
numpy=image_result.anomaly_map,
212215
)
213216
dataset_item.append_metadata_item(heatmap_media)
214217
update_progress_callback(int((idx + 1) / len(dataset) * 100))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
openvino==2023.0
2-
openvino-model-api==0.1.6
2+
openvino-model-api==0.1.8
33
otx==1.5.0
44
numpy>=1.21.0,<=1.23.5 # np.bool was removed in 1.24.0 which was used in openvino runtime

src/otx/api/usecases/exportable_code/prediction_to_annotation_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def convert_to_annotation(self, predictions: AnomalyResult, metadata: Dict[str,
380380
assert predictions.pred_mask is not None
381381
assert predictions.anomaly_map is not None
382382
annotations = create_annotation_from_segmentation_map(
383-
predictions.pred_mask, predictions.anomaly_map, self.label_map
383+
predictions.pred_mask, predictions.anomaly_map / 255.0, self.label_map
384384
)
385385
if len(annotations) == 0:
386386
# TODO: add confidence to this label

src/otx/core/ov/ops/infrastructures.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ def from_ov(cls, ov_op):
233233
if not np.array_equal(data, data_):
234234
logger.warning(f"Overflow detected in {op_name}")
235235
data = torch.from_numpy(data_)
236+
elif data.dtype == np.uint16:
237+
data = torch.from_numpy(data.astype(np.int32))
236238
else:
237239
data = torch.from_numpy(data)
238240

src/otx/core/ov/ops/type_conversions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"u1": torch.uint8, # no type in torch
2626
"u4": torch.uint8, # no type in torch
2727
"u8": torch.uint8,
28+
"u16": torch.int32, # no type in torch
2829
"u32": torch.int32, # no type in torch
2930
"u64": torch.int64, # no type in torch
3031
"i4": torch.int8, # no type in torch

tests/unit/core/ov/graph/test_ov_graph_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33
#
44

5+
import pytest
56
from otx.core.ov.graph.graph import Graph
67
from otx.core.ov.graph.utils import (
78
get_constant_input_nodes,
@@ -38,6 +39,7 @@ def test_handle_merging_into_batchnorm():
3839

3940

4041
@e2e_pytest_unit
42+
@pytest.mark.skip(reason="Updated models are not compatible with the paired batchnorm converter")
4143
def test_handle_paired_batchnorm():
4244
graph = get_graph()
4345
handle_paired_batchnorm(graph)

0 commit comments

Comments
 (0)