Spaces:
Runtime error
Runtime error
File size: 2,305 Bytes
2eafbc4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
from typing import List, Optional, Union
from pydantic import BaseModel, ConfigDict, Field
from inference.core.managers.entities import ModelDescription
class ServerVersionInfo(BaseModel):
"""Server version information.
Attributes:
name (str): Server name.
version (str): Server version.
uuid (str): Server UUID.
"""
name: str = Field(examples=["Roboflow Inference Server"])
version: str = Field(examples=["0.0.1"])
uuid: str = Field(examples=["9c18c6f4-2266-41fb-8a0f-c12ae28f6fbe"])
class ModelDescriptionEntity(BaseModel):
model_config = ConfigDict(protected_namespaces=())
model_id: str = Field(
description="Identifier of the model", examples=["some-project/3"]
)
task_type: str = Field(
description="Type of the task that the model performs",
examples=["classification"],
)
batch_size: Optional[Union[int, str]] = Field(
None,
description="Batch size accepted by the model (if registered).",
)
input_height: Optional[int] = Field(
None,
description="Image input height accepted by the model (if registered).",
)
input_width: Optional[int] = Field(
None,
description="Image input width accepted by the model (if registered).",
)
@classmethod
def from_model_description(
cls, model_description: ModelDescription
) -> "ModelDescriptionEntity":
return cls(
model_id=model_description.model_id,
task_type=model_description.task_type,
batch_size=model_description.batch_size,
input_height=model_description.input_height,
input_width=model_description.input_width,
)
class ModelsDescriptions(BaseModel):
models: List[ModelDescriptionEntity] = Field(
description="List of models that are loaded by model manager.",
)
@classmethod
def from_models_descriptions(
cls, models_descriptions: List[ModelDescription]
) -> "ModelsDescriptions":
return cls(
models=[
ModelDescriptionEntity.from_model_description(
model_description=model_description
)
for model_description in models_descriptions
]
)
|