Dear @jebstone and @conrad,
I am now almost sure that pythonanywhere is unable to run deep learning with Keras models.
I have spent the whole day debugging, and finally figured out why my above script works locally but not on pythonanywhere:
My script calls the Keras models' predict function
predictions = model.predict(img)
This takes 1-4 sec locally.
On pythonanywere, however, this starts but never finishes.
Some print() before each function blocks confirms that:
2018-12-02 09:20:43 entered predict image
2018-12-02 09:20:43 predict_image() entered
2018-12-02 09:20:43 image preprocessed
2018-12-02 09:20:46 Sun Dec 2 09:20:46 2018 - received message 1 from emperor
2018-12-02 09:20:46 ...gracefully killing workers...
2018-12-02 09:20:46 Gracefully killing worker 1 (pid: 44)..
So according to all threads in this forum, Keras with Tensorflow backend must be executed in single thread mode which I did successfully with the threads parameters set to 1.
@conrad @jebstone @giles :
Can you find a possible solution or at least a potential explanation why pyhtonanywhere cannot execute the Model.predict() ?
This is a strategically important question because I intended to teach deep learning in my graduate course with pythonanywhere. For students, it will be so much more fun to see deep learning run on a web server.
I guess there will be many who are attending to this question too. Would be great if you have a look.
Please do access my code on agilebean.pythonanywere.com.