The models in the TF Objection Detection Zoo have meta+ckpt file, Frozen.pb file, and Saved_model file.
I tried to use the meta+ckpt file to train further and also to extract some weights for particular tensors for research purpose. I see that the models don't have any trainable variables.
vars = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)
print(vars)
The above snippet gives an []
list. I also tried using the following.
vars = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES)
print(vars)
I again get an []
list.
How is this possible ? is the model stripped off the variables ? or are the tf.Variable(trainable=False)
? Where can I get meta+ckpt file with valid trainable variables. I specifically looking at SSD+mobilnet models
UPDATE:
Following is the code snippet I'm using for restoring.It inside a class since I am making a custom tool for some application.
def _importer(self):
sess = tf.InteractiveSession()
with sess.as_default():
reader = tf.train.import_meta_graph(self.metafile,
clear_devices=True)
reader.restore(sess, self.ckptfile)
def _read_graph(self):
sess = tf.get_default_session()
with sess.as_default():
vars = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)
print(vars)
UPDATE 2:
I also tried with the following snippet. Simple restoring style.
model_dir = 'ssd_mobilenet_v2/'
meta = glob.glob(model_dir+"*.meta")[0]
ckpt = meta.replace('.meta','').strip()
sess = tf.InteractiveSession()
graph = tf.Graph()
with graph.as_default():
with tf.Session() as sess:
reader = tf.train.import_meta_graph(meta,clear_devices=True)
reader.restore(sess,ckpt)
vari = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)
for var in vari:
print(var.name,"\n")
Th above code snippet also gives []
variable list