GithubHelp home page GithubHelp logo

ansrivas / keras-rest-server Goto Github PK

View Code? Open in Web Editor NEW
65.0 9.0 22.0 22 KB

A very simple project to create a rest backend for serving a neural network model based on keras

License: MIT License

Python 100.00%
keras keras-models keras-rest-server rest-server

keras-rest-server's Introduction

Keras-rest-server: A simple rest implementation for loading and serving keras models


About:

This repository contains a very simple server implemented in flask which loads a a simple neural network model trained using Keras from its saved-weights and model.

In this example a very simple case of XOR is considered.

Getting started:


  1. Install Anaconda:
https://docs.continuum.io/anaconda/install
  1. Clone this repository
git clone https://github.com/ansrivas/keras-rest-server.git
cd keras-rest-server
  1. Create a new environment ( Change python=2 or python=3) and activate it:
conda create --name keras-server -y python=2
source activate keras-server
  1. Install all the dependencies:
conda env update -n keras-server  --file requirements.txt
  1. To remove the environment run:
conda remove -n keras-server --all -y

Usage


Run to generate pickle files:

python createpickles.py

Run the server (defaults to http://localhost:7171)

python server.py

Send a post request to this server to test your model

python client.py

keras-rest-server's People

Contributors

ansrivas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keras-rest-server's Issues

treat this as a classification problem, not regression

since youre predicting 1/0 (ie this is a classification example) for xor, you should use binary_crossentropy for your loss function, not mse.

model.compile(loss='mse', optimizer=rms)

additionally, you should use softmax as your activation function, not linear. this will return a predicted class (eg 0, 1) and not a real continuous value.

model.add(Activation('linear'))

Loading weights

Hi, I have not had much time to look trough your project but I really want to know some things:

  1. Does the model need to be reloaded into memory every time i call the endpoint? because with vgg16() that would mean loading 500mb into memory on every request.
  2. Can you run multiple models on the same application/server? Lets say I have 2 different weight files can I call them both?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.