mediapipe
mediapipe copied to clipboard
Output model tensorflow
I convert model tensorflow lite into tensorflow. And i predict the pose estimate at image. Output is tensor of shape [39 5]. I need only key points of body and coordinates. I get slice [0:33, 0:3] and i want it to draw at image. How i can do that? The range output model strange, it is not [0-1], i try to put this is at image with shape 256*256, but it is not correct. I try to use Sigmoid for predict tensor, but get strange values, example: [[1.000+00, 6.526e-29, 0], [1.000+00, 8.36e-31, 0], [0.0000009, 0.99999991] Thanks
Normalization not help, i convert prediction array to range [0; 1] by divide 255 and get this:
Hi @watermellon2018, Is it implemented through python, Javascript or others? Could you please help me in reproducing the same with complete steps at our end. Thank you!
@kuaashish It is implemented through python. I use tensorflow model pose_landmark_heavy
. I pass image into model and get tensor with shape 1, 195, make reshape (39, 5), get only 33 points and 2 (x, y) coordinates, then i flip horizontal and normalized it
Code:
TFLITE_FILE_PATH = 'model_float32.pb' # i convert tflite into tf
graph_def = tf.compat.v1.GraphDef()
with tf.io.gfile.GFile(TFLITE_FILE_PATH, 'rb') as f:
graph_def.ParseFromString(f.read())
tf.import_graph_def(graph_def, name='')
input_node = 'input_1:0'
output_layer = 'Identity:0'
with tf.compat.v1.Session() as sess:
prob_tensor = sess.graph.get_tensor_by_name(output_layer)
predictions = sess.run(prob_tensor, {input_node: [input_data] })
predictions = predictions.reshape((1, 39, 5))
print(np.min(predictions[0, :, 0:2]), np.max(predictions[0, :, 0:2]))
predictions = predictions[:, 0:33, 0:2][0]
predictions[:, 0] = (256 - predictions[:, 0]) / 256
predictions[:, 1] = predictions[:, 1] / 256
Hi @watermellon2018, Have you looked at this closed issue #1701 and comment. Thank you!
@kuaashish Thank you. I added normalize image and post proccessing of the prediction, it a little bit help. But when i merged prediction from Python API and prediction from Tensorflow model. I get this (blue - python api / green - tensorflow):
@watermellon2018 Good jobs, can you share your codes? The picture seems to be from the bgr channel.
Hi @watermellon2018, This issue to more related to tensorflow. Could you please raise this issue into tensorflow repo. Thank you!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.
Closing as stale. Please reopen if you'd like to work on this further.