Skip to content

Commit e39ccfc

Browse files
committed
Restore create model from adapter
1 parent c113eac commit e39ccfc

File tree

1 file changed

+6
-4
lines changed
  • model_api/python/model_api/models

1 file changed

+6
-4
lines changed

model_api/python/model_api/models/model.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from typing import TYPE_CHECKING, Any, NoReturn, Type
1212

1313
from model_api.adapters.onnx_adapter import ONNXRuntimeAdapter
14+
from model_api.adapters.inference_adapter import InferenceAdapter
1415
from model_api.adapters.openvino_adapter import (
1516
OpenvinoAdapter,
1617
create_core,
@@ -23,7 +24,6 @@
2324

2425
from numpy import ndarray
2526

26-
from model_api.adapters.inference_adapter import InferenceAdapter
2727

2828

2929
class WrapperError(Exception):
@@ -126,7 +126,7 @@ def get_model_class(cls, name: str) -> Type:
126126
@classmethod
127127
def create_model(
128128
cls,
129-
model: str,
129+
model: str | InferenceAdapter,
130130
model_type: Any | None = None,
131131
configuration: dict[str, Any] = {},
132132
preload: bool = True,
@@ -144,7 +144,7 @@ def create_model(
144144
"""Create an instance of the Model API model
145145
146146
Args:
147-
model (str): model name from OpenVINO Model Zoo, path to model, OVMS URL
147+
model (str| InferenceAdapter): model name from OpenVINO Model Zoo, path to model, OVMS URL, or an adapter
148148
configuration (:obj:`dict`, optional): dictionary of model config with model properties, for example
149149
confidence_threshold, labels
150150
model_type (:obj:`str`, optional): name of model wrapper to create (e.g. "ssd")
@@ -166,7 +166,9 @@ def create_model(
166166
Model object
167167
"""
168168
inference_adapter: InferenceAdapter
169-
if isinstance(model, str) and re.compile(
169+
if isinstance(model, InferenceAdapter):
170+
inference_adapter = model
171+
elif isinstance(model, str) and re.compile(
170172
r"(\w+\.*\-*)*\w+:\d+\/models\/[a-zA-Z0-9._-]+(\:\d+)*",
171173
).fullmatch(model):
172174
inference_adapter = OVMSAdapter(model)

0 commit comments

Comments
 (0)