JDhyeok / flask-ml-model-api

Deploy deep learning model using Flask

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

falsk-ml-model-api

Deploy sentiment anaysis deep learning model using flask. It allows you using the result of model prediction through REST API

Installation

Source Code

$ git clone https://github.com/JDhyeok/falsk-ml-model-api.git

Project Setup/Start

Dependency

  • Docker (Optional)
  • Tensorflow
  • Keras
  • Python >= 3.x

Option1 - Local

  • Setup virtual environment

    $ virtualenv venv
  • Start python virtual environment

    $ .\venv\Script\activate
    # or source .\venv\Script\activate
  • Install dependencies

    $ pip install -r requirements
  • Start Flask server

    $ cd app
    $ flask run

Option2 - Docker

  • Build docker image

    $ docker-compose build
  • Start docker container

    $ docker-compose up

Request

You can use cURL examples below or use third party application such as PostMan.

  • api test

    $ curl http://localhost:5000/api
  • Predict sentiment score

    $ curl -X GET -H "Content-Type: application/json" --data '{"contents":"It is the best movie i've ever seen in my whole life"}' http://localhost:5000/api/predict
  • Response JSON example

    {
        sentiment: "Positive"
        score: 95.1245
    }

Ref.

http://ai.stanford.edu/~amaas/papers/wvSent_acl2011.pdf

https://www.kaggle.com/lakshmi25npathi/sentiment-analysis-of-imdb-movie-reviews

About

Deploy deep learning model using Flask

License:MIT License


Languages

Language:Python 86.9%Language:Dockerfile 13.1%