我训练了一个模型并想预测新图像的分数。
现在我执行以下函数,但它返回一个错误:
google.api_core.exceptions.PermissionDenied: 403 Permission 'automl.models.predict' denied on resource 'projects/project_id/locations/us-central1/models/model_id' (or it may not exist).
我不确定是不是因为位置不正确,即 us-central1?要检查的 gcloud 命令是什么?
如何解决这个问题呢?
非常感谢你。
def get_prediction(content, project_id, model_id):
prediction_client = automl_v1beta1.PredictionServiceClient()
name = 'projects/{}/locations/us-central1/models/{}'.format(project_id, model_id)
payload = {'image': {'image_bytes': content }}
params = {}
request = prediction_client.predict(name, payload, params)
return request # waits till request is returned