Created
July 17, 2018 12:04
-
-
Save datitran/e7cb1bc762135e1350d34761731d447f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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