Skip to content

Commit

Permalink
Fix tile PTQ transform (#3261)
Browse files Browse the repository at this point in the history
fix tile PTQ transfomr
  • Loading branch information
eugene123tw authored Apr 4, 2024
1 parent b044dd2 commit cd6702a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/otx/core/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from jsonargparse import ArgumentParser
from lightning import LightningModule
from openvino.model_api.models import Model
from openvino.model_api.tilers import Tiler
from torch import Tensor, nn
from torch.optim.lr_scheduler import ConstantLR
from torch.optim.sgd import SGD
Expand Down Expand Up @@ -816,9 +817,11 @@ def transform_fn(self, data_batch: T_OTXBatchDataEntity) -> np.array:
"""Data transform function for PTQ."""
np_data = self._customize_inputs(data_batch)
image = np_data["inputs"][0]
resized_image = self.model.resize(image, (self.model.w, self.model.h))
resized_image = self.model.input_transform(resized_image)
return self.model._change_layout(resized_image) # noqa: SLF001
# NOTE: Tiler wraps the model, so we need to unwrap it to get the model
model = self.model.model if isinstance(self.model, Tiler) else self.model
resized_image = model.resize(image, (model.w, model.h))
resized_image = model.input_transform(resized_image)
return model._change_layout(resized_image) # noqa: SLF001

def _read_ptq_config_from_ir(self, ov_model: Model) -> dict[str, Any]:
"""Generates the PTQ (Post-Training Quantization) configuration from the meta data of the given OpenVINO model.
Expand Down

0 comments on commit cd6702a

Please sign in to comment.