Speed up Keras Model Prediction Load Times
I was able to get to work like this without flask or django. Just using default http.server in python
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
import sys
import pandas as pd
from keras.models import load_model
from urllib.parse import urlparse
model = load_model('model.h5')

class S(BaseHTTPRequestHandler):
    def _set_response(self):
        self.send_response(200)
        self.send_header('Content-type', 'text/html')
        self.end_headers()

    def do_GET(self):
        query = urlparse(self.path).query
        params = dict(qc.split(&quot;=&quot;) for qc in query.split(&quot;&amp;&quot;))
        X = pd.read_csv(params[&quot;input&quot;]).values
        prediction = model.predict(X)
        pd.DataFrame(prediction).to_json(params[&quot;output&quot;])
        self._set_response()
        self.wfile.write(&quot;Processed&quot;.encode('utf-8'))

def run(server_class=HTTPServer, handler_class=S, port=8080):
    logging.basicConfig(level=logging.INFO)
    server_address = ('', port)
    httpd = server_class(server_address, handler_class)
    logging.info('Starting httpd...\n')
    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass
    httpd.server_close()
    logging.info('Stopping httpd...\n')

if __name__ == '__main__':
    from sys import argv

    if len(argv) == 2:
        run(port=int(argv[1]))
    else:
        run()

Trigger Server using
python3.6 predict_server.py 8000

API like
http://ip/localhost:8000/?input=predict_scaled.csv&amp;output=prediction.json