yinguobing / cnn-facial-landmark

Training code for facial landmark detection based on deep convolutional neural network.
MIT License
626 stars 182 forks source link

KeyError: "The name 'input_image_tensor:0' refers to a Tensor which does not exist. #56

Open abdou31 opened 5 years ago

abdou31 commented 5 years ago

I try to used landmark_video.py to draw landmarks of my own model. When I test frozen_model_inference.py that you give, it works ( but not with good performance the video is too slow ), but the important thing that it works. When I try to test frozen_mode_inference.py produced and generated with .ckpts files of my own model. I get this error :

KeyError: "The name 'input_image_tensor:0' refers to a Tensor which does not exist. The operation, 'input_image_tensor', does not exist in the graph."

How can solve this it?? Thanks

abdou31 commented 5 years ago

Actually, I solved this problem by changing input_image_tensor:0 with input_to_float:0 after review landmark.py, I have seen that the input node ( layer ) is input_to_float:0. I faced other problem and I fixed it by adding this line ( solution refers to stackoverflow website Please try to update landmark_video.py: `

        face_img = cv2.resize(face_img, (INPUT_SIZE, INPUT_SIZE))
        face_img = cv2.cvtColor(face_img, cv2.COLOR_BGR2RGB)
        img=np.array(face_img).reshape(1,128,128,3) # update here
        landmarks = detect_marks(img, sess, detection_graph)`

Now, I face two problems: 1/ The performance of the model ( bad result ) => I know that due to false annotation and prediction in 3D. 2/ The slowly of the video => I think that the problem due to the number of batchs. I tried to increase the number of batchs ( from 1 to 32 for example ) but I get this problem:

img=np.array(face_img).reshape(32,128,128,3) ValueError: cannot reshape array of size 49152 into shape (32,128,128,3)

Did you have any idea how can I solve this issue?

ZlaaM commented 5 years ago

@abdou31 try this def detect_marks(image_np, sess, detection_graph): """Detect marks from image"""

Get result tensor by its name.

logits_tensor = detection_graph.get_tensor_by_name('logits/BiasAdd:0')

predictions = sess.run(logits_tensor,
                       {'input_to_float:0': image_np})

# Actual detection.

# Convert predictions to landmarks.
marks = np.array(predictions).flatten()
marks = np.reshape(marks, (-1, 2))

return marks
abdou31 commented 5 years ago

Okay, I will try this but I have a question. Did this project support detection with 3D ( z coordinates )?