predictClass.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:hourglasstensorlfow 作者: wbenbihi 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号