Serving TensorFlow Models Using Docker to Classify MNIST Digits

Part 1: Project to deploy TensorFlow digit classifier models using docker and integrating them with an Angular front end.

Table of contents

Recently I implement an end to end solution to better understand how a TensorFlow model could be leveraged in a production environment. There are many great resources available online that walk you through setting up and training TensorFlow models and deploying them as services. However, during this short project, I ran into several issues (mostly due to my lack of experience and understanding) and wanted to document my general process and issue resolution here so others can potentially learn from my mistakes and lessons.

Although I undertook this project to learn about TensorFlow model serving I wanted to tackle an end to end challenge to ensure my understanding (and that my setup works).

Project scope

This project is broken down into 3 sections/posts:

Note that the second section is the one that deals with the actual hosting of TensorFlow models while the other 2 sections help set up a testing platform. In terms of a problem for my TensorFlow model to solve I chose the MNIST digit data set. This dataset is readily available online and typically yields very good results with even the most basic models. This project will involve a set of models to classify these digits, host the models, and then provide an interface for a user to draw digits for classification.

some sample images from the MNIST data set

High-level architecture

A single Virtual Machine is leveraged for this project and the docker containers will be used for the deployment of isolated components as illustrated below. For my implementation, an Ubuntu Google Cloud Platform Virtual Machine instance was leveraged but any VM can be used.

High-level system architecture

What will be covered in my post regarding this project

What will not be covered in my post regarding this project

Keep in mind the objective of this project is not to optimize accuracy. The model is finicky with off-center and large/small images as it does not take advantage of convolution. The objective is to deploy a complete end to end functional solution.

Here is a summary of the components involved in this project

Serial tinkerer and digital architect

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store