keras-flask-deploy-webapp

GPL-3.0 License
Python
跨平台
2021-11-17
首席测试

Deploy Keras Model with Flask as Web App in 10 Minutes

GPLv3 license Contributions Welcome

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

Buy Me A Coffee

Getting Started in 10 Minutes

👇 Screenshot:

New Features 🔥

  • Enhanced, mobile-friendly UI
  • Support image drag-and-drop
  • Use vanilla JavaScript, HTML and CSS. Remove jQuery and Bootstrap
  • Switch to TensorFlow 2.0 and tf.keras by default
  • Upgrade Docker base image to Python 3 (it's 2020)

If you need to use Python 2.x or TensorFlow 1.x, check out the legacy snapshot


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/mtobeiyf/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/mtobeiyf/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. 😃


Customization

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

Details

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.

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

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;
  }
}

Future Plan

  • Support detection and segmentation models

More Resources

Building a simple Keras + deep learning REST API

加载中

暂无资讯

暂无问答

Keras + Flask 提供接口服务的坑~~~

最近在搞Keras,训练完的模型要提供个预测服务出来。就想了个办法,通过Flask提供一个http服务,后来发现也能正常跑,但是每次预测都需要加载模型,效率非常低。 然后就把模型加载到全局,每...

2018/12/28 11:33
54
0
flask + MySQL-python 创建 webapp 应用

0 - python 用自带的 wgsi 也可以创建 web 服务 1)建立 hello.py 内容如下 # hello.py def application(environ, start_response): start_response('200 OK', [('Content-Type', 'text/html...

2018/03/12 21:18
17
0
webapp

http://baike.baidu.com/link?url=X8ZP9MwvvHP7prb6uDplwYBftWJdTkfqXd0AJrt7LGz_twlvCknJM1vz-KjuEI6veE3nbvt_Hrnm8Y7y70_m4q http://baike.baidu.com/link?url=PJLQUK40fXP_XnYuyfWDJ1eQT6...

2016/06/18 11:26
10
0
如何使用Python的Flask和谷歌app Engine来构建一个web app

前言 如果您想在很短的时间内使用Python构建web应用程序,那么Flask是一个非常好的选择。Flask是一个小而强大的web框架。它也很容易学习和简单的代码。 在本教程中,我将向您展示如何使用API...

2020/05/07 14:00
17
0
webapp 与sass

webapp 与sass

2016/06/14 01:28
68
0
webapp基本概念

webapp基本概念

2015/08/19 10:14
17
0
keras

The First Column The Second Column sqeue = sqeue(Input=sqeue.input, output=predictions) bug bug:cv2.imshow() categorical_crossentropy categorical_crossentropy weight_decay:权衰量...

2019/05/17 21:31
135
0

没有更多内容

加载失败,请刷新页面

返回顶部
顶部