This post comes with a python notebook where we explain all the steps you need to follow for deploying a deep neural network through an API to perform image classification.
Deploying deep learning on the cloud
In a previous post, we saw how to train a Convolutional Neural Network (CNN), now we are going to see how to create an API that classifies images in the cloud. The frameworks used in the solution are:
- CNTK: Microsoft's Cognitive Toolkit is the deep learning library we used to compute the CNN model that identifies images.
- Flask is one of the most popular frameworks to develop APIs in python.
- CherryPy is a lightweight web framework for python. We use it as a web server to host the machine learning application.
The main procedure is executed by a CNTK CNN. The network is a pretrained ResNet with 152 layers. The CNN was trained on ImageNet dataset, which contains 1.2 million images divided into 1000 different classes.
The CNN is accessible through the flask API, which provides an endpoint /api/v1/classify_image
that can be called to classify an image. CherryPy is the server framework where the application is hosted. It also balances the load, in such a way that several concurrent queries can be executed. Externally, there is the client, which can be any desktop or mobile. It sends an image to the application for analysis and receives the response.
If you want to understand the end to end process, take a look at this notebook.