def visualize_garment(garment_path, with_tex=True): # Load SMPL body for the garment path = split(garment_path)[0] garment_org_body = load_smpl_from_file(join(path, 'registration.pkl')) garment_org_body = Mesh(garment_org_body.v, garment_org_body.f) # Load unposed garment garment_unposed = Mesh(filename=gar_dict[garment_type][index]) garment_unposed.set_texture_image(join(path, 'multi_tex.jpg')) # Pose garments dat = pkl.load(open(join(path, 'registration.pkl'))) dat['gender'] = 'neutral' garment_posed = pose_garment(garment_unposed, vert_indices[garment_type], dat) garment_posed = remove_interpenetration_fast(garment_posed, garment_org_body) if with_tex: garment_posed.vt = garment_unposed.vt garment_posed.ft = garment_unposed.ft garment_posed.set_texture_image(join(path, 'multi_tex.jpg')) mvs = MeshViewers((1, 3), keepalive=True) mvs[0][2].set_background_color(np.array([1, 1, 1])) mvs[0][1].set_background_color(np.array([1, 1, 1])) mvs[0][0].set_background_color(np.array([1, 1, 1])) mvs[0][1].set_static_meshes([garment_org_body]) mvs[0][2].set_static_meshes([garment_org_body, garment_posed]) mvs[0][0].set_static_meshes([garment_unposed]) return
fts['naked'] = ft # Choose any garment type type_upper = 'TShirtNoCoat' type_lower = 'ShortPants' # # Randomly pick from the digital wardrobe # index_upper = np.random.randint(0, len(gar_dict[type_upper])) # index_lower = np.random.randint(0, len(gar_dict[type_lower])) # store their paths path_upper = './Multi-Garment_dataset/125611499279708' path_lower = './Multi-Garment_dataset/125611499279708' # Load SMPL body for the upper garment upper_garment_org_body = load_smpl_from_file( join(path_upper, 'registration.pkl')) upper_garment_org_body = Mesh(upper_garment_org_body.v, upper_garment_org_body.f) # Load SMPL body for the lower garment lower_garment_org_body = load_smpl_from_file( join(path_lower, 'registration.pkl')) lower_garment_org_body = Mesh(lower_garment_org_body.v, lower_garment_org_body.f) # Load unposed garment garment_unposed_upper = Mesh( filename='./Multi-Garment_dataset/125611499279708/TShirtNoCoat.obj') garment_unposed_upper.set_texture_image(join(path_upper, 'multi_tex.jpg')) garment_unposed_lower = Mesh(