Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tile PTQ transform #3261

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
"""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

Check warning on line 824 in src/otx/core/model/base.py

View check run for this annotation

Codecov / codecov/patch

src/otx/core/model/base.py#L821-L824

Added lines #L821 - L824 were not covered by tests

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
Loading