Manage concrete model artifacts and their files.
An instance belongs to one model variant and represents a specific artifact format, for example ONNX input or an RVC4 export. The service supports listing and creating instances, uploading source files, reading NN Archive configuration, and downloading output files.
- Download behavior:
download_instancewrites all files associated with an instance. If output_dir is omitted it creates a directory named after the instance slug in the current working directory. Existing destination files are reused unless force=True.
Example
from hubai_sdk.utils.types import ModelType instance = client.instances.create_instance( "network", variant_id=variant.id, model_type=ModelType.ONNX, input_shape=[1, 3, 640, 640], ) client.instances.upload_file("network.onnx", instance.id)
Note
Most users do not need to create and upload instances manually. The
functions in hubai_sdk.services.convert coordinate these steps for a
complete hosted conversion.
| Function | create |
Create a model artifact beneath a variant. |
| Function | create |
Creates a new model instance. |
| Function | delete |
Delete a model instance from HubAI. |
| Function | delete |
Deletes a model instance. |
| Function | download |
Download every file attached to a model instance. |
| Function | download |
Downloads files from a model instance. |
| Function | get |
Return the NN Archive configuration of a model instance. |
| Function | get |
Returns the configuration of a model instance. |
| Function | get |
Return metadata for files attached to a model instance. |
| Function | get |
Returns the files of a model instance. |
| Function | get |
Get one model instance by UUID or slug. |
| Function | get |
Returns information about a model instance. |
| Function | list |
List model instances visible to the authenticated team. |
| Function | list |
List the model instances in the HubAI. |
| Function | upload |
Upload a file directly to storage for a model instance. |
| Function | upload |
Uploads a file to a model instance using async upload. |
| Function | upload |
Upload a custom calibration archive for an export job. |
| Constant | INSTANCE |
Undocumented |
| Constant | INSTANCE |
Undocumented |
| Constant | INSTANCE |
Undocumented |
| Variable | app |
Undocumented |
| Function | _dump |
Convert SDK response objects into JSON-serializable CLI data. |
| Function | _get |
Fetch a subresource for a model instance after resolving its ID. |
| Function | _instance |
Undocumented |
| Function | _print |
Undocumented |
| Function | _print |
Undocumented |
str, *, variant_id: UUID | str, model_type: ModelType, parent_id: UUID | str | None = None, quantization_mode: QuantizationMode | None = None, quantization_data: QuantizationData | None = None, tags: list[ str] | None = None, input_shape: list[ int] | None = None, is_deployable: bool | None = None, yolo_version: YoloVersion | None = None) -> ModelInstanceResponse:
¶
Create a model artifact beneath a variant.
| Parameters | |
name:str | Human-readable instance name. |
variantUUID | str | UUID of the model variant that owns this instance. |
modelModelType | Source or exported artifact type. |
parentUUID | str | None | Source instance UUID when this instance is an export. |
quantizationQuantizationMode | None | Quantization mode for the model. Must be one of INT8_STANDARD, INT8_ACCURACY_FOCUSED, INT8_INT16_MIXED, INT8_INT16_MIXED_ACCURACY_FOCUSED, or FP16_STANDARD. INT8_STANDARD is standard INT8 quantization with calibration for optimal performance and model size. INT8_ACCURACY_FOCUSED is INT8 quantization with calibration that may improve accuracy without reducing performance or increasing model size, depending on the model. INT8_INT16_MIXED uses 8-bit weights and 16-bit activations across all layers for improved numeric stability and accuracy at the cost of performance and model size. INT8_INT16_MIXED_ACCURACY_FOCUSED is a mixed INT8 and INT16 calibration-based mode that prioritizes accuracy over throughput. FP16_STANDARD is FP16 quantization without calibration for models that require higher accuracy and numeric stability at the cost of performance and model size. |
quantizationQuantizationData | None | Quantization data for the model. This can be one of the predefined domains DRIVING, FOOD, GENERAL, INDOORS, RANDOM, WAREHOUSE, CLIP, CUSTOM, or UNKNOWN, or a dataset ID. For conversion helpers, pass the local .zip path itself instead of CUSTOM; the SDK normalizes that input before instance creation. |
tags:list[ | Tags for the model instance. |
inputlist[ | Input shape for the model instance. |
isbool | None | Whether the model instance is deployable. |
yoloYoloVersion | None | YOLO version for the model instance if it is a YOLO model. |
| Returns | |
ModelInstanceResponse | The created model instance resource. |
str, *, variant_id: UUID | str, model_type: ModelType, parent_id: UUID | str | None = None, quantization_mode: QuantizationMode | None = None, quantization_data: QuantizationData | None = None, tags: list[ str] | None = None, input_shape: list[ int] | None = None, is_deployable: bool | None = None, yolo_version: YoloVersion | None = None):
¶
Creates a new model instance.
UUID | str):
¶
Delete a model instance from HubAI.
| Parameters | |
identifier:UUID | str | The model instance ID or slug. |
UUID | str, output_dir: str | None = None, force: bool = False) -> Path:
¶
Download every file attached to a model instance.
| Parameters | |
identifier:UUID | str | The model instance ID or slug. |
outputstr | None | Directory path to save the downloaded files. If not specified, the downloader creates a directory named after the model instance slug under the current working directory. |
force:bool | Whether to force download the files even if they already exist. |
| Returns | |
Path | Path to the downloaded file. When the instance has multiple files, this is the last file processed. |
| Raises | |
ResourceNotFoundError | If identifier cannot be resolved. |
HubApiError | If the instance has no files or a download fails. |
UUID | str, output_dir: str | None = None, force: bool = False):
¶
Downloads files from a model instance.
UUID | str) -> ArchiveConfigurationResponse:
¶
Return the NN Archive configuration of a model instance.
| Parameters | |
identifier:UUID | str | The model instance ID or slug. |
| Returns | |
ArchiveConfigurationResponse | The NN archive configuration for the model instance. |
UUID | str) -> list[ ModelInstanceFileResponse]:
¶
Return metadata for files attached to a model instance.
| Parameters | |
identifier:UUID | str | The model instance ID or slug. |
| Returns | |
list[ | File metadata for the model instance. |
UUID | str) -> ModelInstanceResponse:
¶
Get one model instance by UUID or slug.
| Parameters | |
identifier:UUID | str | The model instance ID or slug. |
| Returns | |
ModelInstanceResponse | The resolved model instance resource. |
list[ ModelType] | None = None, search: str | None = None, model_id: UUID | str | None = None, variant_id: UUID | str | None = None, model_type: ModelType | None = None, parent_id: UUID | str | None = None, model_class: ModelClass | None = None, name: str | None = None, hash: str | None = None, status: Status | None = None, is_public: bool | None = None, compression_level: Literal[ 0, 1, 2, 3, 4, 5] | None = None, optimization_level: Literal[ -100, 0, 1, 2, 3, 4] | None = None, include_model_name: bool = False, limit: int = 50, sort: str = 'updated', order: Order = 'desc') -> list[ ModelInstanceResponse]:
¶
List model instances visible to the authenticated team.
| Parameters | |
platforms:list[ | Filter the listed model instances by platform. |
search:str | None | Search the listed model instances by a free-text query. |
modelUUID | str | None | Filter the listed model instances by model ID. |
variantUUID | str | None | Filter the listed model instances by variant ID. |
modelModelType | None | Filter the listed model instances by model type. |
parentUUID | str | None | Filter the listed model instances by parent ID. |
modelModelClass | None | Filter the listed model instances by model class. |
name:str | None | Filter the listed model instances by name. |
hash:str | None | Filter the listed model instances by hash. |
status:Status | None | Filter the listed model instances by status. |
isbool | None | Filter the listed model instances by visibility. |
compressionLiteral[ | Filter the listed model instances by compression level. Only relevant for Hailo models. |
optimizationLiteral[ | Filter the listed model instances by optimization level. Only relevant for Hailo models. |
includebool | If True, include the model name and model
variant name in the response. Otherwise,
ModelInstanceResponse.model_name and
ModelInstanceResponse.model_variant_name are None. Enabling
this performs two additional API requests per result. |
limit:int | Maximum number of model instances to return. |
sort:str | Field to sort the model instances by. It should be a field
name from ModelInstanceResponse, such as "name", "id",
or "updated". |
order:Order | Sort order. Must be "asc" or "desc". |
| Returns | |
list[ | A list of matching model instance resources. |
list[ ModelType] | None = None, search: str | None = None, model_id: UUID | str | None = None, variant_id: UUID | str | None = None, model_type: ModelType | None = None, parent_id: UUID | str | None = None, model_class: ModelClass | None = None, name: str | None = None, hash: str | None = None, status: Status | None = None, is_public: bool | None = None, compression_level: Literal[ 0, 1, 2, 3, 4, 5] | None = None, optimization_level: Literal[ -100, 0, 1, 2, 3, 4] | None = None, include_model_name: bool = False, limit: int = 50, sort: str = 'updated', order: Order = 'desc', field: Annotated[ list[ str] | None, Parameter( name=[ (--field), (-f)])] = None):
¶
List the model instances in the HubAI.
str, identifier: UUID | str):
¶
Upload a file directly to storage for a model instance.
This function initiates an async upload by first obtaining a signed upload policy from the server, then uploading the file directly to cloud storage.
| Parameters | |
filestr | Path to the file to upload. |
identifier:UUID | str | The model instance ID or slug. |
| Raises | |
FileNotFoundError | If file_path does not exist. |
ResourceNotFoundError | If identifier cannot be resolved. |
HubApiError | If the signed upload or its asynchronous job fails. |
Upload a custom calibration archive for an export job.
| Parameters | |
filestr | Path to a local ZIP archive containing calibration inputs. |
jobUUID | str | Export job UUID returned by HubAI. |
| Raises | |
FileNotFoundError | If file_path does not exist. |
InputError | If the file does not have a .zip extension. |
HubApiError | If HubAI cannot issue or complete the upload. |
Undocumented
| Value |
|
Undocumented
| Value |
|
UUID | str, subpath: str) -> dict[ str, object] | list[ dict[ str, object]]:
¶
Fetch a subresource for a model instance after resolving its ID.
list[ ModelInstanceResponse], include_model_name: bool, field: list[ str] | None = None):
¶
Undocumented