I have a Keras model and a Flask app. I am using my Keras model within the Flask app itself. When I try to use these well-known functions of Keras (ie. predict, save, fit), the program stucks at that point. However when I extract the related files from the Flask app and run the program standalone which is completely purified from Flask, it works fine.
Please note that load and summary functions works in both way. So I check if the model is loaded correctly and yes even if it is in the Flask app, works properly and I can observe the summary of the model which is correct.
Then I made some research and found these links which are the closest to the solution but none of them could really solve my problem:
https://dref360.github.io/keras-web/
https://www.pythonanywhere.com/forums/topic/12720/#id_post_49248
Related to these links the problem may be this below:
The problem is that Tensorflow Sessions cannot be shared across processes. So you cannot have a web server that has a reference to your model and call methods on it. Also, Keras will not tell you what’s going on, because it doesn’t know. In fact, Tensorflow will just block without error.
I want to use the model in my procution app staying with Flask. How can I use the model in the Flask app without this problem?
Please leave a comment if you need any code block.
I have tried to seperate the model functions from the Flask app following the threading pattern mentioned in the link that I have provided.