Home

Awesome

Deploy Keras Model with Flask as Web App in 10 Minutes

Contributions Welcome

A minimal and customizable repo to deploy your image models as web app easily.

Getting Started

Screenshot:

<p align="center"> <img src="./docs/screenshot.avif" height="420px" alt=""> </p>

New Features :fire:

<p float="left"> <img src="https://user-images.githubusercontent.com/5097752/71065048-61c1c800-213e-11ea-92f1-274cbe4734ba.png" height="330px" alt=""> <img src="https://user-images.githubusercontent.com/5097752/71062921-aeef6b00-2139-11ea-8b23-6b9eb1e326ca.png" height="330px" alt=""> </p>

Run with Docker

Use prebuilt image

$ docker run --rm -p 5000:5000 ghcr.io/imfing/keras-flask-deploy-webapp:latest

Build locally

With Docker, you can quickly build and run the entire application in minutes :whale:

# 1. First, clone the repo
$ git clone https://github.com/imfing/keras-flask-deploy-webapp.git
$ cd keras-flask-deploy-webapp

# 2. Build Docker image
$ docker build -t keras_flask_app .

# 3. Run!
$ docker run -it --rm -p 5000:5000 keras_flask_app

Open http://localhost:5000 and wait till the webpage is loaded.

Local Installation

It's easy to install and run it on your computer.

# 1. First, clone the repo
$ git clone https://github.com/imfing/keras-flask-deploy-webapp.git
$ cd keras-flask-deploy-webapp

# 2. Install Python packages
$ pip install -r requirements.txt

# 3. Run!
$ python app.py

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

<p align="center"> <img src="https://user-images.githubusercontent.com/5097752/71064959-3c34be80-213e-11ea-8e13-91800ca2d345.gif" height="480px" alt=""> </p>

Customization

It's also easy to customize and include your models in this app.

Note Also consider gradio or streamlit to create complicated web apps for ML models.

<details> <summary>Details</summary>

Use your own model

Place your trained .h5 file saved by model.save() under models directory.

Check the commented code in app.py.

Use other pre-trained model

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

Check this section in app.py.

UI Modification

Modify files in templates and static directory.

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

</details>

More Resources

Building a simple Keras + deep learning REST API