Skip to content

Commit ca5f74d

Browse files
authored
Remove custom modelapi patch in visual prompting (#2359)
* Remove custom modelapi patch * Update test
1 parent 7924b5a commit ca5f74d

File tree

5 files changed

+6
-177
lines changed

5 files changed

+6
-177
lines changed

src/otx/algorithms/visual_prompting/adapters/openvino/model_wrappers/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@
1414
# See the License for the specific language governing permissions
1515
# and limitations under the License.
1616

17-
from .openvino_adapters import VisualPromptingOpenvinoAdapter # noqa: F401
1817
from .openvino_models import Decoder, ImageEncoder # noqa: F401

src/otx/algorithms/visual_prompting/adapters/openvino/model_wrappers/openvino_adapters.py

Lines changed: 0 additions & 164 deletions
This file was deleted.

src/otx/algorithms/visual_prompting/tasks/openvino.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,13 @@
2929
import numpy as np
3030
import openvino.runtime as ov
3131
from nncf.common.quantization.structs import QuantizationPreset
32-
from openvino.model_api.adapters import create_core
32+
from openvino.model_api.adapters import OpenvinoAdapter, create_core
3333
from openvino.model_api.models import Model
3434

3535
from otx.algorithms.common.utils.ir import check_if_quantized
3636
from otx.algorithms.common.utils.logger import get_logger
3737
from otx.algorithms.common.utils.utils import get_default_async_reqs_num
3838
from otx.algorithms.visual_prompting.adapters.openvino import model_wrappers
39-
from otx.algorithms.visual_prompting.adapters.openvino.model_wrappers import (
40-
VisualPromptingOpenvinoAdapter,
41-
)
4239
from otx.algorithms.visual_prompting.adapters.pytorch_lightning.datasets.dataset import (
4340
OTXVisualPromptingDataset,
4441
get_transform,
@@ -126,7 +123,7 @@ def __init__(
126123
},
127124
}
128125
for name in ["image_encoder", "decoder"]:
129-
model_adapter = VisualPromptingOpenvinoAdapter(
126+
model_adapter = OpenvinoAdapter(
130127
core=create_core(),
131128
model=model_files.get(name),
132129
weights_path=weight_files.get(name, None),

tests/unit/algorithms/visual_prompting/adapters/openvino/model_wrappers/test_openvino_models.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
import pytest
1111
from openvino.model_api.adapters.openvino_adapter import OpenvinoAdapter
1212
from openvino.model_api.models import ImageModel, SegmentationModel
13-
from openvino.model_api.models.types import BooleanValue, NumericalValue
13+
from openvino.model_api.models.types import NumericalValue
1414

1515
from otx.algorithms.visual_prompting.adapters.openvino.model_wrappers import (
1616
Decoder,
1717
ImageEncoder,
18-
VisualPromptingOpenvinoAdapter,
1918
)
2019
from otx.api.entities.label import LabelEntity
2120
from tests.test_suite.e2e_test_system import e2e_pytest_unit
@@ -52,7 +51,7 @@ class TestDecoder:
5251
@pytest.fixture(autouse=True)
5352
def setup(self, mocker):
5453
mocker.patch.object(SegmentationModel, "__init__")
55-
mocker_model_adapter = mocker.Mock(spec=VisualPromptingOpenvinoAdapter)
54+
mocker_model_adapter = mocker.Mock(spec=OpenvinoAdapter)
5655
self.decoder = Decoder(mocker_model_adapter)
5756
self.decoder.image_size = 6
5857

tests/unit/algorithms/visual_prompting/tasks/test_openvino.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ def setup(self, mocker):
5858
labels=[ScoredLabel(LabelEntity(name="fake", domain="VISUALPROMPTING"), probability=1.0)],
5959
)
6060
]
61-
# FIXME: change VisualPromptingOpenvinoAdapter to OpenvinoAdapter after model api version update
62-
mocker.patch("otx.algorithms.visual_prompting.tasks.openvino.VisualPromptingOpenvinoAdapter")
61+
mocker.patch("otx.algorithms.visual_prompting.tasks.openvino.OpenvinoAdapter")
6362
mocker.patch.object(Model, "create_model")
6463
mocker.patch.object(
6564
VisualPromptingToAnnotationConverter, "convert_to_annotation", return_value=self.fake_annotation
@@ -231,8 +230,7 @@ def otx_model(self):
231230
@pytest.fixture(autouse=True)
232231
def setup(self, mocker, otx_model):
233232
"""Load the OpenVINOVisualPromptingTask."""
234-
# FIXME: change VisualPromptingOpenvinoAdapter to OpenvinoAdapter after model api version update
235-
mocker.patch("otx.algorithms.visual_prompting.tasks.openvino.VisualPromptingOpenvinoAdapter")
233+
mocker.patch("otx.algorithms.visual_prompting.tasks.openvino.OpenvinoAdapter")
236234
mocker.patch.object(Model, "create_model")
237235
self.task_environment = init_environment()
238236
visual_prompting_hparams = self.task_environment.get_hyper_parameters(VisualPromptingBaseConfig)

0 commit comments

Comments
 (0)