Google Cloud Vision implementation in Python

In this post, we will see the Google Cloud Vision implementation in Python. Basically using cloud vision, we can extract image features. Google Cloud Vision API enables developers to understand the content of an image by encapsulating powerful machine learning models in an easy to use REST API. This tutorial is all about implementing Google cloud vision in python.

Using cloud vision, we can extract details such,

  • Landmark Extraction
  • Logo Extraction
  • Mood Analysis
  • Text Extraction
  • Environment Analysis
Google Cloud Vision implementation in Python
Creating a new Project

In order to use google cloud vision, you have to grab an account at Google Cloud. After creating your Google Cloud Account, you can go to the Google Cloud Console. Then click on create a new project, give your project name. Now, wait for it to create that project, Scroll down, and go to APIs overview. Now click on Enable API, Choose Vision API, then again click on Enable.

 

 

Now click on credentials, then create credentials, choose OAuth client ID. It will then ask for ‘create consent screen’, click on that, and then add your details, and proceed. Now choose other, and in it, type Python Client. Now it will display your client ID details, click ok. You have to download the file, listed under ‘OAuth 2.0 client IDs‘. The file will be downloaded in JSON format.

Google Cloud Vision implementation in Python
Screen where you can download the credentials file

The JSON file downloaded is important because it contains the credentials for authentication with the cloud console. For each console session, you have to define the constant, GOOGLE_APPLICATION_CREDENTIALS as your downloaded JSON file.

To install the Python Google Cloud Vision Library, just open console and type below

Fine we are now done with the installing of packages, now let us dig the code.

Text Extraction (Google Cloud Vision implementation in Python)
Text Extraction (Google Cloud Vision implementation in Python)
Text Extraction (Google Cloud Vision implementation in Python)
Landmark Analysis (Google Cloud Vision implementation in Python)
Landmark Analysis (Google Cloud Vision implementation in Python)
Landmark Analysis (Google Cloud Vision implementation in Python)
Similarly, you can do the same for mood analysis, logo extraction, scene detection and all, all you need to do is send particular type in the feature array of the service requests. For example, in the case of landmark extraction, we are using ‘type’: ‘LANDMARK_DETECTION’, the same is for all other types. If you found the post useful, kindly share it with others and help us grow. if have any doubts, drop them in the comments section.

Hey there, I’m Sid. I often write articles here. Apart from being a developer, my interest range from blogging, designing, tinkering and hearing electronic. To connect with me, just navigate to any social icons, below!

Sidharth Patnaik

Hey there, I'm Sid. I often write articles here. Apart from being a developer, my interest range from blogging, designing, tinkering and hearing electronic. To connect with me, just navigate to any social icons, below!

Leave a Reply

Your email address will not be published. Required fields are marked *