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

DL on AWS Using Python: Object Detection and Home Automation

We familiarized ourselves with a few deep-learning-based offerings from Google Cloud Platform and learned how they can be used in Chapter 6, Deep Learning on Google Cloud Platform Using Python. Now that we have a fairly good overview of cloud computing, in this chapter, we will introduce another cloud computing platform, Amazon Web Services (AWS), which also offers some high-performing and highly reliable deep-learning-based solutions to make life easier. In this chapter, we are going to introduce two of them in the form of APIs and learn how they can be consumed from a Python program.

We will start by setting up our AWS account and configuring boto3 in Python. We will then learn how to use the Rekognition API and the Alexa API in Python.

In this chapter, we will cover the following topics:

  • Setting up your AWS account...

Technical requirements

Getting started in AWS

Before using any AWS services or APIs, you will have to create your AWS account. In this section, we will quickly go through the steps to create an account in AWS:

  1. The first step is to go to https://aws.amazon.com/. You should land on a page that resembles the following:

  1. Then click on the Create an AWS Account button, which should take you to the following page:

  1. Fill in the fields and click on Continue.
  2. The portal will ask for some more mandatory information from you. It will also ask you to register a payment method in order to verify your details.
If you do not provide this, you will not be entitled to use the free tier of AWS facilities.
  1. Towards the very last step of your registration, you will be asked to choose between three plans—Free, Developer, and Business. Choose whichever is relevant to your needs and proceed.

Like Google Cloud...

A short tour of the AWS offerings

AWS offers its services and solutions in a variety of domains. The following are the different types of module that AWS offers (the ones in brackets are the names of the different services offered by AWS):

  • Compute (EC2, Lambda, and so on)
  • Storage (S3, Storage Gateway, and so on)
  • Machine learning (Amazon SageMaker, AWS DeepLens, and so on)
  • Database (RDS, DynamoDB, and so on)
  • Migration and transfer (Snowball, DataSync, and so on)
  • Networking and content delivery (CloudFront, VPC, and so on)
  • Developer tools (CodeStar, CodeCommit, and so on)
  • Robotics (AWS RoboMaker)
  • Blockchain (Amazon Managed Blockchain)
  • Analytics (Athena, CloudSearch, and so on)

There are also many others, as shown in the following screenshot:

The list is actually pretty extensive, but let's restrict our focus to machine learning (also known as deep learning) services for...

Getting started with boto3

boto3 is the official library for communicating with AWS APIs, provided by the AWS team. You can find the library at https://aws.amazon.com/sdk-for-python/, and it can be installed using the following command:

pip install boto3

After installation, you need to configure boto3 for use with your project. To configure boto3 (https://bit.ly/2OvXAvb), the first step is to get your AWS access keys from the Identity and Access Management (IAM) console. Go through the following steps to perform the configuration:

  1. Go to your AWS IAM console at https://console.aws.amazon.com/iam. It will look like the following:

On the preceding dashboard, you will be able to see the access keys.

  1. Click on Delete your root access keys and then Manage Security Credentials. You will be presented with the following window:

  1. Expand the Access keys (access key ID and secret access...

Using the Rekognition API in Python

Amazon Rekognition is a deep-learning-enabled visual-analysis service that can help you search, verify, and analyze billions of images seamlessly. Let's first review the Recognition API briefly and then we will jump straight into using it in Python. Let's first go to the home page of the Rekognition API at https://console.aws.amazon.com/rekognition/home. We have already seen Rekognition's home page in one of the earlier sections of this chapter.

As you might have already noticed from the navigation bar, the Rekognition API has several things to offer:

  • Object and scene detection: This lets you automatically label objects, labels, and scenes from a given image (along with confidence scores).
  • Image moderation: This allows you to detect explicit or suggestive adult content in images, along with confidence scores.
  • Celebrity recognition...

Using the Alexa API in Python

Amazon Alexa is a voice-based personal assistant developed by Amazon. The product first featured as an interface for Amazon Echo devices, which went on to inspire the Google Home devices by Google, which use Google Assistant. Other competitors of Alexa are Microsoft's Cortana and Apple's Siri. As a virtual assistant, Alexa can easily set up calls, schedule meetings, or play songs. The various tasks that Alexa can perform are called skills in the Alexa terminology, which we'll be following in this section.

Skills in Alexa are the main core of how we can bring functionality to the platform. Each skill needs to be invoked from the primary interface of Alexa, whereupon the skill takes over the entire functionality unless the program logic completes or the user explicitly asks for the skill to end. Skills apply the logic for the task to...

Summary

In this chapter, we covered how we can use AWS using its Python API—boto3. We explored the various options and configurational requirements for using the API and looked at an example of how to use it with the Rekognition API for recognizing celebrities. We then dove deep into how to create an Alexa skill for home automation, setting up the simple task of turning a switch on/off. This can be very easily extrapolated to other smart home devices. We looked at how Alexa skill logic can be hosted over AWS Lambda and observed from AWS CloudWatch. We also explored the storage of dynamic device data in Amazon DynamoDB.

In the upcoming chapter, we will see how we can use deep learning on Microsoft's Azure platform using Python.

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