I am currently working on a project where I get input data in a Web Interface and send it to a python script for processing.
The python script opens a session, restores the desired model and process the data.
This way, I have to restore the model every time the user sends new data. To restore the model takes though 1:40 min , which is a problem for me.
The solution I came up is to use two python script, one that creates a session and set it as default, then loads the model in that session and another script that gets the default session and default graph and processes the data. That way the model will be loaded it once and I will be able to use it for all user requests. The code looks smth like below..
Script 1 - loads the graph:
with tf.Graph().as_default():
sess = tf.Session()
with sess.as_default():
#Load the graph
#sess.close This is I leave in comments, to keep the session open
Script 2 - process data:
with tf.get_default_graph():
with tf.get_default_session() as sess:
#process data
This solution did not work, The information for the loaded model is lost.
I am to Tensorflow so I probably do it the wrong way. Can you someone help me with this? Any other suggestions are more than welcome.
Thank you!
Aucun commentaire:
Enregistrer un commentaire