You can now run predictions on images using your custom vision model.
python predict.py YOUR_LOCAL_IMAGE_FILE aiyvision-xxx ICNxxxxxxxxxxxxx
When run the command above before, you have to create a JSON file which have enough privileges to invoke the API for inferencing.
https://console.cloud.google.com/iam-admin/serviceaccounts
Then Create another environment variable that points to the downloaded JSON key.
export GOOGLE_APPLICATION_CREDENTIALS=key-file //Linux
set GOOGLE_APPLICATION_CREDENTIALS=key-file //Windows
If see the error as following, you will need to do the 2 steps.google.auth.exceptions.DefaultCredentialsError: The file D:\google_images_download\key.json. does not have a valid type. Type is None, expected one of ('authorized_user', 'service_account').
Reference site
https://cloud.google.com/automl/
https://cloud.google.com/iam/docs/creating-managing-service-accounts
https://thenewstack.io/get-started-with-google-cloud-automl-vision-for-image-classification/
沒有留言:
張貼留言