Reader small image

You're reading from  Hands-On Python Deep Learning for the Web

Product typeBook
Published inMay 2020
Reading LevelBeginner
PublisherPackt
ISBN-139781789956085
Edition1st Edition
Languages
Right arrow
Authors (2):
Anubhav Singh
Anubhav Singh
author image
Anubhav Singh

Anubhav Singh, a web developer since before Bootstrap was launched, is an explorer of technologies, often pulling off crazy combinations of uncommon tech. An international rank holder in the Cyber Olympiad, he started off by developing his own social network and search engine as his first projects at the age of 15, which stood among the top 500 websites of India during their operational years. He's continuously developing software for the community in domains with roads less walked on. You can often catch him guiding students on how to approach ML or the web, or both together. He's also the founder of The Code Foundation, an AI-focused start-up. Anubhav is a Venkat Panchapakesan Memorial Scholarship awardee and an Intel Software Innovator.
Read more about Anubhav Singh

Sayak Paul
Sayak Paul
author image
Sayak Paul

Sayak Paul is currently with PyImageSearch, where he applies deep learning to solve real-world problems in computer vision and bring solutions to edge devices. He is responsible for providing Q&A support to PyImageSearch readers. His areas of interest include computer vision, generative modeling, and more. Previously at DataCamp, Sayak developed projects and practice pools. Prior to DataCamp, Sayak worked at TCS Research and Innovation (TRDDC) on data privacy. There, he was a part of TCS's critically acclaimed GDPR solution called Crystal Ball. Outside of work, Sayak loves to write technical articles and speak at developer meetups and conferences.
Read more about Sayak Paul

View More author details
Right arrow

Deep Learning through APIs

So far, we have become familiar with the basic pipeline that is followed in a deep learning project. We have completed two basic end-to-end projects in previous chapters using the Keras and TensorFlow.js libraries. We have become familiar with Python libraries such as NumPy, pandas, and Keras, and we have also seen how deep learning models can be developed using JavaScript. We have also used the Flask framework to create an API out of a deep learning model. In chapter 4, Getting Started with TensorFlow.js, we used third-party Application Programming Interfaces (APIs) to create a web application.

In this chapter, we are going to study the whole concept of APIs in detail. Starting with a more informal definition of APIs, we are going to take a look at all APIs that are relevant to deep learning. We will first look at some of the most widely known...

What is an API?

Let's first consider a problem scenario.

Imagine that you are working on a web application that needs an image recognition module to be integrated into it. But you are not into computer vision and deep learning. You have a very strict deadline to meet for the project. You cannot afford to commit to studying deep learning and then complete the project's image recognition module. What should you do now? Will your project be completed by the specified deadline?

It definitely won't! However, with the power of APIs, you will be able to easily integrate the image recognition module into your web application. Let's now discuss the concept of APIs in a bit more detail.

An API is a set of functions (although technically an API can consist of just one function) that can be integrated into an application to perform certain tasks. Often, as developers...

The importance of using APIs

Besides saving you a lot of effort in creating and deploying your own deep learning model when you need a quick production or a minimal working product demo, APIs can provide several benefits, such as these:

  • A standard, stable model:
    • APIs for deep learning are often created by an entire group of developers working together on industry-standard technology and research tools that may not be available to all developers. Also, the models deployed through commercial APIs are often very stable to use and provide state-of-the-art features, including scalability, customization, and accuracy. So, if you're facing accuracy issues, which is a common situation in the production of deep learning models, choosing an API is a good choice.
  • High-performance models:
    • Commercial deep learning APIs often run on very powerful servers and are optimized to a great...

How is an API different from a library?

Nowadays, the terms library and API are used interchangeably. There are many similarities between the two, but they are different in many aspects. Much like an API, a library also provides a collection of functions and classes that can be used as per your needs. The following are some pointers that will help you to distinguish between a library and an API:

  • Libraries are generally specific to programming languages. For example, you cannot use the SciPy Python library if you are using a PHP programming environment. However, you can develop an API that uses SciPy and then consume the API using your PHP code.
  • Developers do not have direct access to an API. APIs are consumed in different ways to how libraries are. Many APIs enforce some kind of authentication before a developer can actually use them. We do not see this very often when it...

Some widely known deep learning APIs

In this section, we are going to take a look at some of the most widely used APIs, which are deployed for a variety of deep learning tasks, such as image recognition, sentiment detection from an image, sentiment classification, speech-to-text conversion, and so on. To limit our discussion in this section, we will divide deep learning tasks into two broad groups:

  • Computer vision and image processing
  • Natural language processing

We will then list some of the common tasks related to each of these groups and discuss the APIs that can be used to accomplish those tasks.

Let's now quickly list some common deep learning tasks and assign them to their categories:

  • Computer vision and image processing:
    • Image search: Just like Google Search, image search engines allow us to search for images similar to a particular image.
    • Image detection:...

Some lesser-known deep learning APIs

The following table gives some details about a few lesser-known APIs:

Provider

API

Group

IBM Watson

Watson Virtual Recognition

Computer vision and image processing

Watson Text to Speech

Natural language processing

Watson Natural Language Classifier

Watson Conversation

Watson Natural Language Understanding

AT&T

AT&T Speech

Natural language processing

Wit.ai

Speech

Natural language processing

Message

Entities

Now, among this ocean (well, almost) of APIs, how do you choose a particular provider for a specific task? It can be tricky and demands a discussion. In this section, we are going to discuss some of the strategies that can effectively help us to make these decisions.

Choosing a deep learning API provider

With the long list of API providers for deep learning that could be compiled, it can be a daunting task to decide which API you require. However, there are some simple rules that you can follow to come up with the most suitable API for your needs, and we'll be discussing a few of them in detail here:

  • Platforms:
    • As simple as it sounds, this is probably the foremost factor that comes into play when you are choosing your API provider. Most of the time, if you are developing a product that runs on Google technologies, for instance, you might want to use the deep learning APIs that Google provides, simply because they would integrate seamlessly with the application development interface that you are working with.
    • More often than not, a development environment also offers templated solutions for using its deep learning APIs that are very...

Summary

In this chapter, we took a detailed look at the term API. In Chapter 3, Creating Your First Deep Learning Web Application, we saw how an API can be written in Python using Flask and we saw how to use that API in a web application. We now know how an API is different from a language library and how important it is to make use of APIs. We became familiar with a variety of deep learning APIs that are offered by some top-notch organizations. 

As we progress through the upcoming chapters, we will see how to use these APIs to build powerful and intelligent web applications. We will start with the deep learning APIs provided by Google Cloud Platform in the next chapter. 

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Python Deep Learning for the Web
Published in: May 2020Publisher: PacktISBN-13: 9781789956085
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 (2)

author image
Anubhav Singh

Anubhav Singh, a web developer since before Bootstrap was launched, is an explorer of technologies, often pulling off crazy combinations of uncommon tech. An international rank holder in the Cyber Olympiad, he started off by developing his own social network and search engine as his first projects at the age of 15, which stood among the top 500 websites of India during their operational years. He's continuously developing software for the community in domains with roads less walked on. You can often catch him guiding students on how to approach ML or the web, or both together. He's also the founder of The Code Foundation, an AI-focused start-up. Anubhav is a Venkat Panchapakesan Memorial Scholarship awardee and an Intel Software Innovator.
Read more about Anubhav Singh

author image
Sayak Paul

Sayak Paul is currently with PyImageSearch, where he applies deep learning to solve real-world problems in computer vision and bring solutions to edge devices. He is responsible for providing Q&A support to PyImageSearch readers. His areas of interest include computer vision, generative modeling, and more. Previously at DataCamp, Sayak developed projects and practice pools. Prior to DataCamp, Sayak worked at TCS Research and Innovation (TRDDC) on data privacy. There, he was a part of TCS's critically acclaimed GDPR solution called Crystal Ball. Outside of work, Sayak loves to write technical articles and speak at developer meetups and conferences.
Read more about Sayak Paul