gpt4 book ai didi

authentication - 提供授权 header 以使用 google ml-engine 的方法

转载 作者:IT王子 更新时间:2023-10-29 02:07:06 26 4
gpt4 key购买 nike

我目前参与了一个使用 GCP Ml 引擎的项目。它已经设置好并准备就绪,所以我的任务是使用它的预测命令来利用 API。整个项目存在于 VM 实例中,所以我想知道,它是否有助于以更简洁的方式获取访问 token ?我的意思是,SDK 或类似的东西,因为我没有发现任何有用的东西。如果没有,我在这里有什么选择?智威汤逊?

最佳答案

您可能会发现这很有用。 https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/ml_engine/online_prediction/predict.py

尤其是这些行:

# Create the ML Engine service object.
# To authenticate set the environment variable
# GOOGLE_APPLICATION_CREDENTIALS=<path_to_service_account_file>
service = googleapiclient.discovery.build('ml', 'v1')
name = 'projects/{}/models/{}'.format(project, model)

if version is not None:
name += '/versions/{}'.format(version)

response = service.projects().predict(
name=name,
body={'instances': instances}
).execute()

您可以从项目 IAM 页面创建服务帐户文件并将 token 下载到 VM。

关于authentication - 提供授权 header 以使用 google ml-engine 的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55451308/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com