Skip to content

Commit 94d4f3f

Browse files
authored
BC improvement (#4154)
* Add OTX version to exported models * Forward data format to tiling dataset to fix arrow handling * Workaround missing label_ids * Version up * Update release notes * Update changelog
1 parent 87e10c7 commit 94d4f3f

File tree

7 files changed

+28
-1
lines changed

7 files changed

+28
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## \[2.2.2\]
6+
7+
### Bug fixes
8+
9+
- BC improvement
10+
(<https://github.com/openvinotoolkit/training_extensions/pull/4154>)
11+
512
## \[2.2.1\]
613

714
### Bug fixes

docs/source/guide/release_notes/index.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ Releases
44
.. toctree::
55
:maxdepth: 1
66

7+
v2.2.2 (2024.12)
8+
----------------
9+
10+
Enhancements
11+
^^^^^^^^^^^^
12+
13+
Bug fixes
14+
^^^^^^^^^
15+
16+
- BC improvement
17+
718
v2.2.1 (2024.12)
819
----------------
920

src/otx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright (C) 2024 Intel Corporation
44
# SPDX-License-Identifier: Apache-2.0
55

6-
__version__ = "2.2.1"
6+
__version__ = "2.2.2"
77

88
import os
99
from pathlib import Path

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ def __init__(self, dataset: OTXDataset, tile_config: TileConfig) -> None:
263263
dataset.image_color_channel,
264264
dataset.stack_images,
265265
dataset.to_tv_image,
266+
data_format=dataset.data_format,
266267
)
267268
self.tile_config = tile_config
268269
self._dataset = dataset

src/otx/core/model/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,11 @@ def load_state_dict_incrementally(self, ckpt: dict[str, Any], *args, **kwargs) -
391391
msg = "Checkpoint should have `label_info`."
392392
raise ValueError(msg, ckpt_label_info)
393393

394+
if not hasattr(ckpt_label_info, "label_ids"):
395+
msg = "Loading checkpoint from OTX < 2.2.1, label_ids are assigned automatically"
396+
logger.info(msg)
397+
ckpt_label_info.label_ids = [str(i) for i, _ in enumerate(ckpt_label_info.label_names)]
398+
394399
if ckpt_label_info != self.label_info:
395400
msg = (
396401
"Load model state dictionary incrementally: "

src/otx/core/types/export.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from dataclasses import dataclass, fields
1010
from enum import Enum
1111

12+
import otx
1213
from otx.core.config.data import TileConfig
1314
from otx.core.types.label import HLabelInfo, LabelInfo
1415

@@ -122,6 +123,7 @@ def to_metadata(self) -> dict[tuple[str, str], str]:
122123
("model_info", "labels"): all_labels.strip(),
123124
("model_info", "label_ids"): all_label_ids.strip(),
124125
("model_info", "optimization_config"): json.dumps(self.optimization_config),
126+
("model_info", "otx_version"): otx.__version__,
125127
}
126128

127129
if isinstance(self.label_info, HLabelInfo):

tests/unit/core/types/test_export.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ def test_wrap(fxt_label_info, task_type):
5252
assert ("model_info", "tile_size") in metadata
5353
assert ("model_info", "tiles_overlap") in metadata
5454
assert ("model_info", "max_pred_number") in metadata
55+
assert ("model_info", "otx_version") in metadata

0 commit comments

Comments
 (0)