MTCNN-Tensorflow
MTCNN-Tensorflow copied to clipboard
Get error: fc1/alphas not found in checkpoint when i run python one_image_test.py
when i test the model by issue follow command ,i get the error:
python one_image_test.py
error message as follow:
(virtualenv) ➜ test git:(master) ✗ python one_image_test.py
(1, ?, ?, 3)
(1, ?, ?, 10)
(1, ?, ?, 10)
(1, ?, ?, 16)
(1, ?, ?, 32)
(1, ?, ?, 2)
(1, ?, ?, 4)
(1, ?, ?, 10)
2017-11-23 14:25:45.140042: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
../data/MTCNN_model/PNet_landmark/PNet-18
restore models' param
(256, 24, 24, 3)
(256, 22, 22, 28)
(256, 11, 11, 28)
(256, 9, 9, 48)
(256, 4, 4, 48)
(256, 3, 3, 64)
(256, 576)
(256, 128)
(256, 2)
(256, 4)
(256, 10)
../data/MTCNN_model/RNet_landmark/RNet-14
restore models' param
2017-11-23 14:25:46.070231: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key fc1/alphas not found in checkpoint
Traceback (most recent call last):
File "one_image_test.py", line 32, in <module>
RNet = Detector(R_Net, 24, batch_size[1], model_path[1])
File "../Detection/detector.py", line 25, in __init__
saver.restore(self.sess, model_path)
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1666, in restore
{self.saver_def.filename_tensor_name: save_path})
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 889, in run
run_metadata_ptr)
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1120, in _run
feed_dict_tensor, options, run_metadata)
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1317, in _do_run
options, run_metadata)
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1336, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.NotFoundError: Key fc1/alphas not found in checkpoint
[[Node: save/RestoreV2_13 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2_13/tensor_names, save/RestoreV2_13/shape_and_slices)]]
Caused by op u'save/RestoreV2_13', defined at:
File "one_image_test.py", line 32, in <module>
RNet = Detector(R_Net, 24, batch_size[1], model_path[1])
File "../Detection/detector.py", line 17, in __init__
saver = tf.train.Saver()
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1218, in __init__
self.build()
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1227, in build
self._build(self._filename, build_save=True, build_restore=True)
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1263, in _build
build_save=build_save, build_restore=build_restore)
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 751, in _build_internal
restore_sequentially, reshape)
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 427, in _AddRestoreOps
tensors = self.restore_op(filename_tensor, saveable, preferred_shard)
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 267, in restore_op
[spec.tensor.dtype])[0])
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/ops/gen_io_ops.py", line 1021, in restore_v2
shape_and_slices=shape_and_slices, dtypes=dtypes, name=name)
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2956, in create_op
op_def=op_def)
File "/Users/chenxingyi/work/virtualenv/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1470, in __init__
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
NotFoundError (see above for traceback): Key fc1/alphas not found in checkpoint
[[Node: save/RestoreV2_13 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2_13/tensor_names, save/RestoreV2_13/shape_and_slices)]]
(virtualenv) ➜ test git:(master) ✗
And my environment is macOS Sierra 10.12.6: Python 2.7.13 tensorflow (1.4.0) tensorflow-tensorboard (0.4.0rc3) virtualenv (15.1.0) numpy (1.13.3) pip (9.0.1) easydict (1.7)
https://github.com/AITTSMD/MTCNN-Tensorflow/commit/519b453975a8dbdc7b0eecdb4f8735b7b6c80d46 check the above commit for this project and try undo this commit and run your code again.
@zhulihuacmss my code is the latest, I think maybe the problem is that the code be updated but the model file is not updated, Because when i load the model file(in the data/MTCNN_model directory) and print all the node name, I can not find "fc1/alphas";
@cxy200927099 exactly. Original code had ReLU layers after fully connected instead of PReLU (as in original paper) and that is the reason for missing alpha in current model.
@ilyanelken Do you know how to solve this problem? And do you have the latest pretrained model file?
@cxy200927099 I am still working on improving landmark detection, and it will take some time. In order to solve it you have to train model from scratch before you are running one_image_test.py.
@ilyanelken Ok,I understand and thank you
@cxy200927099 @ilyanelken That is my mistake.When I trained mtcnn,The activation function I used is relu in fc layers.If you want to use my trained model,change prelu to relu.
i met the same mistake, how can i solve this?
@yaxiongchi change prelu in fc layer to relu
我遇到了同样的问题,请问具体的去哪里改变
@WangJianXin666 把全连接层中的激活函数由prelu 改成relu
@AITTSMD 我用Prelu重新训练模型,然后保存。之后加载模型还是出现这个问题。似乎Prelu的超参不能被Save()下来一样。这是什么原因呢?