inference-models 0.18.3__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.
- inference_models/__init__.py +36 -0
- inference_models/configuration.py +72 -0
- inference_models/constants.py +2 -0
- inference_models/entities.py +5 -0
- inference_models/errors.py +137 -0
- inference_models/logger.py +52 -0
- inference_models/model_pipelines/__init__.py +0 -0
- inference_models/model_pipelines/auto_loaders/__init__.py +0 -0
- inference_models/model_pipelines/auto_loaders/core.py +120 -0
- inference_models/model_pipelines/auto_loaders/pipelines_registry.py +36 -0
- inference_models/model_pipelines/face_and_gaze_detection/__init__.py +0 -0
- inference_models/model_pipelines/face_and_gaze_detection/mediapipe_l2cs.py +200 -0
- inference_models/models/__init__.py +0 -0
- inference_models/models/auto_loaders/__init__.py +0 -0
- inference_models/models/auto_loaders/access_manager.py +168 -0
- inference_models/models/auto_loaders/auto_negotiation.py +1329 -0
- inference_models/models/auto_loaders/auto_resolution_cache.py +129 -0
- inference_models/models/auto_loaders/constants.py +7 -0
- inference_models/models/auto_loaders/core.py +1341 -0
- inference_models/models/auto_loaders/dependency_models.py +52 -0
- inference_models/models/auto_loaders/entities.py +57 -0
- inference_models/models/auto_loaders/models_registry.py +497 -0
- inference_models/models/auto_loaders/presentation_utils.py +333 -0
- inference_models/models/auto_loaders/ranking.py +413 -0
- inference_models/models/auto_loaders/utils.py +31 -0
- inference_models/models/base/__init__.py +0 -0
- inference_models/models/base/classification.py +123 -0
- inference_models/models/base/depth_estimation.py +62 -0
- inference_models/models/base/documents_parsing.py +111 -0
- inference_models/models/base/embeddings.py +66 -0
- inference_models/models/base/instance_segmentation.py +87 -0
- inference_models/models/base/keypoints_detection.py +93 -0
- inference_models/models/base/object_detection.py +143 -0
- inference_models/models/base/semantic_segmentation.py +74 -0
- inference_models/models/base/types.py +5 -0
- inference_models/models/clip/__init__.py +0 -0
- inference_models/models/clip/clip_onnx.py +148 -0
- inference_models/models/clip/clip_pytorch.py +104 -0
- inference_models/models/clip/preprocessing.py +162 -0
- inference_models/models/common/__init__.py +0 -0
- inference_models/models/common/cuda.py +30 -0
- inference_models/models/common/model_packages.py +25 -0
- inference_models/models/common/onnx.py +379 -0
- inference_models/models/common/roboflow/__init__.py +0 -0
- inference_models/models/common/roboflow/model_packages.py +361 -0
- inference_models/models/common/roboflow/post_processing.py +436 -0
- inference_models/models/common/roboflow/pre_processing.py +1332 -0
- inference_models/models/common/torch.py +20 -0
- inference_models/models/common/trt.py +266 -0
- inference_models/models/deep_lab_v3_plus/__init__.py +0 -0
- inference_models/models/deep_lab_v3_plus/deep_lab_v3_plus_segmentation_onnx.py +282 -0
- inference_models/models/deep_lab_v3_plus/deep_lab_v3_plus_segmentation_torch.py +264 -0
- inference_models/models/deep_lab_v3_plus/deep_lab_v3_plus_segmentation_trt.py +313 -0
- inference_models/models/depth_anything_v2/__init__.py +0 -0
- inference_models/models/depth_anything_v2/depth_anything_v2_hf.py +77 -0
- inference_models/models/dinov3/__init__.py +0 -0
- inference_models/models/dinov3/dinov3_classification_onnx.py +348 -0
- inference_models/models/dinov3/dinov3_classification_torch.py +323 -0
- inference_models/models/doctr/__init__.py +0 -0
- inference_models/models/doctr/doctr_torch.py +304 -0
- inference_models/models/easy_ocr/__init__.py +0 -0
- inference_models/models/easy_ocr/easy_ocr_torch.py +222 -0
- inference_models/models/florence2/__init__.py +0 -0
- inference_models/models/florence2/florence2_hf.py +897 -0
- inference_models/models/grounding_dino/__init__.py +0 -0
- inference_models/models/grounding_dino/grounding_dino_torch.py +227 -0
- inference_models/models/l2cs/__init__.py +0 -0
- inference_models/models/l2cs/l2cs_onnx.py +216 -0
- inference_models/models/mediapipe_face_detection/__init__.py +0 -0
- inference_models/models/mediapipe_face_detection/face_detection.py +203 -0
- inference_models/models/moondream2/__init__.py +0 -0
- inference_models/models/moondream2/moondream2_hf.py +281 -0
- inference_models/models/owlv2/__init__.py +0 -0
- inference_models/models/owlv2/cache.py +182 -0
- inference_models/models/owlv2/entities.py +112 -0
- inference_models/models/owlv2/owlv2_hf.py +695 -0
- inference_models/models/owlv2/reference_dataset.py +291 -0
- inference_models/models/paligemma/__init__.py +0 -0
- inference_models/models/paligemma/paligemma_hf.py +209 -0
- inference_models/models/perception_encoder/__init__.py +0 -0
- inference_models/models/perception_encoder/perception_encoder_pytorch.py +197 -0
- inference_models/models/perception_encoder/vision_encoder/__init__.py +0 -0
- inference_models/models/perception_encoder/vision_encoder/config.py +160 -0
- inference_models/models/perception_encoder/vision_encoder/pe.py +742 -0
- inference_models/models/perception_encoder/vision_encoder/rope.py +344 -0
- inference_models/models/perception_encoder/vision_encoder/tokenizer.py +342 -0
- inference_models/models/perception_encoder/vision_encoder/transforms.py +33 -0
- inference_models/models/qwen25vl/__init__.py +1 -0
- inference_models/models/qwen25vl/qwen25vl_hf.py +285 -0
- inference_models/models/resnet/__init__.py +0 -0
- inference_models/models/resnet/resnet_classification_onnx.py +330 -0
- inference_models/models/resnet/resnet_classification_torch.py +305 -0
- inference_models/models/resnet/resnet_classification_trt.py +369 -0
- inference_models/models/rfdetr/__init__.py +0 -0
- inference_models/models/rfdetr/backbone_builder.py +101 -0
- inference_models/models/rfdetr/class_remapping.py +41 -0
- inference_models/models/rfdetr/common.py +115 -0
- inference_models/models/rfdetr/default_labels.py +108 -0
- inference_models/models/rfdetr/dinov2_with_windowed_attn.py +1330 -0
- inference_models/models/rfdetr/misc.py +26 -0
- inference_models/models/rfdetr/ms_deform_attn.py +180 -0
- inference_models/models/rfdetr/ms_deform_attn_func.py +60 -0
- inference_models/models/rfdetr/position_encoding.py +166 -0
- inference_models/models/rfdetr/post_processor.py +83 -0
- inference_models/models/rfdetr/projector.py +373 -0
- inference_models/models/rfdetr/rfdetr_backbone_pytorch.py +394 -0
- inference_models/models/rfdetr/rfdetr_base_pytorch.py +807 -0
- inference_models/models/rfdetr/rfdetr_instance_segmentation_onnx.py +206 -0
- inference_models/models/rfdetr/rfdetr_instance_segmentation_pytorch.py +373 -0
- inference_models/models/rfdetr/rfdetr_instance_segmentation_trt.py +227 -0
- inference_models/models/rfdetr/rfdetr_object_detection_onnx.py +244 -0
- inference_models/models/rfdetr/rfdetr_object_detection_pytorch.py +470 -0
- inference_models/models/rfdetr/rfdetr_object_detection_trt.py +270 -0
- inference_models/models/rfdetr/segmentation_head.py +273 -0
- inference_models/models/rfdetr/transformer.py +767 -0
- inference_models/models/roboflow_instant/__init__.py +0 -0
- inference_models/models/roboflow_instant/roboflow_instant_hf.py +141 -0
- inference_models/models/sam/__init__.py +0 -0
- inference_models/models/sam/cache.py +147 -0
- inference_models/models/sam/entities.py +25 -0
- inference_models/models/sam/sam_torch.py +675 -0
- inference_models/models/sam2/__init__.py +0 -0
- inference_models/models/sam2/cache.py +162 -0
- inference_models/models/sam2/entities.py +43 -0
- inference_models/models/sam2/sam2_torch.py +905 -0
- inference_models/models/sam2_rt/__init__.py +0 -0
- inference_models/models/sam2_rt/sam2_pytorch.py +119 -0
- inference_models/models/smolvlm/__init__.py +0 -0
- inference_models/models/smolvlm/smolvlm_hf.py +245 -0
- inference_models/models/trocr/__init__.py +0 -0
- inference_models/models/trocr/trocr_hf.py +53 -0
- inference_models/models/vit/__init__.py +0 -0
- inference_models/models/vit/vit_classification_huggingface.py +319 -0
- inference_models/models/vit/vit_classification_onnx.py +326 -0
- inference_models/models/vit/vit_classification_trt.py +365 -0
- inference_models/models/yolact/__init__.py +1 -0
- inference_models/models/yolact/yolact_instance_segmentation_onnx.py +336 -0
- inference_models/models/yolact/yolact_instance_segmentation_trt.py +361 -0
- inference_models/models/yolo_world/__init__.py +1 -0
- inference_models/models/yolonas/__init__.py +0 -0
- inference_models/models/yolonas/nms.py +44 -0
- inference_models/models/yolonas/yolonas_object_detection_onnx.py +204 -0
- inference_models/models/yolonas/yolonas_object_detection_trt.py +230 -0
- inference_models/models/yolov10/__init__.py +0 -0
- inference_models/models/yolov10/yolov10_object_detection_onnx.py +187 -0
- inference_models/models/yolov10/yolov10_object_detection_trt.py +215 -0
- inference_models/models/yolov11/__init__.py +0 -0
- inference_models/models/yolov11/yolov11_onnx.py +28 -0
- inference_models/models/yolov11/yolov11_torch_script.py +25 -0
- inference_models/models/yolov11/yolov11_trt.py +21 -0
- inference_models/models/yolov12/__init__.py +0 -0
- inference_models/models/yolov12/yolov12_onnx.py +7 -0
- inference_models/models/yolov12/yolov12_torch_script.py +7 -0
- inference_models/models/yolov12/yolov12_trt.py +7 -0
- inference_models/models/yolov5/__init__.py +0 -0
- inference_models/models/yolov5/nms.py +99 -0
- inference_models/models/yolov5/yolov5_instance_segmentation_onnx.py +225 -0
- inference_models/models/yolov5/yolov5_instance_segmentation_trt.py +255 -0
- inference_models/models/yolov5/yolov5_object_detection_onnx.py +192 -0
- inference_models/models/yolov5/yolov5_object_detection_trt.py +218 -0
- inference_models/models/yolov7/__init__.py +0 -0
- inference_models/models/yolov7/yolov7_instance_segmentation_onnx.py +226 -0
- inference_models/models/yolov7/yolov7_instance_segmentation_trt.py +253 -0
- inference_models/models/yolov8/__init__.py +0 -0
- inference_models/models/yolov8/yolov8_classification_onnx.py +181 -0
- inference_models/models/yolov8/yolov8_instance_segmentation_onnx.py +239 -0
- inference_models/models/yolov8/yolov8_instance_segmentation_torch_script.py +201 -0
- inference_models/models/yolov8/yolov8_instance_segmentation_trt.py +268 -0
- inference_models/models/yolov8/yolov8_key_points_detection_onnx.py +263 -0
- inference_models/models/yolov8/yolov8_key_points_detection_torch_script.py +218 -0
- inference_models/models/yolov8/yolov8_key_points_detection_trt.py +287 -0
- inference_models/models/yolov8/yolov8_object_detection_onnx.py +213 -0
- inference_models/models/yolov8/yolov8_object_detection_torch_script.py +166 -0
- inference_models/models/yolov8/yolov8_object_detection_trt.py +231 -0
- inference_models/models/yolov9/__init__.py +0 -0
- inference_models/models/yolov9/yolov9_onnx.py +7 -0
- inference_models/models/yolov9/yolov9_torch_script.py +7 -0
- inference_models/models/yolov9/yolov9_trt.py +7 -0
- inference_models/runtime_introspection/__init__.py +0 -0
- inference_models/runtime_introspection/core.py +410 -0
- inference_models/utils/__init__.py +0 -0
- inference_models/utils/download.py +608 -0
- inference_models/utils/environment.py +28 -0
- inference_models/utils/file_system.py +51 -0
- inference_models/utils/hashing.py +7 -0
- inference_models/utils/imports.py +48 -0
- inference_models/utils/onnx_introspection.py +17 -0
- inference_models/weights_providers/__init__.py +0 -0
- inference_models/weights_providers/core.py +20 -0
- inference_models/weights_providers/entities.py +159 -0
- inference_models/weights_providers/roboflow.py +601 -0
- inference_models-0.18.3.dist-info/METADATA +466 -0
- inference_models-0.18.3.dist-info/RECORD +195 -0
- inference_models-0.18.3.dist-info/WHEEL +5 -0
- inference_models-0.18.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import importlib
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
from typing import Any, Optional
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class LazyClass:
|
|
8
|
+
|
|
9
|
+
def __init__(self, module_name: str, class_name: str):
|
|
10
|
+
self._module_name = module_name
|
|
11
|
+
self._class_name = class_name
|
|
12
|
+
self._symbol: Optional[type] = None
|
|
13
|
+
|
|
14
|
+
def resolve(self) -> type:
|
|
15
|
+
if self._symbol is None:
|
|
16
|
+
module = importlib.import_module(self._module_name)
|
|
17
|
+
self._symbol = getattr(module, self._class_name)
|
|
18
|
+
return self._symbol
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def import_class_from_file(
|
|
22
|
+
file_path: str, class_name: str, alias_name: Optional[str] = None
|
|
23
|
+
) -> type:
|
|
24
|
+
"""
|
|
25
|
+
Emulates what huggingface transformers does to load remote code with trust_remote_code=True,
|
|
26
|
+
but allows us to use the class directly so that we don't have to load untrusted code.
|
|
27
|
+
"""
|
|
28
|
+
file_path = os.path.abspath(file_path)
|
|
29
|
+
module_name = os.path.splitext(os.path.basename(file_path))[0]
|
|
30
|
+
module_dir = os.path.dirname(file_path)
|
|
31
|
+
parent_dir = os.path.dirname(module_dir)
|
|
32
|
+
|
|
33
|
+
sys.path.insert(0, parent_dir)
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
|
37
|
+
module = importlib.util.module_from_spec(spec)
|
|
38
|
+
|
|
39
|
+
# Manually set the __package__ attribute to the parent package
|
|
40
|
+
module.__package__ = os.path.basename(module_dir)
|
|
41
|
+
|
|
42
|
+
spec.loader.exec_module(module)
|
|
43
|
+
cls = getattr(module, class_name)
|
|
44
|
+
if alias_name:
|
|
45
|
+
globals()[alias_name] = cls
|
|
46
|
+
return cls
|
|
47
|
+
finally:
|
|
48
|
+
sys.path.pop(0)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from functools import cache
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from inference_models.configuration import ONNXRUNTIME_EXECUTION_PROVIDERS
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@cache
|
|
8
|
+
def get_selected_onnx_execution_providers() -> List[str]:
|
|
9
|
+
try:
|
|
10
|
+
import onnxruntime
|
|
11
|
+
|
|
12
|
+
available_providers = set(onnxruntime.get_available_providers())
|
|
13
|
+
return [
|
|
14
|
+
ep for ep in ONNXRUNTIME_EXECUTION_PROVIDERS if ep in available_providers
|
|
15
|
+
]
|
|
16
|
+
except ImportError:
|
|
17
|
+
return []
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from inference_models.errors import ModelRetrievalError
|
|
4
|
+
from inference_models.weights_providers.entities import ModelMetadata
|
|
5
|
+
from inference_models.weights_providers.roboflow import get_roboflow_model
|
|
6
|
+
|
|
7
|
+
WEIGHTS_PROVIDERS = {
|
|
8
|
+
"roboflow": get_roboflow_model,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def get_model_from_provider(
|
|
13
|
+
model_id: str, provider: str, api_key: Optional[str] = None
|
|
14
|
+
) -> ModelMetadata:
|
|
15
|
+
if provider not in WEIGHTS_PROVIDERS:
|
|
16
|
+
raise ModelRetrievalError(
|
|
17
|
+
message=f"Requested model to be retrieved using '{provider}' provider which is not implemented.",
|
|
18
|
+
help_url="https://todo",
|
|
19
|
+
)
|
|
20
|
+
return WEIGHTS_PROVIDERS[provider](model_id=model_id, api_key=api_key)
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from typing import List, Optional, Set, Tuple, Union
|
|
4
|
+
|
|
5
|
+
from packaging.version import Version
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
from inference_models.models.auto_loaders.entities import BackendType
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Quantization(str, Enum):
|
|
12
|
+
FP32 = "fp32"
|
|
13
|
+
FP16 = "fp16"
|
|
14
|
+
BF16 = "bf16"
|
|
15
|
+
INT8 = "int8"
|
|
16
|
+
UNKNOWN = "unknown"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass(frozen=True)
|
|
20
|
+
class FileDownloadSpecs:
|
|
21
|
+
download_url: str
|
|
22
|
+
file_handle: str
|
|
23
|
+
md5_hash: Optional[str] = field(default=None)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True)
|
|
27
|
+
class ServerEnvironmentRequirements:
|
|
28
|
+
cuda_device_cc: Version
|
|
29
|
+
cuda_device_name: str
|
|
30
|
+
driver_version: Optional[Version]
|
|
31
|
+
cuda_version: Optional[Version]
|
|
32
|
+
trt_version: Optional[Version]
|
|
33
|
+
os_version: Optional[str]
|
|
34
|
+
|
|
35
|
+
def __str__(self) -> str:
|
|
36
|
+
return (
|
|
37
|
+
f"Server(device={self.cuda_device_name}, cc={self.cuda_device_cc}, "
|
|
38
|
+
f"os={self.os_version}, driver={self.driver_version}, cu={self.cuda_version}, "
|
|
39
|
+
f"trt={self.trt_version})"
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@dataclass(frozen=True)
|
|
44
|
+
class JetsonEnvironmentRequirements:
|
|
45
|
+
cuda_device_cc: Version
|
|
46
|
+
cuda_device_name: str
|
|
47
|
+
l4t_version: Version
|
|
48
|
+
jetson_product_name: Optional[str]
|
|
49
|
+
cuda_version: Optional[Version]
|
|
50
|
+
trt_version: Optional[Version]
|
|
51
|
+
driver_version: Optional[Version]
|
|
52
|
+
|
|
53
|
+
def __str__(self) -> str:
|
|
54
|
+
return (
|
|
55
|
+
f"Jetson(device={self.cuda_device_name}, cc={self.cuda_device_cc}, "
|
|
56
|
+
f"l4t={self.l4t_version}, product={self.jetson_product_name}, cu={self.cuda_version}, "
|
|
57
|
+
f"trt={self.trt_version}, driver={self.driver_version})"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@dataclass(frozen=True)
|
|
62
|
+
class TRTPackageDetails:
|
|
63
|
+
min_dynamic_batch_size: Optional[int] = field(default=None)
|
|
64
|
+
opt_dynamic_batch_size: Optional[int] = field(default=None)
|
|
65
|
+
max_dynamic_batch_size: Optional[int] = field(default=None)
|
|
66
|
+
same_cc_compatible: bool = field(default=False)
|
|
67
|
+
trt_forward_compatible: bool = field(default=False)
|
|
68
|
+
trt_lean_runtime_excluded: bool = field(default=False)
|
|
69
|
+
|
|
70
|
+
def __str__(self):
|
|
71
|
+
return (
|
|
72
|
+
f"TRTPackageDetails("
|
|
73
|
+
f"dynamic_batch=({self.min_dynamic_batch_size}/{self.opt_dynamic_batch_size}/{self.max_dynamic_batch_size}), "
|
|
74
|
+
f"same_cc_compatible={self.same_cc_compatible}, "
|
|
75
|
+
f"trt_forward_compatible={self.trt_forward_compatible}, "
|
|
76
|
+
f"trt_lean_runtime_excluded={self.trt_lean_runtime_excluded})"
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@dataclass(frozen=True)
|
|
81
|
+
class ONNXPackageDetails:
|
|
82
|
+
opset: int
|
|
83
|
+
incompatible_providers: Optional[List[str]] = field(default=None)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@dataclass(frozen=True)
|
|
87
|
+
class TorchScriptPackageDetails:
|
|
88
|
+
supported_device_types: Set[str]
|
|
89
|
+
torch_version: Version
|
|
90
|
+
torch_vision_version: Optional[Version] = field(default=None)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@dataclass(frozen=True)
|
|
94
|
+
class ModelPackageMetadata:
|
|
95
|
+
package_id: str
|
|
96
|
+
backend: BackendType
|
|
97
|
+
package_artefacts: List[FileDownloadSpecs]
|
|
98
|
+
quantization: Optional[Quantization] = field(default=None)
|
|
99
|
+
dynamic_batch_size_supported: Optional[bool] = field(default=None)
|
|
100
|
+
static_batch_size: Optional[int] = field(default=None)
|
|
101
|
+
trt_package_details: Optional[TRTPackageDetails] = field(default=None)
|
|
102
|
+
onnx_package_details: Optional[ONNXPackageDetails] = field(default=None)
|
|
103
|
+
torch_script_package_details: Optional[TorchScriptPackageDetails] = field(
|
|
104
|
+
default=None
|
|
105
|
+
)
|
|
106
|
+
trusted_source: bool = field(default=False)
|
|
107
|
+
environment_requirements: Optional[
|
|
108
|
+
Union[ServerEnvironmentRequirements, JetsonEnvironmentRequirements]
|
|
109
|
+
] = field(default=None)
|
|
110
|
+
model_features: Optional[dict] = field(default=None)
|
|
111
|
+
|
|
112
|
+
def get_summary(self) -> str:
|
|
113
|
+
return (
|
|
114
|
+
f"ModelPackageMetadata(package_id={self.package_id}, backend={self.backend.value}, quantization={self.quantization} "
|
|
115
|
+
f"dynamic_batch_size_supported={self.dynamic_batch_size_supported}, "
|
|
116
|
+
f"static_batch_size={self.static_batch_size}, trt_package_details={self.trt_package_details}, "
|
|
117
|
+
f"environment_requirements={self.environment_requirements}, model_features={self.model_features})"
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
def get_dynamic_batch_boundaries(self) -> Tuple[int, int]:
|
|
121
|
+
if not self.specifies_dynamic_batch_boundaries():
|
|
122
|
+
raise RuntimeError(
|
|
123
|
+
"Requested dynamic batch boundaries from model package that does not support dynamic batches."
|
|
124
|
+
)
|
|
125
|
+
values = []
|
|
126
|
+
if self.trt_package_details.min_dynamic_batch_size is not None:
|
|
127
|
+
values.append(self.trt_package_details.min_dynamic_batch_size)
|
|
128
|
+
if self.trt_package_details.opt_dynamic_batch_size is not None:
|
|
129
|
+
values.append(self.trt_package_details.opt_dynamic_batch_size)
|
|
130
|
+
if self.trt_package_details.max_dynamic_batch_size is not None:
|
|
131
|
+
values.append(self.trt_package_details.max_dynamic_batch_size)
|
|
132
|
+
return min(values), max(values)
|
|
133
|
+
|
|
134
|
+
def specifies_dynamic_batch_boundaries(self) -> bool:
|
|
135
|
+
if not self.dynamic_batch_size_supported:
|
|
136
|
+
return False
|
|
137
|
+
if self.trt_package_details is None:
|
|
138
|
+
return False
|
|
139
|
+
return (
|
|
140
|
+
self.trt_package_details.min_dynamic_batch_size is not None
|
|
141
|
+
or self.trt_package_details.opt_dynamic_batch_size is not None
|
|
142
|
+
or self.trt_package_details.max_dynamic_batch_size is not None
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class ModelDependency(BaseModel):
|
|
147
|
+
name: str
|
|
148
|
+
model_id: str
|
|
149
|
+
model_package_id: Optional[str] = Field(default=None)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
@dataclass(frozen=True)
|
|
153
|
+
class ModelMetadata:
|
|
154
|
+
model_id: str
|
|
155
|
+
model_architecture: str
|
|
156
|
+
model_packages: List[ModelPackageMetadata]
|
|
157
|
+
task_type: Optional[str] = field(default=None)
|
|
158
|
+
model_variant: Optional[str] = field(default=None)
|
|
159
|
+
model_dependencies: Optional[List[ModelDependency]] = field(default=None)
|