Integrate with Machine Learning APIs: Challenge Lab Tutorial

Task 1: Configure a service account to access the Machine Learning APIs, BigQuery, and Cloud Storage

Open a Cloud Shell session by clicking on the icon in the top right corner of the Cloud Console:

export SANAME=challenge
gcloud iam service-accounts create $SANAME
1) gcloud projects add-iam-policy-binding $DEVSHELL_PROJECT_ID --member=serviceAccount:$SANAME@$DEVSHELL_PROJECT_ID.iam.gserviceaccount.com --role=roles/bigquery.admin2) gcloud projects add-iam-policy-binding $DEVSHELL_PROJECT_ID --member=serviceAccount:$SANAME@$DEVSHELL_PROJECT_ID.iam.gserviceaccount.com --role=roles/storage.admin

Task 2: Create and download a credential file for your Service Account

When you have configured the service account permissions, download the JSON format IAM credentials file for the service account. Don’t forget to configure the environment variable that supplies the name of the credential file for the Python script.

1) gcloud iam service-accounts keys create sa-key.json --iam-account $SANAME@$DEVSHELL_PROJECT_ID.iam.gserviceaccount.com2) export GOOGLE_APPLICATION_CREDENTIALS=${PWD}/sa-key.json3) gsutil cp gs://$DEVSHELL_PROJECT_ID/analyze-images.py .

Task 3 & 4: Modify the Python script to extract text from image files

Open gcloud shell editor and replace the file analyze-images.py with the following code below

python3 analyze-images.py <PROJECT_NAME> <BUCKET_NAME>

Task 5: Identify the most common non-English language used in the signs in the data set

  1. Click Navigation menu > BigQuery.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store