Skip to content

Commit bccea76

Browse files
🔧 Fix exportable code handling for Tiler model in OVModel (#4234)
* 🔧 Fix exportable code handling for Tiler model in OVModel * 📖 Update CHANGELOG to include exportable code fix for tiling --------- Co-authored-by: Prokofiev Kirill <[email protected]>
1 parent af90324 commit bccea76

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ All notable changes to this project will be documented in this file.
1010

1111
### Bug fixes
1212

13+
- Fix exportable code for tiling
14+
(<https://github.com/openvinotoolkit/training_extensions/pull/4234>)
1315
- Don't filter empty label from kp arrow
1416
(<https://github.com/openvinotoolkit/training_extensions/pull/4229>)
1517

src/otx/core/model/base.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,14 +1038,25 @@ def export(
10381038
msg = "OpenVINO model can be exported only as exportable code with demo package."
10391039
raise RuntimeError(msg)
10401040

1041-
return self._exporter.export(
1042-
self.model,
1043-
output_dir,
1044-
base_name,
1045-
export_format,
1046-
precision,
1047-
to_exportable_code,
1048-
)
1041+
# Temporarily unwrap Tiler model if applicable
1042+
original_model = self.model
1043+
if isinstance(original_model, Tiler):
1044+
self.model = original_model.model
1045+
1046+
try:
1047+
exported_path = self._exporter.export(
1048+
self.model,
1049+
output_dir,
1050+
base_name,
1051+
export_format,
1052+
precision,
1053+
to_exportable_code,
1054+
)
1055+
finally:
1056+
# Restore the original model
1057+
self.model = original_model
1058+
1059+
return exported_path
10491060

10501061
def transform_fn(self, data_batch: T_OTXBatchDataEntity) -> np.array:
10511062
"""Data transform function for PTQ."""

0 commit comments

Comments
 (0)