models
最后更新
hubai_sdk.services.models创建和管理顶级模型资源。模型包含共享元数据,例如其显示名称、支持的任务、许可证和可见性。实际文件属于版本化变体下的模型实例;请参阅 hubai_sdk.services.variants 和 hubai_sdk.services.instances。标识符::接受identifier的函数支持 UUID、原始模型 slug 或<team>/<model>资源路径。这使得 slug 适用于配置文件,而 UUID 对于编程流程仍然有用。可见性::在创建过程中,is_public=True使模型公开,False使其私有,None选择团队可见性。对于列表操作,None表示没有可见性过滤器。对于更新,None使现有可见性保持不变。
示例
Python
1models = client.models.list_models(
2 tasks=["OBJECT_DETECTION"],
3 is_public=True,
4 limit=10,
5)
6model = client.models.get_model(models[0].id)函数
create_model
Python
1def create_model(name: str, *, license_type: License = 'undefined', is_public: bool | None = False, description: str | None = None, description_short: str = '<empty>', architecture_id: UUID | str | None = None, tasks: list[Task] | None = None, links: list[str] | None = None, is_yolo: bool = False) -> ModelResponse:name(str): 人类可读的模型名称。HubAI 从中派生 slug。license_type(License): 附加到模型元数据的许可证。is_public(bool | None):True表示公开,False表示私有,None表示团队可见性。description(str | None): 完整的模型描述。description_short(str): 模型列表中显示的简短摘要。architecture_id(UUID | str | None): 相关的架构 UUID(如果已知)。tasks(list[Task] | None): 模型支持的任务。links(list[str] | None): 源代码、论文或其他相关资源的 URL。is_yolo(bool): 模型是否使用受支持的 YOLO 输出契约。
ModelResponse: 创建的模型资源。
ResourceConflictError: 如果具有派生 slug 的模型已存在。HubApiError: 如果 HubAI 因其他原因拒绝请求。
create_model_cli
Python
1def create_model_cli(name: str, *, license_type: License = 'undefined', is_public: bool | None = False, description: str | None = None, description_short: str = '<empty>', architecture_id: UUID | str | None = None, tasks: list[Task] | None = None, links: list[str] | None = None, is_yolo: bool = False):delete_model
Python
1def delete_model(identifier: UUID | str):identifier(UUID | str): 模型 UUID、原始 slug 或<team>/<model>路径。
ResourceNotFoundError: 如果无法解析identifier。HubApiError: 如果 HubAI 拒绝删除。
delete_model_cli
Python
1def delete_model_cli(identifier: UUID | str):get_model
Python
1def get_model(identifier: UUID | str) -> ModelResponse:identifier(UUID | str): 模型 UUID、原始 slug 或<team>/<model>路径。
ModelResponse: 解析的模型资源。
get_model_info_cli
Python
1def get_model_info_cli(identifier: UUID | str):list_models
Python
1def list_models(tasks: list[Task] | None = None, license_type: License | None = None, is_public: bool | None = None, project_id: str | None = None, luxonis_only: bool = False, limit: int = 50, sort: str = 'updated', order: Order = 'desc') -> list[ModelResponse]:tasks(list[Task] | None): 按支持的任务筛选模型。license_type(License | None): 保留具有此许可证的模型。is_public(bool | None): 按公开状态筛选。保留为None以包含 API 密钥可用的所有可见性。project_id(str | None): 保留属于此项目的模型。luxonis_only(bool): 是否仅返回 Luxonis 维护的模型。limit(int): 要返回的最大模型数量。sort(str): ModelResponse 用于排序的字段,例如"name"、"id"或"updated"。order(Order): 按升序或降序排序。
list[ModelResponse]: 匹配的模型资源列表。
list_models_cli
Python
1def list_models_cli(tasks: list[Task] | None = None, license_type: License | None = None, is_public: bool | None = None, project_id: str | None = None, luxonis_only: bool = False, limit: int = 50, sort: str = 'updated', order: Order = 'desc', field: Annotated[list[str] | None, Parameter(name=['--field', '-f'])] = None):update_model
Python
1def update_model(identifier: UUID | str, *, license_type: License | None = None, is_public: bool | None = None, description: str | None = None, description_short: str | None = None, architecture_id: UUID | str | None = None, tasks: list[Task] | None = None, links: list[str] | None = None, is_yolo: bool | None = None) -> ModelResponse:None 的参数才会发送到 HubAI。这意味着无法使用此帮助程序清除可选文本字段。参数identifier(UUID | str): 模型 UUID、原始 slug 或<team>/<model>路径。license_type(License | None): 替换许可证。is_public(bool | None): 替换公开/私有状态。description(str | None): 替换完整描述。description_short(str | None): 替换简短描述。architecture_id(UUID | str | None): 替换架构 UUID。tasks(list[Task] | None): 替换任务列表。links(list[str] | None): 替换相关资源链接。is_yolo(bool | None): 替换 YOLO 标志。
ModelResponse: 更新的模型资源。
update_model_cli
Python
1def update_model_cli(identifier: UUID | str, *, license_type: License | None = None, is_public: bool | None = None, description: str | None = None, description_short: str | None = None, architecture_id: UUID | str | None = None, tasks: list[Task] | None = None, links: list[str] | None = None, is_yolo: bool | None = None):