Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add label ids to model xml in release 1.5 #2591

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/otx/algorithms/anomaly/tasks/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,20 @@ def _add_metadata_to_ir(self, model_file: str, export_type: ExportType) -> None:

extra_model_data[("model_info", "reverse_input_channels")] = False
extra_model_data[("model_info", "model_type")] = "AnomalyDetection"
extra_model_data[("model_info", "labels")] = "Normal Anomaly"

labels = []
label_ids = []
for label_entity in self.task_environment.label_schema.get_labels(include_empty=False):
label_name = label_entity.name.replace(" ", "_")
# There is a mismatch between labels in OTX and modelAPI
if label_name == "Anomalous":
label_name = "Anomaly"
labels.append(label_name)
label_ids.append(str(label_entity.id_))

extra_model_data[("model_info", "labels")] = " ".join(labels)
extra_model_data[("model_info", "label_ids")] = " ".join(label_ids)

if export_type == ExportType.OPENVINO:
embed_ir_model_data(model_file, extra_model_data)
elif export_type == ExportType.ONNX:
Expand Down