Skip to content

Instantly share code, notes, and snippets.

@datitran
Created July 17, 2018 12:04
Show Gist options
  • Save datitran/e7cb1bc762135e1350d34761731d447f to your computer and use it in GitHub Desktop.
Save datitran/e7cb1bc762135e1350d34761731d447f to your computer and use it in GitHub Desktop.
import os
import falcon
from keras.models import load_model
from .predict import PredictResource
api = application = falcon.API()
def load_trained_model():
global model
model = load_model(os.path.join(os.path.dirname(__file__), 'model/cnn_model.h5'))
model._make_predict_function() # make keras thread-safe
return model
predict = PredictResource(model=load_trained_model())
api.add_route('/predict', predict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment