def load_smpl_from_file(file): dat = pkl.load(open(file, 'rb'), encoding='latin1') dp = SmplPaths(gender=dat['gender']) smpl_h = Smpl(dp.get_hres_smpl_model_data()) smpl_h.pose[:] = dat['pose'] smpl_h.betas[:] = dat['betas'] smpl_h.trans[:] = dat['trans'] return smpl_h
def pose_garment(garment, vert_indices, smpl_params): ''' :param smpl_params: dict with pose, betas, v_template, trans, gender ''' dp = SmplPaths(gender=smpl_params['gender']) smpl = Smpl(dp.get_hres_smpl_model_data()) smpl.pose[:] = 0 smpl.betas[:] = smpl_params['betas'] # smpl.v_template[:] = smpl_params['v_template'] offsets = np.zeros_like(smpl.r) offsets[vert_indices] = garment.v - smpl.r[vert_indices] smpl.v_personal[:] = offsets smpl.pose[:] = smpl_params['pose'] smpl.trans[:] = smpl_params['trans'] mesh = Mesh(smpl.r, smpl.f).keep_vertices(vert_indices) return mesh
return ret_posed_interp path = '/home/nathanbendich/MultiGarmentNetwork/transl8d_py3/clothes_objs/' all_scans = glob(path + '*') garment_classes = [ 'Pants', 'ShortPants', 'ShirtNoCoat', 'TShirtNoCoat', 'LongCoat' ] gar_dict = {} for gar in garment_classes: gar_dict[gar] = glob(join(path, '*', gar + '.obj')) if __name__ == '__main__': dp = SmplPaths() vt, ft = dp.get_vt_ft_hres() smpl = Smpl(dp.get_hres_smpl_model_data()) ## This file contains correspondances between garment vertices and smpl body fts_file = 'assets/garment_fts.pkl' vert_indices, fts = pkl.load(open(fts_file, 'rb'), encoding='latin1') fts['naked'] = ft ## Choose any garment type as source -BLB #garment_type = 'TShirtNoCoat' # 'TShirtNoCoat' was the original garment type entered by Bhatnagar, Mon Mar 2 23:17:29 EST 2020 -nxb. garment_type = 'Pants' index = np.random.randint(0, len( gar_dict[garment_type])) ## Randomly pick from the digital wardrobe path = split(gar_dict[garment_type][index])[0] garment_org_body_unposed = load_smpl_from_file( join(path, 'registration.pkl'))
ret_posed_interp.vt = garment.vt ret_posed_interp.ft = garment.ft ret_posed_interp.set_texture_image(garment_tex) return ret_posed_interp #=========================================================== #=========================================================== if __name__ == '__main__': #=========================================================== path = '/home/nathanbendich/MultiGarmentNetwork/assets/clothes_and_scans/Multi-Garment_dataset/125611512607128/' # mgn-3 GCloud VM, April 20, 2020 -nxb dp = SmplPaths() vt, ft = dp.get_vt_ft_hres() smpl = Smpl(dp.get_hres_smpl_model_data()) body = load_smpl_from_file(join(path, 'registration.pkl')) print("body.pose.shape : ") print(body.pose.shape) print("=" * 99) print("\n" * 2) body.pose[:] = 0 # angles are in radians: body.pose[5] = 0.5 # left leg body.pose[8] = -0.5 # right leg # NOTE: you can reshape the body here: #body.betas[:] = np.random.randn(10) *0.01 # 10 shape parameters body.betas[1] = -2.0