Hands-on Configuration of GCP Vision API

Introduction

Few months ago, we built a simple AWS Rekognition Application. In that time, we used Cloud9 service in AWS, and it will be treated as an instance. But this time, we can do it with CloudShell on GCP. In this article, we can even run few commands to complete all the things. Of course, I will still briefly introduce what we have done.

Result

Environment Setup

In console, we choose Cloud Shell and then click the editor mode such that we could easily review our code.

The we have to setup our environment e.g. define project, zone and region:

gcloud config set project <you-project-id>
gcloud config set compute/zone us-central1-a
gcloud config set compute/region us-central1

First of all, please download my prepared files on Cloud Shell:

git clone https://github.com/manbobo2002/gcp-visionAPI-demo.git
cd gcp-visionAPI-demo

Test our Application

What we have to do is just run:

sh setup.sh

The setup script will help us do all the things. First of all, help us create a service-account and generate a key to access Vision API. Also, it helps us install all the required libraries and kick start the application.

When we see something like this, then we are able to test our application through port 5000.

Click the right top corner and then change port.

Set it as 5000 and then change and preview.

Now we can see our application, we just have to choose an image we want and upload it.

Then it will automatically help us analyze the image.

The image will store in uploads folder.

Actually, Vision API provides many functions, we can test these functions by changing the API call in model_predict. For others API reference, please visit here.

Cleanup

To cleanup all the things, we just have to run:

sh cleanup.sh

It does nothing but just help us delete the service account.

Leave a Reply