def joints_pred_numpy(self, img, coord = 'hm', thresh = 0.2, sess = None):
""" Create Tensor for joint position prediction
NON TRAINABLE
TO CALL AFTER GENERATING GRAPH
Notes:
Not more efficient than Numpy, prefer Numpy for such operation!
"""
if sess is None:
hm = self.HG.Session.run(self.HG.pred_sigmoid , feed_dict = {self.HG.img: img})
else:
hm = sess.run(self.HG.pred_sigmoid , feed_dict = {self.HG.img: img})
joints = -1*np.ones(shape = (self.params['num_joints'], 2))
for i in range(self.params['num_joints']):
index = np.unravel_index(hm[0,:,:,i].argmax(), (self.params['hm_size'],self.params['hm_size']))
if hm[0,index[0], index[1],i] > thresh:
if coord == 'hm':
joints[i] = np.array(index)
elif coord == 'img':
joints[i] = np.array(index) * self.params['img_size'] / self.params['hm_size']
return joints
评论列表
文章目录