Skip to content

Commit f2d5476

Browse files
authored
Don't apply labels normalization on training (#3886)
* Don't apply labels normalization on training * Fix black
1 parent ab54588 commit f2d5476

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/otx/algorithms/classification/utils/cls_utils.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@
2626
from otx.api.utils.labels_utils import get_normalized_label_name
2727

2828

29-
def get_multihead_class_info(label_schema: LabelSchemaEntity): # pylint: disable=too-many-locals
29+
def get_multihead_class_info(
30+
label_schema: LabelSchemaEntity, normalize_labels: bool = False
31+
): # pylint: disable=too-many-locals
3032
"""Get multihead info by label schema."""
3133
all_groups = label_schema.get_groups(include_empty=False)
3234
all_groups_str = []
3335
for g in all_groups:
34-
group_labels_str = [get_normalized_label_name(lbl) for lbl in g.labels]
36+
if normalize_labels:
37+
group_labels_str = [get_normalized_label_name(lbl) for lbl in g.labels]
38+
else:
39+
group_labels_str = [lbl.name for lbl in g.labels]
3540
all_groups_str.append(group_labels_str)
3641

3742
single_label_groups = [g for g in all_groups_str if len(g) == 1]
@@ -77,7 +82,7 @@ def get_cls_inferencer_configuration(label_schema: LabelSchemaEntity):
7782
hierarchical = not multilabel and len(label_schema.get_groups(False)) > 1
7883
multihead_class_info = {}
7984
if hierarchical:
80-
multihead_class_info = get_multihead_class_info(label_schema)
85+
multihead_class_info = get_multihead_class_info(label_schema, normalize_labels=True)
8186
return {
8287
"multilabel": multilabel,
8388
"hierarchical": hierarchical,
@@ -120,7 +125,7 @@ def get_cls_model_api_configuration(label_schema: LabelSchemaEntity, inference_c
120125
mapi_config[("model_info", "label_ids")] = all_label_ids.strip()
121126

122127
hierarchical_config = {}
123-
hierarchical_config["cls_heads_info"] = get_multihead_class_info(label_schema)
128+
hierarchical_config["cls_heads_info"] = get_multihead_class_info(label_schema, normalize_labels=True)
124129
hierarchical_config["label_tree_edges"] = []
125130
for edge in label_schema.label_tree.edges: # (child, parent)
126131
hierarchical_config["label_tree_edges"].append(

0 commit comments

Comments
 (0)