Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def __init__(self, labels: LabelList, configuration: dict[str, Any]):
)
for i in range(n_missing_ids):
label_ids.append(f"generated_label_{i}")

# Assumes configuration['label_ids'] and configuration['labels'] have the same ordering
for i, (label_id_str, label_str) in enumerate(zip(label_ids, model_api_labels)):
try:
Expand Down Expand Up @@ -184,7 +183,7 @@ def convert_to_prediction(
labels = []
for label in inference_results.top_labels:
label_idx, label_name, label_prob = label
scored_label = ScoredLabel.from_label(label=self.get_label_by_idx(label_idx), probability=label_prob)
scored_label = ScoredLabel.from_label(label=self.get_label_by_str(label_name), probability=label_prob)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with get_label_by_idx?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember that MAPI does not handle hierarchical classification in a consistent way, so we could not rely on the label indices. See related issue: open-edge-platform/geti#402.

Therefore, it is correct to use the label name for classification tasks. However, this means that we might get ambigous results if label are poorly named. For example, foo bar and foo_bar, spaces are not supported by either MAPI or OV AFAIK, resulting in a name collision.

labels.append(scored_label)

if not labels and self.empty_label:
Expand Down
6 changes: 3 additions & 3 deletions tests/pre-merge/unit/deployment/test_prediction_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ def test_keypoint_to_prediction_converter(self, fxt_label_list_factory):
[
(
["1", "2"],
["foo bar", "foo_bar"],
["foo_bar", "foo_bar"],
{"label_ids": ["1", "2"], "labels": ["foo_bar", "foo_bar"]},
["foo bar1", "foo_bar2"],
["foo_bar1", "foo_bar2"],
{"label_ids": ["1", "2"], "labels": ["foo_bar1", "foo_bar2"]},
Comment on lines -312 to +314
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this test case was to check an edge case where the label names are very similar and conflict after escaping (both foo bar and foo_bar become foo_bar). The new label names foo bar1 and foo_bar2 do not trigger the intended edge case.

),
(
["1", "2"],
Expand Down
Loading