Help us learn about your current experience with the documentation. Take the survey.

模型注册表 API

  • 版本:Free, Premium, Ultimate
  • 产品:GitLab.com, GitLab Self-Managed, GitLab Dedicated

使用此 API 来操作机器学习模型注册表。更多信息,请参阅模型注册表

下载机器学习模型包

此接口会返回文件。

GET /projects/:id/packages/ml_models/:model_version_id/files/(*path/):file_name

对于版本(Versions),:model_version_id 在模型版本的 URL 中指定。 在以下示例中,模型版本为 5/namespace/project/-/ml/models/1/versions/5

对于运行(Runs),ID 必须以 candidate: 开头。在以下示例中,:model_version_idcandidate:5/namespace/project/-/ml/candidates/5

参数:

属性 类型 必需 描述
id integer 或 string 项目的 ID 或 URL 编码的项目路径
model_version_id integer 或 string 文件的模型版本 ID
path string 文件目录路径
filename string 文件名
curl --header "Authorization: Bearer <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/:id/packages/ml_models/:model_version_id/files/(*path/):filename"

响应中包含文件内容。

例如,以下命令会返回项目 ID 为 1、模型版本 ID 为 2 的文件 foo.txt

curl --header "Authorization: Bearer <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/packages/ml_models/2/files/foo.txt"