Skip to content

Commit

Permalink
Update MAPI version (#2730)
Browse files Browse the repository at this point in the history
* Update MAPI version

* Update anomaly ov inference task

* Update reqs in exportable code

* Fix one more place of convertion of anomaly map
  • Loading branch information
sovrasov authored Dec 15, 2023
1 parent aceebda commit 18c713c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion requirements/openvino.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# OpenVINO Requirements. #
nncf==2.6.0
onnx==1.13.0
openvino-model-api==0.1.6
openvino-model-api==0.1.8
openvino==2023.0
openvino-dev==2023.0
openvino-telemetry==2023.2.*
11 changes: 7 additions & 4 deletions src/otx/algorithms/anomaly/tasks/openvino.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,27 +188,30 @@ def infer(self, dataset: DatasetEntity, inference_parameters: InferenceParameter
label = self.anomalous_label if image_result.pred_score >= 0.5 else self.normal_label
elif self.task_type == TaskType.ANOMALY_SEGMENTATION:
annotations = create_annotation_from_segmentation_map(
pred_mask, image_result.anomaly_map.squeeze(), {0: self.normal_label, 1: self.anomalous_label}
pred_mask,
image_result.anomaly_map.squeeze() / 255.0,
{0: self.normal_label, 1: self.anomalous_label},
)
dataset_item.append_annotations(annotations)
label = self.normal_label if len(annotations) == 0 else self.anomalous_label
elif self.task_type == TaskType.ANOMALY_DETECTION:
annotations = create_detection_annotation_from_anomaly_heatmap(
pred_mask, image_result.anomaly_map.squeeze(), {0: self.normal_label, 1: self.anomalous_label}
pred_mask,
image_result.anomaly_map.squeeze() / 255.0,
{0: self.normal_label, 1: self.anomalous_label},
)
dataset_item.append_annotations(annotations)
label = self.normal_label if len(annotations) == 0 else self.anomalous_label
else:
raise ValueError(f"Unknown task type: {self.task_type}")

dataset_item.append_labels([ScoredLabel(label=label, probability=float(probability))])
anomaly_map = (image_result.anomaly_map * 255).astype(np.uint8)
heatmap_media = ResultMediaEntity(
name="Anomaly Map",
type="anomaly_map",
label=label,
annotation_scene=dataset_item.annotation_scene,
numpy=anomaly_map,
numpy=image_result.anomaly_map,
)
dataset_item.append_metadata_item(heatmap_media)
update_progress_callback(int((idx + 1) / len(dataset) * 100))
Expand Down
4 changes: 2 additions & 2 deletions src/otx/api/usecases/exportable_code/demo/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
openvino==2023.0
openvino-model-api==0.1.6
otx==1.4.4
openvino-model-api==0.1.8
otx @ git+https://github.com/openvinotoolkit/training_extensions/@4abe2ea89680d4bdf54f97e1fa78abebd65c7e36#egg=otx
numpy>=1.21.0,<=1.23.5 # np.bool was removed in 1.24.0 which was used in openvino runtime
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def convert_to_annotation(self, predictions: AnomalyResult, metadata: Dict[str,
assert predictions.pred_mask is not None
assert predictions.anomaly_map is not None
annotations = create_annotation_from_segmentation_map(
predictions.pred_mask, predictions.anomaly_map, self.label_map
predictions.pred_mask, predictions.anomaly_map / 255.0, self.label_map
)
if len(annotations) == 0:
# TODO: add confidence to this label
Expand Down

0 comments on commit 18c713c

Please # to comment.