nyoki-mtl / keras-facenet

Facenet implementation by Keras2
553 stars 217 forks source link

Error Converting Tensorflow model into keras #4

Closed sharma-ji closed 6 years ago

sharma-ji commented 6 years ago

There are 4 files, .pb, .meta, .index, ckpt-250000.data-00000-of-00001. How to convert it using your notebook?? also I'm running Anaconda on Windows 10

nyoki-mtl commented 6 years ago

@sharma-ji Please tell me the error message. You just have to specify the filename ckpt-250000 to use ckpt-250000.data-00000-of-00001 in tf.train.NewCheckpointReader.

sharma-ji commented 6 years ago

`DataLossError Traceback (most recent call last)

in () ----> 1 extract_tensors_from_checkpoint_file('F:\\models\\20170512-110547\\model-20170512-110547.ckpt-250000.data-00000-of-00001', npy_weights_dir) in extract_tensors_from_checkpoint_file(filename, output_folder) 23 24 def extract_tensors_from_checkpoint_file(filename, output_folder): ---> 25 reader = tf.train.NewCheckpointReader(filename) 26 27 for key in reader.get_variable_to_shape_map(): ~\AppData\Local\conda\conda\envs\vision\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in NewCheckpointReader(filepattern) 223 with errors.raise_exception_on_not_ok_status() as status: 224 from tensorflow.python.util import compat --> 225 return CheckpointReader(compat.as_bytes(filepattern), status) 226 227 NewCheckpointReader._tf_api_names = ['train.NewCheckpointReader'] ~\AppData\Local\conda\conda\envs\vision\lib\site-packages\tensorflow\python\framework\errors_impl.py in __exit__(self, type_arg, value_arg, traceback_arg) 471 None, None, 472 compat.as_text(c_api.TF_Message(self.status.status)), --> 473 c_api.TF_GetCode(self.status.status)) 474 # Delete the underlying status object from memory otherwise it stays alive 475 # as there is a reference to status from this from the traceback due to DataLossError: Unable to open table file F:\models\20170512-110547\model-20170512-110547.ckpt-250000.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?` **I get the above error**
nyoki-mtl commented 6 years ago

@sharma-ji Please try the code below. extract_tensors_from_checkpoint_file('F:\models\20170512-110547\model-20170512-110547.ckpt-250000', npy_weights_dir)

You should use '...ckpt-250000' instead of '...ckpt-250000.data-00000-of-00001'.

AkashSabir commented 5 years ago

Hi, I am trying to convert latest model from facenet repository from sandberg which is 20180408-102900. I am getting following error

ValueError: Layer weight shape (1792, 128) not compatible with provided weight shape (1792, 512)