Book Image

Google Cloud AI Services Quick Start Guide

By : Arvind Ravulavaru
Book Image

Google Cloud AI Services Quick Start Guide

By: Arvind Ravulavaru

Overview of this book

<p>Cognitive services are the new way of adding intelligence to applications and services. Now we can use Artificial Intelligence as a service that can be consumed by any application or other service, to add smartness and make the end result more practical and useful.</p> <p>Google Cloud AI enables you to consume Artificial Intelligence within your applications, from a REST API.  Text, video and speech analysis are among the powerful machine learning features that can be used. This book is the easiest way to get started with the Google Cloud AI services suite and open up the world of smarter applications.</p> <p>This book will help you build a Smart Exchange, a forum application that will let you upload videos, images and perform text to speech conversions and translation services. You will use the power of Google Cloud AI Services to make our simple forum application smart by validating the images, videos, and text provided by users to Google Cloud AI Services and make sure the content which is uploaded follows the forum standards, without a human curator involvement.</p> <p>You will learn how to work with the Vision API, Video Intelligence API, Speech Recognition API, Cloud Language Process, and Cloud Translation API services to make your application smarter.</p> <p>By the end of this book, you will have a strong understanding of working with Google Cloud AI Services, and be well on the way to building smarter applications.</p>
Table of Contents (9 chapters)

Cognition on cloud

In the last section, we saw the various services offered by Google Cloud Platform. One of the services we saw in that section is Google Cloud AI Services. Before we start exploring Google Cloud AI Services, let's understand what it's importance is.

We have been using the cloud as a central entity for storing data and providing scalable computing for more than a decade now. Until recently, all applications had intelligence built in locally. Times have changed; we are now using the cloud as a central dispatcher for intelligence. We have separated the application from its intelligence and have hosted the intelligence so that everyone can use it and not just the application.

So, what exactly is AI in the cloud? It is when clients upload data to a cognitive service, and the service responds with a prediction.

Let's take a moment to understand the three previously highlighted terms: the clients, the data, and the cognitive service. This helps us better define AI on the cloud.

Clients

When I say clients, I mean any device that has the capability of making an HTTP request to an endpoint and being able to resolve the response.

This could be a simple web/mobile/desktop application or a piece of smart internet-enabled hardware such as an IoT device, a voice assistant, a smartwatch, or a smart camera.

If these were defined as clients, what would the data that we are dealing with be?

Data types

As we have seen the different types of clients, let's see what kinds of data they produce.

In today's world, data can be categorized into three types:

  • Structured data: Structured data is well defined data and the entire dataset follows a schema for such data. Examples of structured data are CSV files and RDBMS databases.
  • Unstructured data: Unstructured data, on the other hand, is not well defined and there are structural changes to the data throughout the dataset. Examples of unstructured data are audio files, video files, and image files.
  • Semi-structured data: Data that is present in emails, log files, text files, or word documents is considered unstructured data.

So, data has three types, and we need a cognitive service that can consume this data and respond with an intelligent response. So, let's define what a cognitive service is.

Cognitive services

A cognitive service is a piece of computing software that can consume a data type that we have defined previously and respond with a cognitive response.

A simple example of a cognitive service is image intelligence. This is the ability to upload an image to view its contents and label it. Almost all of us have experienced this feature using the camera app, where the camera software can detect faces and detect smiles on those faces. This is image intelligence.

Another type of intelligence is sentiment analysis. Given a few paragraphs of text, the cognitive service can detect the emotions in the text. A simple example could be a product Twitter account feeding all the tweets it's tagged in into a cognitive service to see the overall sentiment of people using the product.

Of late, video intelligence has become even more common. This is the ability to scan a video's contents and label it for rapid detection of content in various frames and scenes, and this is very helpful for navigating and indexing a long video.

Now that we understand what AI on the cloud is, let's look at why we need it.

Why Cognition on Cloud?

This is a very important question that one needs to understand before going further. Here are a few reasons:

  • Distributed global intelligence
  • Process large volumes of data
  • Process different types of data
  • Cognitive accuracy

Distributed global intelligence defines how cognition as a service, when placed in a central location, can be used by many more entities to make them smart, rather than just one application.

Processing large volumes of data defines how the power of cloud computing can handle large volumes of data efficiently, which a normal computer or a human being would find difficult.

Processing different types of data defines how the cognitive service can process various types of data without much effort.

Cognitive accuracy is one of the most important features of all. The more data a machine learning algorithm service consumes, the better its accuracy. We will talk more about this in the next sections.

How do machines achieve intelligence?

Accuracy depends on how we train the system. There are two ways for machines to learn something:

  • Rule-based learning
  • Pattern-based learning

In rule-based learning, the developer defines a bunch of rules and the machine parses the incoming data against those rules to come to a conclusion. This approach is good for monotonous systems and where things do not change that often.

What if we are trying to build ;intelligence for a weather prediction system? Will the learning that we have had up to today be enough for us to get an accurate prediction, even after 50 years? Maybe not.

This is where pattern-based learning comes in. Pattern-based learning is more popularly known as machine learning (ML). In today's world, most of the learning by computers happens through machine learning. Let's take a quick look at how ML plays an important role in this.

Cognitive accuracy and machine learning

Machine learning is the process a machine follows to learn about various things. Some things are easier to learn than others.

Artificial Intelligence is a collection of such machine learnings that can be put to use in the real world to make decisions or to predict something.

Here is a diagram that shows how a typical machine learns:

We have a data-gathering source at one end, which gets data from various reliable sources, depending on the solution. This data has both features and labels. Features are columns of data that are taken as input to learning, and labels are the expected outcome for that set of features. Let's take a look at an example of weather station data:

Temperature

Humidity

Wind

Rainfall

17 degrees Celsius

87%

5 km per hour

10 mm

23 degrees Celsius

23%

1 km per hour

0 mm

The columns named Temperature, Humidity, and Wind are features, and Rainfall is a label, in our table. Using this type of supervised learning, we would build a data model from this data and ask a question such as: Given the following features, what is the chance of rain?

The data we gather is the most important part of machine learning, as the quality and quantity of data define the accuracy of prediction.

Once the data has been gathered, this data is then cleaned and normalized. The cleaned data is then split into two parts, training data and testing data. Training data is used to train the data model and testing data is used to cross-validate the accuracy of the data model.

Now, depending on the type of cognitive service we want to provide, we would use a machine learning algorithm and feed the training data to it, building something called a data model.

A data model is a snapshot of the learning and this snapshot is now tested against the testing data. This step is critical in analyzing the accuracy of the data model.

The model can be trained again and again with various sets of data to have a better accuracy. Once the model is completed, we host it as an API for other systems to query it, passing their features. Based on the prediction results from here on, we would refine the data model.

The previous process is how most cognitive services are built. Now, one of the key steps of data model accuracy depends on the quality and quantity of data.

The more accurate the data that is fed to the machine learning algorithm, the higher the quality of the data model.

Imagine a cognitive service such as explicit image detection built by you or your organization. We need data to train this cognitive service to start with. How many images can we feed it, 1 million, 2 million? Imagine the size of infrastructure needed for training about 10 million images.

Once the service is built, how many hits will your users make? 1 million requests per day? And will this be sufficient to know the accuracy of your model and improve it?

Now, on the other hand, consider data models built by the likes of Google, which pretty much has access to almost all the content of the internet. And imagine the number of people using this service, thus helping the cognitive service to learn by experience.

Within no time, a cognitive service like this will be far more accurate, not only for mainstream scenarios, but also corner cases.

In cognitive services, accuracy increases with the quality and quantity of data and this is one of the main things that adds value to cloud-based cognition over local intelligence.

Take a look at this video titled Inside Google Translate: https://www.youtube.com/watch?v=_GdSC1Z1Kzs, which explains how the Google Translate service works. This re-emphasizes the thought I expressed previously about how machines learn.

This concludes our section on why cognition on the cloud. In the next section, we are going to explore various Google Cloud AI services.