Skip to content

Commit 0c3cd2f

Browse files
authored
Minor updates (#4162)
* Bump OV and NNCF * Update iseg empty label handling * Update bg label handling in sseg * Update changelog * Add extra check to export params * Update test case implementation
1 parent 8a82764 commit 0c3cd2f

File tree

7 files changed

+31
-3
lines changed

7 files changed

+31
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ All notable changes to this project will be documented in this file.
4747
(<https://github.com/openvinotoolkit/training_extensions/pull/3843>)
4848
- Add mAP metric to evaluate multilabel classification
4949
(<https://github.com/openvinotoolkit/training_extensions/pull/3985>)
50+
- Bump OV to 2024.6, update empty label handling
51+
(<https://github.com/openvinotoolkit/training_extensions/pull/4162>)
5052

5153
### Bug fixes
5254

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ base = [
7979
"lightning==2.4.0",
8080
"pytorchcv==0.0.67",
8181
"timm==1.0.3",
82-
"openvino==2024.5",
83-
"openvino-dev==2024.5",
82+
"openvino==2024.6",
83+
"openvino-dev==2024.6",
8484
"openvino-model-api==0.2.5",
8585
"onnx==1.17.0",
8686
"onnxconverter-common==1.14.0",
87-
"nncf==2.14.0",
87+
"nncf==2.14.1",
8888
"anomalib[core]==1.1.0",
8989
]
9090

src/otx/core/data/dataset/segmentation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ def __init__(
184184
if self.has_polygons:
185185
# insert background class at index 0 since polygons represent only objects
186186
self.label_info.label_names.insert(0, "otx_background_lbl")
187+
self.label_info.label_ids.insert(0, "None")
187188

188189
self.label_info = SegLabelInfo(
189190
label_names=self.label_info.label_names,

src/otx/core/model/instance_segmentation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ def _export_parameters(self) -> TaskLevelExportParameters:
280280
modified_label_info = copy.deepcopy(self.label_info)
281281
# Instance segmentation needs to add empty label to satisfy MAPI wrapper requirements
282282
modified_label_info.label_names.insert(0, "otx_empty_lbl")
283+
modified_label_info.label_ids.insert(0, "None")
283284

284285
return super()._export_parameters.wrap(
285286
model_type="MaskRCNN",
@@ -773,6 +774,7 @@ def _create_label_info_from_ov_ir(self) -> LabelInfo:
773774
# workaround to hide extra otx_empty_lbl
774775
if ir_label_info.label_names[0] == "otx_empty_lbl":
775776
ir_label_info.label_names.pop(0)
777+
ir_label_info.label_ids.pop(0)
776778
ir_label_info.label_groups[0].pop(0)
777779
return ir_label_info
778780

src/otx/core/model/segmentation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ def _export_parameters(self) -> TaskLevelExportParameters:
192192
# remove otx background label for export
193193
modified_label_info = copy.deepcopy(self.label_info)
194194
modified_label_info.label_names.pop(0)
195+
modified_label_info.label_ids.pop(0)
195196
else:
196197
modified_label_info = self.label_info
197198

src/otx/core/types/export.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ def to_metadata(self) -> dict[tuple[str, str], str]:
101101
"""
102102
all_labels = ""
103103
all_label_ids = ""
104+
105+
if len(self.label_info.label_names) != len(self.label_info.label_ids):
106+
msg = "Label info is incorrect: label names and IDs do not match"
107+
raise RuntimeError(msg)
108+
104109
for lbl in self.label_info.label_names:
105110
all_labels += lbl.replace(" ", "_") + " "
106111
for lbl_id in self.label_info.label_ids:

tests/unit/core/types/test_export.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (C) 2024 Intel Corporation
22
# SPDX-License-Identifier: Apache-2.0
33

4+
from copy import deepcopy
5+
46
import pytest
57
from otx.core.config.data import TileConfig
68
from otx.core.types.export import TaskLevelExportParameters
@@ -53,3 +55,18 @@ def test_wrap(fxt_label_info, task_type):
5355
assert ("model_info", "tiles_overlap") in metadata
5456
assert ("model_info", "max_pred_number") in metadata
5557
assert ("model_info", "otx_version") in metadata
58+
59+
60+
def test_to_metadata_label_consistency(fxt_label_info):
61+
label_info = deepcopy(fxt_label_info)
62+
label_info.label_ids.append("new id")
63+
64+
params = TaskLevelExportParameters(
65+
model_type="dummy model",
66+
task_type="instance_segmentation",
67+
label_info=label_info,
68+
optimization_config={},
69+
)
70+
71+
with pytest.raises(RuntimeError, match="incorrect"):
72+
params.to_metadata()

0 commit comments

Comments
 (0)