I wanted to try out how to send an ML model to production. Turns out it is a bit more complicated, but this is how to run it on local machine. Still want to learn how to dockerize it all but okay this is a start.
This repository presents a method of taking a ML model and deploying it as an API, showing the easiest way to take an deep learning model to production. I also take advantage of Test Driven Development (TDD) by writing acceptance and developer tests throughout, which can be seen in testing/.
I started with the assumption that the Keras API was inherently well tested (thus out of the scope of our requirements) and that Flask was equally so, therefore the simple test cases found in tests.robot
- Submit Photo
- Send a Photo using a POST request
- App receives Photo
- Photo sent = photo received
- Model correctly predicts sample photos
- Model receives photo
- Model makes prediction
- Prediction = expected
which contain the high level keywords also in tests.robot
- Supply Image
- Detection
using the low level keywords written in TestLibrary.py
- send_img
- post_img
- image_analysis
The results are then stored in the files log.html, output.xml, and report.html also located in testing/
The API consists of two actions (hence simple). One responds to the get request of the URL (in this case the host machine) and provides a basic form to uplaod a file for precition. The second action is a POST method that takes the uploaded file (upon the submit button being pressed) and returns a JSON (I said simple) response of the top 5 predictions from the network.
Note: The Model is not loaded every time a prediction is requested, instead I load the model upon the main execution of the file simple_keras_api_server.py right before the server is started.
The main focus of this API was to learn how to load a keras model efficiently, serve it using Flask, and make predictions returnable (JSON) to the client.
More can be read about RESNET here on the keras website.
The following python libraries are used:
numpy, gevent, flask, pillow, keras, tensorflow, robotframework
- COVID Model
- Add ML assisted diagnosis of COVID from patient's lung xrays concept
- Write tests for including it into the system
- Training Model
- Loading Model
- Model receives/predicts xrays
- Front-end revamp
- Add separate report folder within testing/
- Tests
- What happens when no file is submitted
- Too large of file
- Not an Image on request