Facenet: what input does --pretrained_model argument takes?

Created on 22 May 2019  路  3Comments  路  Source: davidsandberg/facenet

First of all thank you @davidsandberg for providing us with facenet
i tried giving the argument --pretrained_model 20180408-102900/model-20180408-102900.ckpt-90

but it threw an error

InvalidArgumentError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Assign requires shapes of both tensors to match. lhs shape= [1] rhs shape= [10575]
[[node save/Assign_490 (defined at src/train_softmax.py:184) ]]

how do i solve this?

Most helpful comment

You have to modify the pretrained model load at line 200
if pretrained_model:
print('Restoring pretrained model: %s' % pretrained_model)
saver.restore(sess, pretrained_model)

to
if args.pretrained_model:
print('Restoring pretrained model: %s' % args.pretrained_model)
ckpt = tf.train.get_checkpoint_state(args.pretrained_model)
if ckpt and ckpt.model_checkpoint_path:
saver.restore(sess, ckpt.model_checkpoint_path)

All 3 comments

how do i load a pretrained model into train-softmax.py?

You have to modify the pretrained model load at line 200
if pretrained_model:
print('Restoring pretrained model: %s' % pretrained_model)
saver.restore(sess, pretrained_model)

to
if args.pretrained_model:
print('Restoring pretrained model: %s' % args.pretrained_model)
ckpt = tf.train.get_checkpoint_state(args.pretrained_model)
if ckpt and ckpt.model_checkpoint_path:
saver.restore(sess, ckpt.model_checkpoint_path)

thankyou @thelastfunction
just now figured out those lines we're taken form facenet.py... thank you so much.

but this raises a new doubt in my mind that @davidsandberg stated that --pretrained_model argument is only for resuming the training and the number of classes has to be equal.

what if i load a pretrained model and add few more classes and resume training.... what would happen to the accuracy when the model is dumped?

Was this page helpful?
0 / 5 - 0 ratings