def fetch_data(self, idx): sample = {k: self.ds[k][idx] for k in self.ds.keys()} from human_body_prior.train.vposer_smpl import VPoser sample['pose_matrot'] = VPoser.aa2matrot(sample['pose'].view( [1, 1, -1, 3])).view(1, -1) return sample
def fetch_data(self, idx): data = {k: self.ds[k][idx] for k in self.ds.keys()} pose = data.pop('pose') data['pose_aa'] = pose.view(1,52,3)[:,1:22] if 'pose_matrot' not in data.keys(): data['pose_matrot'] = VPoser.aa2matrot(data['pose_aa'][np.newaxis]).view(1,-1,9) else: data['pose_matrot'] = data['pose_matrot'].view(1,52,9)[:,1:22] return data
def test_aa2matrot(self): aa = np.random.randn(10, 3) cv2_matrot = [] for id in range(aa.shape[0]): cv2_matrot.append(cv2.Rodrigues(aa[id:id + 1])[0]) cv2_matrot = np.array(cv2_matrot).reshape(-1, 9) vposer_matrot = c2c(VPoser.aa2matrot(torch.tensor(aa))).reshape(-1, 9) self.assertAlmostEqual( np.square((vposer_matrot - cv2_matrot)).sum(), 0.0)
def test_matrot2aa(self): np.random.seed(100) aa = np.random.randn(10, 3) matrot = c2c(VPoser.aa2matrot(torch.tensor(aa))).reshape(-1, 9) cv2_aa = [] for id in range(matrot.shape[0]): cv2_aa.append(cv2.Rodrigues(matrot[id].reshape(3, 3))[0]) cv2_aa = np.array(cv2_aa).reshape(-1, 3) vposer_aa = c2c(VPoser.matrot2aa(torch.tensor(matrot))).reshape(-1, 3) self.assertAlmostEqual(np.square((vposer_aa - cv2_aa)).sum(), 0.0)
def fetch_data(self, idx): ''' This an exampl of augmenting the data fields. Furthermore, one can add random noise to data fields here as well. There should be a match between returning dictionary field names and the one in AMASS_ROW. :param idx: :return: ''' sample = {k: self.ds[k][idx] for k in self.ds.keys()} from human_body_prior.train.vposer_smpl import VPoser sample['pose_matrot'] = VPoser.aa2matrot(sample['pose'].view( [1, 1, -1, 3])).view(1, -1) return sample