A Deep Learning Web-app using Docker and Heroku

Original article can be found here (source): Deep Learning on Medium

A Deep Learning Web-app using Docker and Heroku

Debugging and Deploying.

Huge L

More than a week ago I made a Deep Learning model that classified the alphabets in the American Sign Language using the data-set I found here. Here I was thinking I’d turn into a web-app, deploy it and document my exploits in an article. That was almost exactly a week ago. It took me an hour to train the model and nearly 168 to deploy it. Here’s what I learned this week.


The first time I had deployed a web-app was editing someone else’s Github repo. So this time I wanted to do it the hard way and deploy it locally before on a server.

So, what is docker?

“Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package.” Being as inquisitive as I was, I went straight ahead and got to trying to install it without even finding out exactly how it worked. Little did I know that it required a Windows 10 Pro (mine was a Home Edition). Twelve hours and numerous tutorials later Docker was running on Ubuntu 18.04 on VirtualBox.

The Docker Image

Little to my knowledge I’d spend the next twenty-four hours trying to initialize the image for my web-app. Throughout these hours, I’d install and reinstall Docker thinking it was the fault of my Docker installation. The truth is the answer was right in front of me all along.

When you create an image, there’s supposed to be a Docker file in the directory which tells Docker the dependencies it has to install.

An example Dockerfile

What I discovered after hours of toiling was that Pytorch(on top of which fastai works) required Python 3.6 or above. My Ubuntu had Python 2.7. My problem was solved and my brain had turned into mush by now.


At this point, I had deployed my image in my local environment. Now I needed to push it to a server that would host it. This is where Heroku comes in, they provide you with quite a lot of free hours to run your web apps.

I’d read on their documentation that the whole web app including dependencies had to be less than 500Mb; my docker image at the time was 4Gb. I spent that day moving through various Github repositories to no avail.

I kept getting this error which I couldn’t get past.

All hope was lost and I was about to abandon my dream of deploying my web-app. That was when I found this blog post and their Github repo with a heavenly ReadMe. Everything I had to do was explained so beautifully and concisely. It was exactly the kind of hand-holding I was looking for, all I had to do was put my model in the template. The result of this looks like this. It might take a while to load up, so bear with it.



Initially, I was of the mind that I had to do everything from scratch, write all the code in Python Flask, find a way to deploy it all on my own. The funny thing is, everything looks like a rat race from the outside. But once you’re a part of it, especially when you’re starting, you see that everyone is willing to help you out. All you have to do is admit that you don’t know how it works. I don’t know how exactly docker or Heroku works, I don’t know anything about Flask which was used to write the backend. Funnily enough, I was still able to make a half-decent bare-bones web-app with grit and a whole lotta time. You can too.