In the following notebook released by tf for pose classification: 3doc/tutorials/pose_classification.ipynb#scrollTo=HgQMdfeT65Z5
There exists a function, “get_center_point” that takes in a 17,2 tensor, and two-row indices. I’m assuming the point is to calculate the center point given two landmarks, however why is axis = 1 in the tf.gather() call. If I want to calculate the centerpoint of the LeftHip and RightHip, left_bodypart = 11, and right_bodypart = 12. Thus tf.gather(landmarks, 11, axis = 1) will either error in older tf versions or return a tensor of zeros right? Shouldn’t axis = 0 here? But if so, the rest of the code errors.
Hi @Dhruv_Ahuja
Thank you for using TensorFlow,
In the context of this code, get_center_point() function takes (N,2) tensor, that is landmarks, and the body_part number, so, here when we use axis = 0, then we are getting values which are across columns, are x, y coordinates rather than when we use axis = 1, then we get values either x or y coordinates of a landmark.
for example :
landmarks = tf.constant([
[0.0, 0.0], # Landmark 0
[0.1, 0.2], # Landmark 1
[0.2, 0.3], # Landmark 2
[0.4, 0.5], # Landmark 3 (Left Hip)
[0.6, 0.7] # Landmark 4 (Right Hip)
])
left = tf.gather(landmarks, 3, axis=0) # Outputs [0.4, 0.5] (row 3)
right = tf.gather(landmarks, 4, axis=0) # Outputs [0.6, 0.7] (row 4)
Thank you