Skip to content

Keras REST API with Flask RESTPlus, Swagger, Gunicorn and Docker

License

Notifications You must be signed in to change notification settings

vvives/keras-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keras REST API with Flask RESTPlus, Swagger, Gunicorn and Docker

This project is a simple boilerplate for deploying Keras models with Flask RESTPlus, Swagger, Gunicorn and Docker.

Prerequisites

  • Docker

Installing

  1. Clone this repository in your local system and navigate to root folder.
$ git clone repository-url
  1. Navigate to docker folder and run.
$ cd docker
$ docker-compose up

Run

This will expose on http://127.0.0.1:5000 the Swagger API docs and that's all!

Usage

When the project is fully deployed, you will get a single endpoint. This endpoint will allow to predict house prices by using a simple Keras Boston house pricing regression model loaded from a HDF5 file.

House pricing

This endpoint will predict a house price by using the following input data.

You must provide all these parameters as float numbers:

  • crim: Per capita crime rate by town.
  • zn: Proportion of residential land zoned for lots over 25,000 sq.ft.
  • indus: Proportion of non-retail business acres per town.
  • chas: Charles River dummy variable (= 1 if tract bounds river; 0 otherwise).
  • nox: Nitric oxides concentration (parts per 10 million).'
  • rm: Average number of rooms per dwelling.
  • age: Proportion of owner-occupied units built prior to 1940.
  • dis: Weighted distances to five Boston employment centres.
  • rad: Index of accessibility to radial highways.
  • tax: Full-value property-tax rate per $10,000.
  • ptratio: Pupil-teacher ratio by town.
  • b: 1000(Bk - 0.63)^2 where Bk is the proportion of blacks by town.
  • lstat: Percentage of lower status of the population.

The endpoint will return the predicted value as a median value of owner-occupied homes in one thousand dollars.

The response with default input data:

{
    "medv": 453.8800964355469, 
    "description": "Median value of owner-occupied homes in $1000's.", 
}

Built With

  • Flask - Web framework
  • Flask-RESTPlus - Flask REST Extensions
  • Swagger - API Documentation
  • Keras - Deep learning framework
  • Gunicorn - Python WSGI HTTP Server for UNIX
  • Docker - Platform as a Service (PaaS) to deliver software in containers

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Víctor Vives - Main developer - vvives

See also the list of contributors who participated in this project.

License

Project License

This project is licensed under the MIT License - see the LICENSE.md file for details