falcon-prediction-app icon indicating copy to clipboard operation
falcon-prediction-app copied to clipboard

Simple Machine Learning Web API Example with Falcon

trafficstars

Machine Learning Web API Example with Falcon

Simple example that uses Falcon to create a deep learning RESTful prediction service (simple convnet trained on the MNIST dataset). Locust is used for load testing. Gunicorn as WSGI HTTP Server and nginx as HTTP proxy server.

Getting Started

Run prediction service

docker build -t falcon-prediction-app .
docker run -p 127.0.0.1:8000:8081 falcon-prediction-app

Test prediction service

(echo -n '{"image": "'; base64 src/tests/data/four_test.png; echo '"}') |
curl -i -H "Content-Type: application/json" -d @- http://127.0.0.1:8000/predict

Run unittests

pytest -s src/tests/

Run load testing

locust -f load_testing.py --host=http://127.0.0.1:8000

Note: Access the Locust GUI via http://localhost:8089/ to start load testing.

Dependencies

  • Python conda environment (install with conda env create --file environment.yml)
  • Gunicorn
  • Falcon
  • Keras
  • Tensorflow
  • Pillow
  • Locust

Copyright

See LICENSE for details.