Skip to content
😺 Pretty&simple image classifier app template. Deploy your own trained model or pre-trained model (VGG, ResNet, Densenet) to a web app using Flask in 10 minutes.
Branch: master
Clone or download
mtobeiyf Merge pull request #12 from physhik/docker
Update dockerfile and README
Latest commit 5d89ee1 Mar 12, 2019

Deploy Keras Model with Flask as Web App in 10 Minutes

GPLv3 license

A pretty and customizable web app to deploy your DL model with ease

Getting started in 10 minutes


Docker Installation

Build and run an image for keras-application pretrained model

$ cd keras-flask-deploy-webapp
$ docker build -t keras_flask_app .
$ docker run -d -p 5000:5000 keras_flask_app 

Build and run an image from your model into the containeri.

After build an image as above, and

$ docker run -e MODEL_PATH=/mnt/models/your_model.h5  -v volume-name:/mnt/models -p 5000:5000 keras_flask_app

Pull an built-image from Docker hub

For your convenience, can just pull the image instead of building it.

$ docker pull physhik/keras-flask-app:2 
$ docker run -d -p 5000:5000 physhik/keras-flask-app:2

Open http://localhost:5000 after waiting for a minute to install in the container.

Local Installation

Clone the repo

$ git clone

Install requirements

$ pip install -r requirements.txt

Make sure you have the following installed:

  • tensorflow
  • keras
  • flask
  • pillow
  • h5py
  • gevent

Run with Python

Python 2.7 or 3.5+ are supported and tested.

$ python


Open http://localhost:5000 and have fun. 😃


Use your own model

Place your trained .h5 file saved by under models directory.

Check the commented code in

Use other pre-trained model

See Keras applications for more available models such as DenseNet, MobilNet, NASNet, etc.

Check this section in

UI Modification

Modify files in templates and static directory.

index.html for the UI and main.js for all the behaviors


To deploy it for public use, you need to have a public linux server.

Run the app

Run the script and hide it in background with tmux or screen.

$ python

You can also use gunicorn instead of gevent

$ gunicorn -b app:app

More deployment options, check here

Set up Nginx

To redirect the traffic to your local app. Configure your Nginx .conf file.

server {
    listen  80;

    client_max_body_size 20M;

    location / {

More resources

Check Siraj's "How to Deploy a Keras Model to Production" video. The corresponding repo.

Building a simple Keras + deep learning REST API

You can’t perform that action at this time.