Skip to content

Commit 18c713c

Browse files
authored
Update MAPI version (#2730)
* Update MAPI version * Update anomaly ov inference task * Update reqs in exportable code * Fix one more place of convertion of anomaly map
1 parent aceebda commit 18c713c

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
openvino==2023.0
2-
openvino-model-api==0.1.6
3-
otx==1.4.4
2+
openvino-model-api==0.1.8
3+
otx @ git+https://github.com/openvinotoolkit/training_extensions/@4abe2ea89680d4bdf54f97e1fa78abebd65c7e36#egg=otx
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
@@ -370,7 +370,7 @@ def convert_to_annotation(self, predictions: AnomalyResult, metadata: Dict[str,
370370
assert predictions.pred_mask is not None
371371
assert predictions.anomaly_map is not None
372372
annotations = create_annotation_from_segmentation_map(
373-
predictions.pred_mask, predictions.anomaly_map, self.label_map
373+
predictions.pred_mask, predictions.anomaly_map / 255.0, self.label_map
374374
)
375375
if len(annotations) == 0:
376376
# TODO: add confidence to this label

0 commit comments

Comments
 (0)