GCP顶点 - 获取部署模型ID的直接方法

发布于 2025-01-28 01:26:06 字数 630 浏览 4 评论 0原文

有没有一种方法可以直接从gcloud AI模型上传命令中获取模型ID?

使用JSON输出或值输出,需要通过分裂和提取来操纵。如果有一种方法可以直接获取模型ID而不操纵,请告知。

output = !gcloud ai models upload \
  --region=$REGION \
  --display-name=$JOB_NAME \
  --container-image-uri=us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-8:latest \
  --artifact-uri=$GCS_URL_FOR_SAVED_MODEL \
  --format="value(model)"

output
-----
['Using endpoint [https://us-central1-aiplatform.googleapis.com/]',
 'projects/xxxxxxxx/locations/us-central1/models/1961937762277916672',
 'Waiting for operation [8951184153827606528]...',
 '...................................done.']

Is there a way to directly acquire the model ID from the gcloud ai models upload command?

Either using JSON output or value output, need to manipulate by splitting and extracting. If there is a way to directly get the model ID without manipulation, please advise.

output = !gcloud ai models upload \
  --region=$REGION \
  --display-name=$JOB_NAME \
  --container-image-uri=us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-8:latest \
  --artifact-uri=$GCS_URL_FOR_SAVED_MODEL \
  --format="value(model)"

output
-----
['Using endpoint [https://us-central1-aiplatform.googleapis.com/]',
 'projects/xxxxxxxx/locations/us-central1/models/1961937762277916672',
 'Waiting for operation [8951184153827606528]...',
 '...................................done.']

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凡间太子 2025-02-04 01:26:07

gcloud AI模型的输出描述$ model_name包括DiventionedModelid。

因此,如果您有model_name,请仅提取一个部署的modelid:

MODEL_ID=$(gcloud ai models describe $MODEL_NAME --project=$PROJECT --region=$REGION  --flatten="deployedModels[0]" --format="csv[no-heading](deployedModelId)")

如果您有许多已部署的版本并且需要选择一个,则需要细化。

The output of gcloud ai models describe $MODEL_NAME includes the deployedModelId.

So if you have the MODEL_NAME, to extract just a deployedModelId:

MODEL_ID=$(gcloud ai models describe $MODEL_NAME --project=$PROJECT --region=$REGION  --flatten="deployedModels[0]" --format="csv[no-heading](deployedModelId)")

It will need refinement if you have many deployed versions and need to select one.

罗罗贝儿 2025-02-04 01:26:06

由于您已经有$ region$ job_name的值用最小操作的ID。

请参阅下面的命令:

export REGION=us-central1
export JOB_NAME=test_training
export PROJECT_ID=your-project-name

gcloud ai models list --region=$REGION --filter="DISPLAY_NAME: $JOB_NAME" | grep "MODEL_ID" | cut -f2 -d: | sed 's/\s//'

输出:

”“在此处输入图像描述”


如果要形成由gcloud AI返回的实际字符串,则可以将变量置于变量。

MODEL_ID=$(gcloud ai models list --region=$REGION --filter="DISPLAY_NAME: $JOB_NAME" | grep "MODEL_ID" | cut -f2 -d: | sed 's/\s//')

echo projects/${PROJECT_ID}/locations/${REGION}/models/${MODEL_ID}

输出:

在此处输入图像描述“

Since you already have values for $REGION and $JOB_NAME, you can use execute gcloud ai models list after you uploaded the model to get the model id with minimal manipulation.

See command below:

export REGION=us-central1
export JOB_NAME=test_training
export PROJECT_ID=your-project-name

gcloud ai models list --region=$REGION --filter="DISPLAY_NAME: $JOB_NAME" | grep "MODEL_ID" | cut -f2 -d: | sed 's/\s//'

Output:

enter image description here


If you want to form the actual string returned by gcloud ai models upload you can just concatenate your variables.

MODEL_ID=$(gcloud ai models list --region=$REGION --filter="DISPLAY_NAME: $JOB_NAME" | grep "MODEL_ID" | cut -f2 -d: | sed 's/\s//')

echo projects/${PROJECT_ID}/locations/${REGION}/models/${MODEL_ID}

Output:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文