Closed anujgupta82 closed 6 years ago
This is resolved. This is a very well researched problem. The solution is given in Issue #1
def load_model():
global model
model = ResNet50(weights="imagenet")
# this is key : save the graph after loading the model
global graph
graph = tf.get_default_graph()
While predicting, use the same graph
with graph.as_default():
preds = model.predict(image)
#... etc
Congrats on resolving the issue @anujgupta82 and thank you for sharing the relevant links just in case others have this problem.
This works for the developmental server, but it does not work if you want to use a standalone wsgi container e.g. gunicorn, gevent, uwsgi.
Also there is another solution if you just want to get the model to work. Essentially just get rid of the load_model() function. run_keras_server.txt
The above works on the standalone wsgi containers but not on the Flask developmental server ??? Is there a solution that works for all cases?
Hey @johncleveland, please don't copy and paste the same question into multiple threads. Your question has already been addressed and answered in #1. Thanks.
I cloned this code with
When I send a request I am getting
Below is complete screen shot of the error
Any suggestions will be of great help