clarifai 10.0.1__py3-none-any.whl → 10.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- clarifai/client/app.py +23 -43
- clarifai/client/base.py +46 -4
- clarifai/client/dataset.py +85 -33
- clarifai/client/input.py +35 -7
- clarifai/client/model.py +192 -11
- clarifai/client/module.py +8 -6
- clarifai/client/runner.py +3 -1
- clarifai/client/search.py +6 -3
- clarifai/client/user.py +14 -12
- clarifai/client/workflow.py +8 -5
- clarifai/datasets/upload/features.py +3 -0
- clarifai/datasets/upload/image.py +57 -26
- clarifai/datasets/upload/loaders/README.md +3 -4
- clarifai/datasets/upload/loaders/xview_detection.py +9 -5
- clarifai/datasets/upload/utils.py +23 -7
- clarifai/models/model_serving/README.md +113 -121
- clarifai/models/model_serving/__init__.py +2 -0
- clarifai/models/model_serving/cli/_utils.py +53 -0
- clarifai/models/model_serving/cli/base.py +14 -0
- clarifai/models/model_serving/cli/build.py +79 -0
- clarifai/models/model_serving/cli/clarifai_clis.py +33 -0
- clarifai/models/model_serving/cli/create.py +171 -0
- clarifai/models/model_serving/cli/example_cli.py +34 -0
- clarifai/models/model_serving/cli/login.py +26 -0
- clarifai/models/model_serving/cli/upload.py +182 -0
- clarifai/models/model_serving/constants.py +20 -0
- clarifai/models/model_serving/docs/cli.md +150 -0
- clarifai/models/model_serving/docs/concepts.md +229 -0
- clarifai/models/model_serving/docs/dependencies.md +1 -1
- clarifai/models/model_serving/docs/inference_parameters.md +112 -107
- clarifai/models/model_serving/docs/model_types.md +16 -17
- clarifai/models/model_serving/model_config/__init__.py +4 -2
- clarifai/models/model_serving/model_config/base.py +369 -0
- clarifai/models/model_serving/model_config/config.py +219 -224
- clarifai/models/model_serving/model_config/inference_parameter.py +5 -0
- clarifai/models/model_serving/model_config/model_types_config/multimodal-embedder.yaml +25 -24
- clarifai/models/model_serving/model_config/model_types_config/text-classifier.yaml +19 -18
- clarifai/models/model_serving/model_config/model_types_config/text-embedder.yaml +20 -18
- clarifai/models/model_serving/model_config/model_types_config/text-to-image.yaml +19 -18
- clarifai/models/model_serving/model_config/model_types_config/text-to-text.yaml +19 -18
- clarifai/models/model_serving/model_config/model_types_config/visual-classifier.yaml +22 -18
- clarifai/models/model_serving/model_config/model_types_config/visual-detector.yaml +32 -28
- clarifai/models/model_serving/model_config/model_types_config/visual-embedder.yaml +19 -18
- clarifai/models/model_serving/model_config/model_types_config/visual-segmenter.yaml +19 -18
- clarifai/models/model_serving/{models → model_config}/output.py +8 -0
- clarifai/models/model_serving/model_config/triton/__init__.py +14 -0
- clarifai/models/model_serving/model_config/{serializer.py → triton/serializer.py} +3 -1
- clarifai/models/model_serving/model_config/triton/triton_config.py +182 -0
- clarifai/models/model_serving/{models/model_types.py → model_config/triton/wrappers.py} +4 -4
- clarifai/models/model_serving/{models → repo_build}/__init__.py +2 -0
- clarifai/models/model_serving/repo_build/build.py +198 -0
- clarifai/models/model_serving/repo_build/static_files/_requirements.txt +2 -0
- clarifai/models/model_serving/repo_build/static_files/base_test.py +169 -0
- clarifai/models/model_serving/repo_build/static_files/inference.py +26 -0
- clarifai/models/model_serving/repo_build/static_files/sample_clarifai_config.yaml +25 -0
- clarifai/models/model_serving/repo_build/static_files/test.py +40 -0
- clarifai/models/model_serving/{models/pb_model.py → repo_build/static_files/triton/model.py} +15 -14
- clarifai/models/model_serving/utils.py +21 -0
- clarifai/rag/rag.py +67 -23
- clarifai/rag/utils.py +21 -5
- clarifai/utils/evaluation/__init__.py +427 -0
- clarifai/utils/evaluation/helpers.py +522 -0
- clarifai/utils/logging.py +7 -0
- clarifai/utils/model_train.py +3 -1
- clarifai/versions.py +1 -1
- {clarifai-10.0.1.dist-info → clarifai-10.1.1.dist-info}/METADATA +58 -10
- clarifai-10.1.1.dist-info/RECORD +115 -0
- clarifai-10.1.1.dist-info/entry_points.txt +2 -0
- clarifai/datasets/upload/loaders/coco_segmentation.py +0 -98
- clarifai/models/model_serving/cli/deploy_cli.py +0 -123
- clarifai/models/model_serving/cli/model_zip.py +0 -61
- clarifai/models/model_serving/cli/repository.py +0 -89
- clarifai/models/model_serving/docs/custom_config.md +0 -33
- clarifai/models/model_serving/docs/output.md +0 -28
- clarifai/models/model_serving/models/default_test.py +0 -281
- clarifai/models/model_serving/models/inference.py +0 -50
- clarifai/models/model_serving/models/test.py +0 -64
- clarifai/models/model_serving/pb_model_repository.py +0 -108
- clarifai-10.0.1.dist-info/RECORD +0 -103
- clarifai-10.0.1.dist-info/entry_points.txt +0 -4
- {clarifai-10.0.1.dist-info → clarifai-10.1.1.dist-info}/LICENSE +0 -0
- {clarifai-10.0.1.dist-info → clarifai-10.1.1.dist-info}/WHEEL +0 -0
- {clarifai-10.0.1.dist-info → clarifai-10.1.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,369 @@
|
|
1
|
+
from typing import Dict, Iterable, List, TypedDict, Union
|
2
|
+
|
3
|
+
import numpy as np
|
4
|
+
|
5
|
+
from ..constants import IMAGE_TENSOR_NAME, TEXT_TENSOR_NAME
|
6
|
+
from .config import ModelConfigClass, ModelTypes, get_model_config
|
7
|
+
from .output import (ClassifierOutput, EmbeddingOutput, ImageOutput, MasksOutput, TextOutput,
|
8
|
+
VisualDetectorOutput)
|
9
|
+
from .triton import wrappers as triton_wrapper
|
10
|
+
|
11
|
+
|
12
|
+
class _TypeCheckModelOutput(type):
|
13
|
+
|
14
|
+
def __new__(cls, name, bases, attrs):
|
15
|
+
"""
|
16
|
+
Override child `predict` function with parent._output_type_check(child.predict).
|
17
|
+
Aim to check if child.predict returns valid output type
|
18
|
+
"""
|
19
|
+
|
20
|
+
def wrap_function(fn_name, base, base_fn, other_fn):
|
21
|
+
|
22
|
+
def new_fn(_self,
|
23
|
+
input_data,
|
24
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}):
|
25
|
+
# Run child class
|
26
|
+
out = other_fn(_self, input_data, inference_parameters=inference_parameters)
|
27
|
+
# Run type check
|
28
|
+
return base_fn(base, input_data, out)
|
29
|
+
|
30
|
+
new_fn.__name__ = "wrapped_%s" % fn_name
|
31
|
+
new_fn.__doc__ = other_fn.__doc__
|
32
|
+
return new_fn
|
33
|
+
|
34
|
+
if name != "_BaseClarifaiModel":
|
35
|
+
attrs["predict"] = wrap_function("predict", bases[0],
|
36
|
+
getattr(bases[0], "_output_type_check", lambda: None),
|
37
|
+
attrs.setdefault("predict", lambda: None))
|
38
|
+
|
39
|
+
return type.__new__(cls, name, bases, attrs)
|
40
|
+
|
41
|
+
|
42
|
+
class _BaseClarifaiModel(metaclass=_TypeCheckModelOutput):
|
43
|
+
_config: ModelConfigClass = None
|
44
|
+
|
45
|
+
@property
|
46
|
+
def config(self):
|
47
|
+
return self._config
|
48
|
+
|
49
|
+
def _output_type_check(self, input, output):
|
50
|
+
output_type = self._config.clarifai_model.output_type
|
51
|
+
if isinstance(output, Iterable):
|
52
|
+
assert all(
|
53
|
+
each.__class__.__name__ == output_type for each in output
|
54
|
+
), f"Expected output is iteration of `{output_type}` type, got iteration `{output}`"
|
55
|
+
assert len(output) == len(
|
56
|
+
input
|
57
|
+
), f"Input length and output length must be equal, but got input length of {len(input)} and output length of {len(output)}"
|
58
|
+
else:
|
59
|
+
raise ValueError(f"Expected output is iteration of `{output_type}` type, got `{output}`")
|
60
|
+
return output
|
61
|
+
|
62
|
+
def predict(self,
|
63
|
+
input_data: Union[List[np.ndarray], Dict[str, List[np.ndarray]]],
|
64
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}) -> Iterable:
|
65
|
+
"""
|
66
|
+
Prediction method.
|
67
|
+
|
68
|
+
Args:
|
69
|
+
-----
|
70
|
+
- input_data: A list of input data item to predict on. The type depends on model input type:
|
71
|
+
* `image`: List[np.ndarray]
|
72
|
+
* `text`: List[str]
|
73
|
+
* `multimodal`:
|
74
|
+
input_data is list of dict where key is input type name e.i. `image`, `text` and value is list.
|
75
|
+
{"image": List[np.ndarray], "text": List[str]}
|
76
|
+
|
77
|
+
- inference_parameters (Dict[str, Union[bool, str, float, int]]): your inference parameters.
|
78
|
+
|
79
|
+
Returns:
|
80
|
+
--------
|
81
|
+
List of one of the `clarifai.models.model_serving.model_config.output` types. Refer to the README/docs
|
82
|
+
"""
|
83
|
+
raise NotImplementedError
|
84
|
+
|
85
|
+
def _tritonserver_predict(self,
|
86
|
+
input_data,
|
87
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}):
|
88
|
+
""" This method is invoked within tritonserver, specifically in the model.py of the Python backend. Attempting to execute it outside of the triton environment will result in failure."""
|
89
|
+
raise NotImplementedError
|
90
|
+
|
91
|
+
|
92
|
+
_MultiModalInputTypeDict = TypedDict("_MultiModalInputTypeDict", {
|
93
|
+
IMAGE_TENSOR_NAME: np.ndarray,
|
94
|
+
TEXT_TENSOR_NAME: str
|
95
|
+
})
|
96
|
+
|
97
|
+
|
98
|
+
class MultiModalEmbedder(_BaseClarifaiModel):
|
99
|
+
_config: ModelConfigClass = get_model_config(ModelTypes.multimodal_embedder)
|
100
|
+
|
101
|
+
def predict(self,
|
102
|
+
input_data: List[_MultiModalInputTypeDict],
|
103
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}
|
104
|
+
) -> Iterable[EmbeddingOutput]:
|
105
|
+
""" Custom prediction function for `multimodal-embedder` model.
|
106
|
+
|
107
|
+
Args:
|
108
|
+
input_data (List[_MultiModalInputTypeDict]): List of dict of key-value: `image`(np.ndarray) and `text` (str)
|
109
|
+
inference_parameters (Dict[str, Union[bool, str, float, int]]): your inference parameters
|
110
|
+
|
111
|
+
Returns:
|
112
|
+
list of EmbeddingOutput
|
113
|
+
"""
|
114
|
+
raise NotImplementedError
|
115
|
+
|
116
|
+
@triton_wrapper.multimodal_embedder
|
117
|
+
def _tritonserver_predict(self,
|
118
|
+
input_data,
|
119
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}):
|
120
|
+
""" This method is invoked within tritonserver, specifically in the model.py of the Python backend. Attempting to execute it outside of the triton environment will result in failure."""
|
121
|
+
return self.predict(input_data, inference_parameters=inference_parameters)
|
122
|
+
|
123
|
+
|
124
|
+
class TextClassifier(_BaseClarifaiModel):
|
125
|
+
_config: ModelConfigClass = get_model_config(ModelTypes.text_classifier)
|
126
|
+
|
127
|
+
def predict(self,
|
128
|
+
input_data: List[str],
|
129
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}
|
130
|
+
) -> Iterable[ClassifierOutput]:
|
131
|
+
""" Custom prediction function for `text-classifier` model.
|
132
|
+
|
133
|
+
Args:
|
134
|
+
input_data (List[str]): List of text
|
135
|
+
inference_parameters (Dict[str, Union[bool, str, float, int]]): your inference parameters
|
136
|
+
|
137
|
+
Returns:
|
138
|
+
list of ClassifierOutput
|
139
|
+
"""
|
140
|
+
raise NotImplementedError
|
141
|
+
|
142
|
+
@triton_wrapper.text_classifier
|
143
|
+
def _tritonserver_predict(self,
|
144
|
+
input_data,
|
145
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}):
|
146
|
+
return self.predict(input_data, inference_parameters=inference_parameters)
|
147
|
+
|
148
|
+
|
149
|
+
class TextEmbedder(_BaseClarifaiModel):
|
150
|
+
_config: ModelConfigClass = get_model_config(ModelTypes.text_embedder)
|
151
|
+
|
152
|
+
def predict(self,
|
153
|
+
input_data: List[str],
|
154
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}
|
155
|
+
) -> Iterable[EmbeddingOutput]:
|
156
|
+
""" Custom prediction function for `text-embedder` model.
|
157
|
+
|
158
|
+
Args:
|
159
|
+
input_data (List[str]): List of text
|
160
|
+
inference_parameters (Dict[str, Union[bool, str, float, int]]): your inference parameters
|
161
|
+
|
162
|
+
Returns:
|
163
|
+
list of EmbeddingOutput
|
164
|
+
"""
|
165
|
+
raise NotImplementedError
|
166
|
+
|
167
|
+
@triton_wrapper.text_embedder
|
168
|
+
def _tritonserver_predict(self,
|
169
|
+
input_data,
|
170
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}):
|
171
|
+
return self.predict(input_data, inference_parameters=inference_parameters)
|
172
|
+
|
173
|
+
|
174
|
+
class TextToImage(_BaseClarifaiModel):
|
175
|
+
_config: ModelConfigClass = get_model_config(ModelTypes.text_to_image)
|
176
|
+
|
177
|
+
def predict(
|
178
|
+
self,
|
179
|
+
input_data: List[str],
|
180
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}) -> Iterable[ImageOutput]:
|
181
|
+
""" Custom prediction function for `text-to-image` model.
|
182
|
+
|
183
|
+
Args:
|
184
|
+
input_data (List[str]): List of text
|
185
|
+
inference_parameters (Dict[str, Union[bool, str, float, int]]): your inference parameters
|
186
|
+
|
187
|
+
Returns:
|
188
|
+
list of ImageOutput
|
189
|
+
"""
|
190
|
+
raise NotImplementedError
|
191
|
+
|
192
|
+
@triton_wrapper.text_to_image
|
193
|
+
def _tritonserver_predict(self,
|
194
|
+
input_data,
|
195
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}):
|
196
|
+
return self.predict(input_data, inference_parameters=inference_parameters)
|
197
|
+
|
198
|
+
|
199
|
+
class TextToText(_BaseClarifaiModel):
|
200
|
+
_config: ModelConfigClass = get_model_config(ModelTypes.text_to_text)
|
201
|
+
|
202
|
+
def predict(
|
203
|
+
self,
|
204
|
+
input_data: List[str],
|
205
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}) -> Iterable[TextOutput]:
|
206
|
+
""" Custom prediction function for `text-to-text` (also called as `text generation`) model.
|
207
|
+
|
208
|
+
Args:
|
209
|
+
input_data (List[str]): List of text
|
210
|
+
inference_parameters (Dict[str, Union[bool, str, float, int]]): your inference parameters
|
211
|
+
|
212
|
+
Returns:
|
213
|
+
list of TextOutput
|
214
|
+
"""
|
215
|
+
raise NotImplementedError
|
216
|
+
|
217
|
+
@triton_wrapper.text_to_text
|
218
|
+
def _tritonserver_predict(self,
|
219
|
+
input_data,
|
220
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}):
|
221
|
+
""" This method is invoked within tritonserver, specifically in the model.py of the Python backend. Attempting to execute it outside of the triton environment will result in failure."""
|
222
|
+
return self.predict(input_data, inference_parameters=inference_parameters)
|
223
|
+
|
224
|
+
|
225
|
+
class VisualClassifier(_BaseClarifaiModel):
|
226
|
+
_config: ModelConfigClass = get_model_config(ModelTypes.visual_classifier)
|
227
|
+
|
228
|
+
def predict(self,
|
229
|
+
input_data: List[np.ndarray],
|
230
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}
|
231
|
+
) -> Iterable[ClassifierOutput]:
|
232
|
+
""" Custom prediction function for `visual-classifier` model.
|
233
|
+
|
234
|
+
Args:
|
235
|
+
input_data (List[np.ndarray]): List of image
|
236
|
+
inference_parameters (Dict[str, Union[bool, str, float, int]]): your inference parameters
|
237
|
+
|
238
|
+
Returns:
|
239
|
+
list of ClassifierOutput
|
240
|
+
"""
|
241
|
+
raise NotImplementedError
|
242
|
+
|
243
|
+
@triton_wrapper.visual_classifier
|
244
|
+
def _tritonserver_predict(self,
|
245
|
+
input_data,
|
246
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}):
|
247
|
+
""" This method is invoked within tritonserver, specifically in the model.py of the Python backend. Attempting to execute it outside of the triton environment will result in failure."""
|
248
|
+
return self.predict(input_data, inference_parameters=inference_parameters)
|
249
|
+
|
250
|
+
|
251
|
+
class VisualDetector(_BaseClarifaiModel):
|
252
|
+
_config: ModelConfigClass = get_model_config(ModelTypes.visual_detector)
|
253
|
+
|
254
|
+
def predict(self,
|
255
|
+
input_data: List[np.ndarray],
|
256
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}
|
257
|
+
) -> Iterable[VisualDetectorOutput]:
|
258
|
+
""" Custom prediction function for `visual-detector` model.
|
259
|
+
|
260
|
+
Args:
|
261
|
+
input_data (List[np.ndarray]): List of image
|
262
|
+
inference_parameters (Dict[str, Union[bool, str, float, int]]): your inference parameters
|
263
|
+
|
264
|
+
Returns:
|
265
|
+
list of VisualDetectorOutput
|
266
|
+
"""
|
267
|
+
raise NotImplementedError
|
268
|
+
|
269
|
+
@triton_wrapper.visual_detector
|
270
|
+
def _tritonserver_predict(self,
|
271
|
+
input_data,
|
272
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}):
|
273
|
+
""" This method is invoked within tritonserver, specifically in the model.py of the Python backend. Attempting to execute it outside of the triton environment will result in failure."""
|
274
|
+
return self.predict(input_data, inference_parameters=inference_parameters)
|
275
|
+
|
276
|
+
@staticmethod
|
277
|
+
def postprocess(width: int,
|
278
|
+
height: int,
|
279
|
+
labels: list,
|
280
|
+
scores: list,
|
281
|
+
xyxy_boxes: list,
|
282
|
+
max_bbox_count: int = 500) -> VisualDetectorOutput:
|
283
|
+
"""Convert detection output to Clarifai detector output format
|
284
|
+
|
285
|
+
Args:
|
286
|
+
width (int): image width
|
287
|
+
height (int): image height
|
288
|
+
labels (list): list of labels
|
289
|
+
scores (list): list of scores
|
290
|
+
xyxy_boxes (list): list of bounding boxes in x_min, y_min, x_max, y_max format
|
291
|
+
max_bbox_count (int, optional): Maximum detection result. Defaults to 500.
|
292
|
+
|
293
|
+
Returns:
|
294
|
+
VisualDetectorOutput
|
295
|
+
"""
|
296
|
+
assert len(labels) == len(scores) == len(
|
297
|
+
xyxy_boxes
|
298
|
+
), f"Length of `labels`, `scores` and `bboxes` must be equal, got {len(labels)}, {len(scores)} and {len(xyxy_boxes)} "
|
299
|
+
labels = [[each] for each in labels]
|
300
|
+
scores = [[each] for each in scores]
|
301
|
+
bboxes = [[x[1] / height, x[0] / width, x[3] / height, x[2] / width]
|
302
|
+
for x in xyxy_boxes] # normalize the bboxes to [0,1] and [y1 x1 y2 x2]
|
303
|
+
bboxes = np.clip(bboxes, 0, 1.)
|
304
|
+
if len(bboxes) != 0:
|
305
|
+
bboxes = np.concatenate((bboxes, np.zeros((max_bbox_count - len(bboxes), 4))))
|
306
|
+
scores = np.concatenate((scores, np.zeros((max_bbox_count - len(scores), 1))))
|
307
|
+
labels = np.concatenate((labels, np.zeros((max_bbox_count - len(labels), 1),
|
308
|
+
dtype=np.int32)))
|
309
|
+
else:
|
310
|
+
bboxes = np.zeros((max_bbox_count, 4), dtype=np.float32)
|
311
|
+
scores = np.zeros((max_bbox_count, 1), dtype=np.float32)
|
312
|
+
labels = np.zeros((max_bbox_count, 1), dtype=np.int32)
|
313
|
+
|
314
|
+
output = VisualDetectorOutput(
|
315
|
+
predicted_bboxes=bboxes, predicted_labels=labels, predicted_scores=scores)
|
316
|
+
|
317
|
+
return output
|
318
|
+
|
319
|
+
|
320
|
+
class VisualEmbedder(_BaseClarifaiModel):
|
321
|
+
_config: ModelConfigClass = get_model_config(ModelTypes.visual_embedder)
|
322
|
+
|
323
|
+
def predict(self,
|
324
|
+
input_data: List[np.ndarray],
|
325
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}
|
326
|
+
) -> Iterable[EmbeddingOutput]:
|
327
|
+
""" Custom prediction function for `visual-embedder` model.
|
328
|
+
|
329
|
+
Args:
|
330
|
+
input_data (List[np.ndarray]): List of image
|
331
|
+
inference_parameters (Dict[str, Union[bool, str, float, int]]): your inference parameters
|
332
|
+
|
333
|
+
Returns:
|
334
|
+
list of EmbeddingOutput
|
335
|
+
"""
|
336
|
+
raise NotImplementedError
|
337
|
+
|
338
|
+
@triton_wrapper.visual_embedder
|
339
|
+
def _tritonserver_predict(self,
|
340
|
+
input_data,
|
341
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}):
|
342
|
+
""" This method is invoked within tritonserver, specifically in the model.py of the Python backend. Attempting to execute it outside of the triton environment will result in failure."""
|
343
|
+
return self.predict(input_data, inference_parameters=inference_parameters)
|
344
|
+
|
345
|
+
|
346
|
+
class VisualSegmenter(_BaseClarifaiModel):
|
347
|
+
_config: ModelConfigClass = get_model_config(ModelTypes.visual_segmenter)
|
348
|
+
|
349
|
+
def predict(
|
350
|
+
self,
|
351
|
+
input_data: List[np.ndarray],
|
352
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}) -> Iterable[MasksOutput]:
|
353
|
+
""" Custom prediction function for `visual-segmenter` model.
|
354
|
+
|
355
|
+
Args:
|
356
|
+
input_data (List[np.ndarray]): List of image
|
357
|
+
inference_parameters (Dict[str, Union[bool, str, float, int]]): your inference parameters
|
358
|
+
|
359
|
+
Returns:
|
360
|
+
list of MasksOutput
|
361
|
+
"""
|
362
|
+
raise NotImplementedError
|
363
|
+
|
364
|
+
@triton_wrapper.visual_segmenter
|
365
|
+
def _tritonserver_predict(self,
|
366
|
+
input_data,
|
367
|
+
inference_parameters: Dict[str, Union[bool, str, float, int]] = {}):
|
368
|
+
""" This method is invoked within tritonserver, specifically in the model.py of the Python backend. Attempting to execute it outside of the triton environment will result in failure."""
|
369
|
+
return self.predict(input_data, inference_parameters=inference_parameters)
|