I trained a model and would like to predict the score of a new image.
Now I execute the following function but it returns an error:
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).
I am not sure if it is due to incorrect location, i.e. us-central1? What is the gcloud command to check?
How to solve this problem?
Thank you very much.
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