# Deploy Keras Model with Flask as Web App in 10 Minutes
[![GPLv3 license](https://img.shields.io/badge/License-GPLv3-blue.svg)](http://perso.crans.org/besson/LICENSE.html)
[![](https://img.shields.io/badge/python-3.5%2B-green.svg)]()
![Contributions Welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)
A pretty and customizable web app to deploy your DL model with ease
<a href="https://www.buymeacoffee.com/fing" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png" alt="Buy Me A Coffee"></a>
## Getting Started in 10 Minutes
- Clone this repo
- Install requirements
- Run the script
- Go to http://localhost:5000
- Done! :tada:
:point_down: Screenshot:
<p align="center">
<img src="https://user-images.githubusercontent.com/5097752/71063354-8caa1d00-213a-11ea-86eb-879238887c1f.png" height="420px" alt="">
</p>
## New Features :fire:
- 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](https://www.tensorflow.org/guide/keras) by default
- Upgrade Docker base image to Python 3 (it's 2020)
<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>
_If you need to use Python 2.x or TensorFlow 1.x, check out the [legacy](https://github.com/mtobeiyf/keras-flask-deploy-webapp/tree/legacy) snapshot_
------------------
## Run with Docker
With **[Docker](https://www.docker.com)**, you can quickly build and run the entire application in minutes :whale:
```shell
# 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.
```shell
# 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. :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.
<details>
<summary>Details</summary>
### Use your own model
Place your trained `.h5` file saved by `model.save()` under models directory.
Check the [commented code](https://github.com/mtobeiyf/keras-flask-deploy-webapp/blob/master/app.py#L37) in app.py.
### Use other pre-trained model
See [Keras applications](https://keras.io/applications/) for more available models such as DenseNet, MobilNet, NASNet, etc.
Check [this section](https://github.com/mtobeiyf/keras-flask-deploy-webapp/blob/master/app.py#L26) 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>
## Deployment
To deploy it for public use, you need to have a public **linux server**.
<details>
<summary>Details</summary>
### 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](https://flask.palletsprojects.com/en/1.1.x/deploying/wsgi-standalone/)
### 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;
}
}
```
</details>
## Future Plan
- [ ] Support detection and segmentation models
## More Resources
[Building a simple Keras + deep learning REST API](https://blog.keras.io/building-a-simple-keras-deep-learning-rest-api.html)
没有合适的资源?快使用搜索试试~ 我知道了~
keras-flask-deploy-webapp:漂亮简单的图像分类器应用模板。 在10分钟内使用Flask将您自己的训练模型...
共12个文件
py:2个
md:2个
html:2个
需积分: 11 6 下载量 24 浏览量
2021-02-05
00:24:45
上传
评论 1
收藏 22KB ZIP 举报
温馨提示
在10分钟内用Flask作为Web App部署Keras模型 一个漂亮且可自定义的Web应用程序,可轻松部署DL模型 10分钟入门 克隆此仓库 安装要求 运行脚本 转到 做完了! :party_popper: :backhand_index_pointing_down: 屏幕截图: 新的功能 :fire: 增强的,适合移动设备的UI 支持图像拖放 使用原始JavaScript,HTML和CSS。 删除jQuery和Bootstrap 默认情况下切换到TensorFlow 2.0和 将Docker基本映像升级到Python 3(2020年) 如果您需要使用Python 2.x或TensorFlow 1.x,请签出快照 与Docker一起运行 使用 ,您可以在数分钟内快速
资源详情
资源评论
资源推荐
收起资源包目录
keras-flask-deploy-webapp-master.zip (12个子文件)
keras-flask-deploy-webapp-master
models
README.md 66B
app.py 3KB
templates
index.html 1KB
base.html 2KB
Dockerfile 155B
util.py 656B
LICENSE 34KB
static
main.js 4KB
main.css 3KB
requirements.txt 102B
.gitignore 322B
README.md 4KB
共 12 条
- 1
八年一轮回
- 粉丝: 44
- 资源: 4727
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0