4

I am using keras model to predict something and used flask-restplus to make this as a REST service. so far everything is working fine when I run the server with python app.py command.

But I wanted to run this through gunicorn and nginx (gunicorn -b 0.0.0.0:5000 --error-logfile - -w 4 --access-logfile - --preload wsgi:app -t 900 --preload --reload), every configuration is correct since It was working fine with the normal endpoint but predict service is not working.

I have investigated and found that my code is stuck at prediction level p = model.predict(np.array(X))

can some one tell me what could be the issue.

Reddi Mohan
  • 251
  • 2
  • 13
  • 1
    It has to do with Tensoflow graph and it is fixed – Reddi Mohan Jul 03 '18 at 08:10
  • For the sake of others who find this question, could you provide any detail about what the issue was, and how you fixed it? – ukosteopath Jul 12 '18 at 17:53
  • 1
    I just had to create a tensor graph and use this for predicting `import tensorflow as tf` `graph = tf.get_default_graph()` `with graph.as_default(): #predict here` – Reddi Mohan Jul 16 '18 at 11:06

2 Answers2

2

Running TF2 alpha 0 with Keras, the issue has been the --preload flag for me. I suspect the session/graph being the issue. Not an expert though.

Felix
  • 21
  • 2
0

For the same problem occurring on more general platforms a solution has been given here - "uninstalling keras and tensorflow and then reinstalling them at the same version" or trying other versions.

NeStack
  • 1,739
  • 1
  • 20
  • 40