Book Image

PyTorch Deep Learning Hands-On

By : Sherin Thomas, Sudhanshu Passi
Book Image

PyTorch Deep Learning Hands-On

By: Sherin Thomas, Sudhanshu Passi

Overview of this book

PyTorch Deep Learning Hands-On is a book for engineers who want a fast-paced guide to doing deep learning work with PyTorch. It is not an academic textbook and does not try to teach deep learning principles. The book will help you most if you want to get your hands dirty and put PyTorch to work quickly. PyTorch Deep Learning Hands-On shows how to implement the major deep learning architectures in PyTorch. It covers neural networks, computer vision, CNNs, natural language processing (RNN), GANs, and reinforcement learning. You will also build deep learning workflows with the PyTorch framework, migrate models built in Python to highly efficient TorchScript, and deploy to production using the most sophisticated available tools. Each chapter focuses on a different area of deep learning. Chapters start with a refresher on how the model works, before sharing the code you need to implement it in PyTorch. This book is ideal if you want to rapidly add PyTorch to your deep learning toolset.
Table of Contents (11 chapters)
10
Index

Serving with Flask

Serving the PyTorch model in Python itself is the easiest way of serving your model in production. But before going into explaining how it can be done, let's have a quick look at what Flask is. Explaining Flask completely is out of the scope of this chapter, but we'll still go through the most fundamental concepts of Flask.

Introduction to Flask

Flask is a microframework that's been used in production by several big companies in the Python world. Even though Flask comes up with a template engine that can be used to push the UI to the client, we are not using that; instead, we will make a RESTful backend that serves APIs.

Flask can be installed using pip, just like any other Python package:

pip install Flask

This will install the additional dependencies Werkzeug (the Python interface between the application and the server), Jinga (as the template engine), itsdangerous (for securely signing the data), and Click (as the CLI builder).

Once installed...