Reader small image

You're reading from  Hands-On Machine Learning on Google Cloud Platform

Product typeBook
Published inApr 2018
PublisherPackt
ISBN-139781788393485
Edition1st Edition
Right arrow
Authors (3):
Giuseppe Ciaburro
Giuseppe Ciaburro
author image
Giuseppe Ciaburro

Giuseppe Ciaburro holds a PhD and two master's degrees. He works at the Built Environment Control Laboratory - Università degli Studi della Campania "Luigi Vanvitelli". He has over 25 years of work experience in programming, first in the field of combustion and then in acoustics and noise control. His core programming knowledge is in MATLAB, Python and R. As an expert in AI applications to acoustics and noise control problems, Giuseppe has wide experience in researching and teaching. He has several publications to his credit: monographs, scientific journals, and thematic conferences. He was recently included in the world's top 2% scientists list by Stanford University (2022).
Read more about Giuseppe Ciaburro

V Kishore Ayyadevara
V Kishore Ayyadevara
author image
V Kishore Ayyadevara

V Kishore Ayyadevara leads a team focused on using AI to solve problems in the healthcare space. He has 10 years' experience in data science, solving problems to improve customer experience in leading technology companies. In his current role, he is responsible for developing a variety of cutting edge analytical solutions that have an impact at scale while building strong technical teams. Prior to this, Kishore authored three books — Pro Machine Learning Algorithms, Hands-on Machine Learning with Google Cloud Platform, and SciPy Recipes. Kishore is an active learner with keen interest in identifying problems that can be solved using data, simplifying the complexity and in transferring techniques across domains to achieve quantifiable results.
Read more about V Kishore Ayyadevara

Alexis Perrier
Alexis Perrier
author image
Alexis Perrier

Alexis Perrier is a data science consultant with experience in signal processing and stochastic algorithms. He holds a master's in mathematics from Universit Pierre et Marie Curie Paris VI and a PhD in signal processing from Tlcom ParisTech. He is actively involved in the DC data science community. He is also an avid book lover and proud owner of a real chalk blackboard, where he regularly shares his fascination of mathematical equations with his kids.
Read more about Alexis Perrier

View More author details
Right arrow

Google Machine Learning APIs

As seen in the previous chapter, machine learning is used in a wide variety of applications. However, a few applications are easy to build, while a few are very hard to build, especially for a user who is less familiar with machine learning. Some of the applications that we are going to discuss in this chapter fall in the hard to build category, as the process of building a machine learning model for these applications is data intensive, resource intensive, and requires a lot of knowledge in the field.

In this chapter, we will go over five machine learning APIs provided by Google (as of March 2018). These APIs are meant to be used out of the box, as RESTful APIs. For each service mentioned in the following, we will show what type of application can benefit from it, and how to interpret the returned results:

  • Vision has a label detection, OCR, face...

Vision API

The Vision API lets us build quite a few applications related to vision:

  • Detecting labels in an image
  • Detecting the text in an image
  • Face detection
  • Emotion detection
  • Logo detection
  • Landmark detection

Before we dive into building applications using the preceding, let's get a quick understanding of how they might be built, using face emotion detection as an example.

The process of detecting emotions involves:

  1. Collecting a huge set of images
  2. Hand-labeling images with the emotion that is likely represented in the image
  3. Training a convolutional neural network (CNN) (to be discussed in future chapters) to classify the emotion, based on an image as input

While the preceding steps are heavily resource intensive (as we would need a lot of humans to collect and hand-label images), there are multiple other ways to obtain face emotion detection. We are not sure how Google...

Cloud Translation API

The Cloud Translation API provides a simple, programmatic interface for translating an arbitrary string into any supported language, using state-of-the-art neural machine translation. The Translation API is highly responsive, so websites and applications can integrate with the Translation API for fast, dynamic translation of source text from the source language to a target language (for example, French to English). Language detection is also available for cases in which the source language is unknown.

Enabling the API

For us to be able to use Google cloud translation services, we need to enable, which is done as follows:

  1. In order to enable the Google Cloud Translation API, search for the API in the console...

Natural Language API

The Google Cloud Natural Language API reveals the structure and meaning of text by offering powerful machine learning models in an easy-to-use REST API. You can use it to extract information about people, places, events, and much more, that are mentioned in text documents, news articles, or blog posts. You can also use it to understand the sentiment about your product on social media, or to parse intent from customer conversations happening in a call center or a messaging app. You can analyze the text uploaded in your request, or integrate it with with your document storage on Google Cloud storage.

The Cloud Natural Language API can be found by searching for it in your console, as follows:

The Cloud Natural Language API is enabled in the resulting page:

Similar to the Translation API, we do not have to create credentials for this API if at least one API...

Speech-to-text API

The Google Cloud Speech API enables developers to convert audio to text, by applying powerful neural network models in an easy-to-use API. The API recognizes over 110 languages and variants. One can transcribe the text of users dictating to an application's microphone, enable command-and-control through voice, or transcribe audio files, among many use cases.

In order to enable the speech to text API, search for it in the console, as follows:

In the resulting web page, enable the API, as follows:

Similar to the APIs mentioned in the previous sections, credentials obtained for one API can be replicated for the other Google APIs. So, we don't have to create credentials separately for the speech to text API.

Once the API is enabled, let's start the Cloud Shell and Datalab, as we did in the previous sections.

In the following code, we transcribe...

Video Intelligence API

The Cloud Video Intelligence API makes videos searchable and discoverable, by extracting metadata with an easy-to-use REST API. You can now search every moment of every video file in your catalog. It quickly annotates videos stored in Google Cloud storage, and helps you to identify key entities (nouns) within your videos and when they occur.

The Cloud Video Intelligence API can be searched for and enabled as follows:

We import the required packages and add the path to the api-key, as follows:

from google.cloud import videointelligence
import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/content/datalab/google-api.json"
from google.cloud.speech import enums
from google.cloud.speech import types

The method features enables us to specify the type of content that we want to detect in a video. The features available are as follows:

Let...

Summary

In this chapter, we went through the major machine learning APIs that Google provides: vision, translate, NLP, speech, and video intelligence. We have learned how the various methods in each of the APIs enable us to replicate deep learning results, without having to code from scratch.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Machine Learning on Google Cloud Platform
Published in: Apr 2018Publisher: PacktISBN-13: 9781788393485
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (3)

author image
Giuseppe Ciaburro

Giuseppe Ciaburro holds a PhD and two master's degrees. He works at the Built Environment Control Laboratory - Università degli Studi della Campania "Luigi Vanvitelli". He has over 25 years of work experience in programming, first in the field of combustion and then in acoustics and noise control. His core programming knowledge is in MATLAB, Python and R. As an expert in AI applications to acoustics and noise control problems, Giuseppe has wide experience in researching and teaching. He has several publications to his credit: monographs, scientific journals, and thematic conferences. He was recently included in the world's top 2% scientists list by Stanford University (2022).
Read more about Giuseppe Ciaburro

author image
V Kishore Ayyadevara

V Kishore Ayyadevara leads a team focused on using AI to solve problems in the healthcare space. He has 10 years' experience in data science, solving problems to improve customer experience in leading technology companies. In his current role, he is responsible for developing a variety of cutting edge analytical solutions that have an impact at scale while building strong technical teams. Prior to this, Kishore authored three books — Pro Machine Learning Algorithms, Hands-on Machine Learning with Google Cloud Platform, and SciPy Recipes. Kishore is an active learner with keen interest in identifying problems that can be solved using data, simplifying the complexity and in transferring techniques across domains to achieve quantifiable results.
Read more about V Kishore Ayyadevara

author image
Alexis Perrier

Alexis Perrier is a data science consultant with experience in signal processing and stochastic algorithms. He holds a master's in mathematics from Universit Pierre et Marie Curie Paris VI and a PhD in signal processing from Tlcom ParisTech. He is actively involved in the DC data science community. He is also an avid book lover and proud owner of a real chalk blackboard, where he regularly shares his fascination of mathematical equations with his kids.
Read more about Alexis Perrier