I train the model with the shell command:
python src/facenet_train.py \
--batch_size 15 \
--gpu_memory_fraction 0.25 \
--models_base_dir trained_model_2017_05_15_10_24 \
--pretrained_model trained_model_2017_05_15_10_24/20170515-121856/model-20170515-121856.ckpt-182784 \
--model_def models.nn2 \
--logs_base_dir logs \
--data_dir /data/user_set/training/2017_05_15_10_24 \
--lfw_pairs /data/user_set/lfw_pairs.txt \
--image_size 224 \
--lfw_dir /data/user_set/lfw \
--optimizer ADAM \
--max_nrof_epochs 1000 \
--learning_rate 0.00001
but i get error infomation like this when use my own trained model:
2017-05-17 14:23:05.448285: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. 2017-05-17 14:23:05.448318: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2017-05-17 14:23:05.448324: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2017-05-17 14:23:05.448329: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2017-05-17 14:23:05.448334: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. 2017-05-17 14:23:05.674872: I tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0 with properties: name: Quadro M4000 major: 5 minor: 2 memoryClockRate (GHz) 0.7725 pciBusID 0000:03:00.0 Total memory: 7.93GiB Free memory: 2.89GiB 2017-05-17 14:23:05.674917: I tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0 2017-05-17 14:23:05.674935: I tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0: Y 2017-05-17 14:23:05.674957: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Quadro M4000, pci bus id: 0000:03:00.0) Traceback (most recent call last): File "forward.py", line 21, in images_placeholder = tf.get_default_graph().get_tensor_by_name("input:0") File "/home/chen/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2563, in get_tensor_by_name return self.as_graph_element(name, allow_tensor=True, allow_operation=False) File "/home/chen/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2414, in as_graph_element return self._as_graph_element_locked(obj, allow_tensor, allow_operation) File "/home/chen/.pyenv/versions/anaconda3-4.2.0/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2456, in _as_graph_element_locked "graph." % (repr(name), repr(op_name))) KeyError: "The name 'input:0' refers to a Tensor which does not exist. The operation, 'input', does not exist in the graph."
get feature code:
import tensorflow as tf
import facenet
w_MODEL_PATH_='/home/chen/demo_dir/facenet_tensorflow_train/trained_model_2017_05_15_10_24/20170515-121856'
with tf.Graph().as_default():
with tf.Session() as sess:
# load the model
meta_file, ckpt_file = facenet.get_model_filenames(w_MODEL_PATH_)
facenet.load_model(w_MODEL_PATH_, meta_file, ckpt_file)
# print("model_path:", w_MODEL_PATH_,"meta_file:", meta_file,"ckpt_file:", ckpt_file)
# Get input and output tensors
# ops = tf.get_default_graph().get_operations()
#
# print(ops)
images_placeholder = tf.get_default_graph().get_tensor_by_name("input:0")
embeddings = tf.get_default_graph().get_tensor_by_name("embeddings:0")
phase_train_placeholder = tf.get_default_graph().get_tensor_by_name("phase_train:0")
image_size = images_placeholder.get_shape()[1]
embedding_size = embeddings.get_shape()[1]
# print(image_size)
paths = ['one.png', 'two.png']
# Run forward pass to calculate embeddings
images = facenet.load_data(paths, do_random_crop=False, do_random_flip=False, image_size=image_size,
do_prewhiten=True)
# print("images:", idx, images)
feed_dict = {images_placeholder: images, phase_train_placeholder: False}
# print(idx,"embeddings:", embeddings)
emb_array = sess.run(embeddings, feed_dict=feed_dict)
# print(idx, "emb_array:", emb_array)
print(emb_array)
I don't know how to use my own trained model, please help.