Breaking News

Deploy a Keras Classification model on Docker with Flask

After training, next step is to deploy model for use in production. There are different ways to do it, Docker is one of them. Docker is widely used for deployment of almost any application.

What is Docker?

Docker is a set of coupled software-as-a-service and platform-as-a-service products that use operating-system-level virtualization to develop and deliver software in packages called containers. The software that hosts the containers is called Docker Engine. It was first started in 2013 and is developed by Docker, Inc.

How to install

Windows

For Windows, Docker has a pretty simple installer. Which is a GUI and just requires some clicks to install docker on your machine. It can be downloaded from Docker's official site.

https://hub.docker.com/editions/community/docker-ce-desktop-windows
Ubuntu

For ubuntu, it requires come commands for right version of your Ubuntu.
For Ubuntu 16.04.
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04
For Ubuntu 18.04
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04


Flask

We need a web server which can accept incoming data and respond to user. So, in this tutorial, we will create a flask server app which accepts an image and returns label of that image. We will use a classification model. Which is trained on 5 classes of flowers. You can change it to your model by just replacing model and labels file.

from flask import Flask, render_template, Response
import cv2
app = Flask(__name__)

@app.route('/')
def index():
    return render_template('App is Working')

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=80, debug=True)

No comments