Integrate with Machine Learning APIs: Challenge Lab Tutorial

Ajil T U
2 min readSep 20, 2020


Detailed walk-through of the Integrate with Machine Learning APIs Skill Badge on Google Cloud Platform.

This medium article focuses on the detailed walk through of the steps I took to solve the challenge lab Integrate with Machine Learning APIs of the in Google Cloud Skill Badge on the Google Cloud Platform.

This lab is only recommended for students who have completed the quest Machine Learning APIs on Qwiklabs.

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:

Then Click Continue:

Create a new service account that provides credentials for the script.

export SANAME=challenge
gcloud iam service-accounts create $SANAME

Once you have created the account, bind the BigQuery Admin and Cloud Storage Admin roles to the Service Account to provide the IAM permissions required to process files from Cloud Storage and insert the result data into a BigQuery table.

1) gcloud projects add-iam-policy-binding $DEVSHELL_PROJECT_ID --member=serviceAccount:$SANAME@$ --role=roles/bigquery.admin2) gcloud projects add-iam-policy-binding $DEVSHELL_PROJECT_ID --member=serviceAccount:$SANAME@$ --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/ .

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

Open gcloud shell editor and replace the file with the following code below

Run the command :


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

  1. Click Navigation menu > BigQuery.

The Welcome to BigQuery in the Cloud Console message box opens.

Click Done.

Copy and paste the following query into the Query editor, then Run query

SELECT locale, COUNT(locale) as OCCURENCE FROM `<QWIKLABS_PROJECT_ID>.image_classification_dataset.image_text_detail` GROUP BY locale

Replace <QWIKLABS_PROJECT_ID>with your project ID.