From a2d2c81f291aad479db4c98816bae10541ee4c0c Mon Sep 17 00:00:00 2001 From: Harim Kang Date: Fri, 25 Oct 2024 13:28:37 +0900 Subject: [PATCH] Fix incorrect all_groups order configuration in HLabelInfo (#4067) * Fix all_labels * Update CHAGELOG * label_groups change --- CHANGELOG.md | 4 ++++ src/otx/__init__.py | 2 +- src/otx/core/types/label.py | 21 +++++++++++---------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 570682d6fd..5b6ed7e7ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,8 @@ All notable changes to this project will be documented in this file. () - Update HPO interface () +- Bump onnx to 1.17.0 to omit CVE-2024-5187 + () ### Bug fixes @@ -104,6 +106,8 @@ All notable changes to this project will be documented in this file. () - Fix applying model's hparams when loading model from checkpoint () +- Fix incorrect all_groups order configuration in HLabelInfo + () ## \[v2.1.0\] diff --git a/src/otx/__init__.py b/src/otx/__init__.py index 11d4d3f1be..4799025869 100644 --- a/src/otx/__init__.py +++ b/src/otx/__init__.py @@ -3,7 +3,7 @@ # Copyright (C) 2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -__version__ = "2.2.0rc11" +__version__ = "2.2.0rc12" import os from pathlib import Path diff --git a/src/otx/core/types/label.py b/src/otx/core/types/label.py index b9e26b4851..c89f67d7fd 100644 --- a/src/otx/core/types/label.py +++ b/src/otx/core/types/label.py @@ -169,10 +169,8 @@ def from_dm_label_groups(cls, dm_label_categories: LabelCategories) -> HLabelInf dm_label_categories (LabelCategories): the label categories of datumaro. """ - def get_exclusive_group_info(all_groups: list[Label | list[Label]]) -> dict[str, Any]: + def get_exclusive_group_info(exclusive_groups: list[Label | list[Label]]) -> dict[str, Any]: """Get exclusive group information.""" - exclusive_groups = [g for g in all_groups if len(g) > 1] - last_logits_pos = 0 num_single_label_classes = 0 head_idx_to_logits_range = {} @@ -193,12 +191,10 @@ def get_exclusive_group_info(all_groups: list[Label | list[Label]]) -> dict[str, } def get_single_label_group_info( - all_groups: list[Label | list[Label]], + single_label_groups: list[Label | list[Label]], num_exclusive_groups: int, ) -> dict[str, Any]: """Get single label group information.""" - single_label_groups = [g for g in all_groups if len(g) == 1] - class_to_idx = {} for i, group in enumerate(single_label_groups): @@ -256,8 +252,13 @@ def convert_labels_if_needed( label_names = [item.name for item in dm_label_categories.items] all_groups = convert_labels_if_needed(dm_label_categories, label_names) - exclusive_group_info = get_exclusive_group_info(all_groups) - single_label_group_info = get_single_label_group_info(all_groups, exclusive_group_info["num_multiclass_heads"]) + exclusive_groups = [g for g in all_groups if len(g) > 1] + exclusive_group_info = get_exclusive_group_info(exclusive_groups) + single_label_groups = [g for g in all_groups if len(g) == 1] + single_label_group_info = get_single_label_group_info( + single_label_groups, + exclusive_group_info["num_multiclass_heads"], + ) merged_class_to_idx = merge_class_to_idx( exclusive_group_info["class_to_idx"], @@ -268,13 +269,13 @@ def convert_labels_if_needed( return HLabelInfo( label_names=label_names, - label_groups=all_groups, + label_groups=exclusive_groups + single_label_groups, num_multiclass_heads=exclusive_group_info["num_multiclass_heads"], num_multilabel_classes=single_label_group_info["num_multilabel_classes"], head_idx_to_logits_range=exclusive_group_info["head_idx_to_logits_range"], num_single_label_classes=exclusive_group_info["num_single_label_classes"], class_to_group_idx=merged_class_to_idx, - all_groups=all_groups, + all_groups=exclusive_groups + single_label_groups, label_to_idx=label_to_idx, label_tree_edges=get_label_tree_edges(dm_label_categories.items), empty_multiclass_head_indices=[], # consider the label removing case