spykard / Deep-Learning-WebApp

Deploy your own or any pre-trained Deep Neural Network to the Web using Flask. Supports both text and image classifiers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deploy a Deep Learning Model as a Web App in 10 Minutes

GPLv3 license Python Version Contributions Welcome

A pretty and customizable web app to deploy your Deep Learning Models with ease.

Getting Started

Example of the Implementation in action

New Features ๐Ÿ”ฅ

  • Enhanced, mobile-friendly UI
  • Support image drag-and-drop
  • State-of-the-art custom-made text preprocessing
  • Use vanilla JavaScript, HTML and CSS. Remove jQuery and Bootstrap
  • Upgrade Docker base image to Python 3


Run with Docker

With Docker, you can quickly build and run the entire application in minutes ๐Ÿณ

# 1. First, clone the repo
$ git clone https://github.com/spykard/Deep-Learning-WebApp.git
$ cd Deep-Learning-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 the app on your computer.

# 1. First, clone the repo
$ git clone https://github.com/spykard/Deep-Learning-WebApp.git
$ cd Deep-Learning-WebApp

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

# 3. Run!
$ python app.py

Open http://localhost:5000 and have fun. ๐Ÿ˜ƒ


Customization

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

Details

Use your own model

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

Change the code in app.py and make the appropriate changes in the preprocessing modules (deeplearning_image.py and deeplearning_text.py) to fit your model's needs.

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 implements the UI and main.js implements all the behaviors.

Deployment

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

Details

Run the app

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

$ python app.py

You can also use gunicorn instead of gevent

$ gunicorn -b 127.0.0.1:5000 app:app

For 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 / {
      proxy_pass http://127.0.0.1:5000;
  }
}

Resources

Building a simple Keras Deep Learning REST API

About

Deploy your own or any pre-trained Deep Neural Network to the Web using Flask. Supports both text and image classifiers.

License:GNU General Public License v3.0


Languages

Language:Python 71.8%Language:JavaScript 11.6%Language:HTML 8.3%Language:CSS 8.0%Language:Dockerfile 0.3%