Open munikarmanish opened 5 years ago
You need to use separate Tensorflow graphs when loading and using each model. If you are using Keras, you also need to use separate sessions. See:
import tensorflow as tf
graph1 = tf.Graph()
with graph1.as_default():
session1 = tf.Session()
with session1.as_default():
model1 = Detector('checkpoint1')
graph2 = tf.Graph()
with graph2.as_default():
session2 = tf.Session()
with session2.as_default():
model2 = Detector('checkpoint2')
with graph1.as_default():
with session1.as_default():
model1.predict(img)
with graph2.as_default():
with session2.as_default():
model2.predict(img)
Reference: https://stackoverflow.com/a/51290092
I tried loading two checkpoints as follows. However, loading only one (either) works fine.
System:
Basically, I need to load multiple checkpoints in memory and use one of them based on a parameter provided by the user.