1111from typing import TYPE_CHECKING , Any , NoReturn , Type
1212
1313from model_api .adapters .onnx_adapter import ONNXRuntimeAdapter
14+ from model_api .adapters .inference_adapter import InferenceAdapter
1415from model_api .adapters .openvino_adapter import (
1516 OpenvinoAdapter ,
1617 create_core ,
2324
2425 from numpy import ndarray
2526
26- from model_api .adapters .inference_adapter import InferenceAdapter
2727
2828
2929class 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