reafactor merge data little

This commit is contained in:
2022-10-07 21:59:07 +00:00
parent b2788778c5
commit 75164b1672
+36 -35
View File
@@ -155,24 +155,7 @@ if __name__ == '__main__':
ids = os.listdir(folder)[int(args.start):int(args.end)]
os.makedirs(os.path.join(output_folder), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'mesh_mask'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'mesh_static'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'uv_static'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'mesh_posed'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'mesh_body_posed'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'uv_posed'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'uv_body_posed'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'pose_shape'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'uv_mask'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'mesh_unposed'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'uv_unposed'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'mesh_unposed_no_shape'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'uv_unposed_no_shape'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'uv_shaped_body'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'uv_curvature'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'mesh_curvature'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'uv_posed_body_no_orient'), exist_ok=True)
os.makedirs(os.path.join(output_folder, 'mesh_posed_body_no_orient'), exist_ok=True)
# os.makedirs(os.path.join(output_folder, 'uv_shaped_body'), exist_ok=True)
for id in tqdm.tqdm(ids):
@@ -194,15 +177,17 @@ if __name__ == '__main__':
# continue
start = time.perf_counter()
offsets_static = sio.loadmat(os.path.join(folder, id, garment + '_offsets_static.mat'))['label'][:,:3]
body_static = sio.loadmat(os.path.join(garment_dir, 'info_body.mat'))['B']
mask = np.squeeze(sio.loadmat(os.path.join(garment_dir, garment + '_mask.mat'))['mask'].astype(bool))
verts_static = (body_static + offsets_static) * mask[:, np.newaxis]
assert verts_static.min() > -1 and verts_static.max() < 1
# offsets_static = sio.loadmat(os.path.join(folder, id, garment + '_offsets_static.mat'))['label'][:,:3]
# body_static = sio.loadmat(os.path.join(garment_dir, 'info_body.mat'))['B']
# mask = np.squeeze(sio.loadmat(os.path.join(garment_dir, garment + '_mask.mat'))['mask'].astype(bool))
# verts_static = (body_static + offsets_static) * mask[:, np.newaxis]
# dfassert verts_static.min() > -1 and verts_static.max() < 1
# os.makedirs(os.path.join(output_folder, 'mesh_static'), exist_ok=True)
# np.savez_compressed(os.path.join(output_folder, 'mesh_static', id + '.npz'), mesh_static=verts_static)
# os.makedirs(os.path.join(output_folder, 'uv_static'), exist_ok=True)
# uv_verts_static = np.load(os.path.join(folder, id, garment + '_offsets_static_uv.npy'))
# np.savez_compressed(os.path.join(output_folder, 'uv_static', id + '.npz'), uv_static=uv_verts_static)
@@ -210,58 +195,74 @@ if __name__ == '__main__':
# garment_folder_body = os.path.join(folder, id, 'body_posed_uv')
# garment_folder_body_mesh = os.path.join(folder, id, 'mesh_body_posed')
# os.makedirs(os.path.join(output_folder, 'mesh_mask'), exist_ok=True)
# shutil.copyfile(os.path.join(folder, id, garment + '_mask.npy'), os.path.join(output_folder, 'mesh_mask', id + '.npy'))
# os.makedirs(os.path.join(output_folder, 'mesh_posed'), exist_ok=True)
# garment_posed = readPC2(os.path.join(garment_dir, garment + '_registered.pc16'), True)['V']
# for i in range(garment_posed.shape[0]):
# np.savez_compressed(os.path.join(output_folder, 'mesh_posed', id + '_' + str(i) + '.npz'), mesh_posed=garment_posed[i,:,:] * mask[:, np.newaxis])
# os.makedirs(os.path.join(output_folder, 'mesh_body_posed'), exist_ok=True)
body_posed = readPC2(os.path.join(garment_dir, 'Body_posed.pc16'), True)['V']
# for i in range(body_posed.shape[0]):
# np.save(os.path.join(output_folder, 'mesh_body_posed', id + '_' + str(i) + '.npy'), body_posed[i,:,:])
# os.makedirs(os.path.join(output_folder, 'uv_posed'), exist_ok=True)
# for i in range(body_posed.shape[0]):
# shutil.copyfile(os.path.join(garment_folder_gt, garment + '_' + str(i) + '.npz'), os.path.join(output_folder, 'uv_posed', id + '_' + str(i) + '.npz'))
# os.makedirs(os.path.join(output_folder, 'uv_body_posed'), exist_ok=True)
# for i in range(body_posed.shape[0]):
# shutil.copyfile(os.path.join(garment_folder_body, garment + '_' + str(i) + '.npz'), os.path.join(output_folder, 'uv_body_posed', id + '_' + str(i) + '.npz'))
# os.makedirs(os.path.join(output_folder, 'pose_shape'), exist_ok=True)
# info = sio.loadmat(os.path.join(garment_dir, 'info.mat'))
# pose, shape, gender = info['poses'], info['shape'], info['gender']
# shape = np.squeeze(np.concatenate((shape, gender), axis=1))
# for i in range(body_posed.shape[0]):
# np.save(os.path.join(output_folder, 'pose_shape', id + '_' + str(i) + '.npy'), np.concatenate((pose[:, i], shape), axis=-1))
# os.makedirs(os.path.join(output_folder, 'uv_mask'), exist_ok=True)
# assert os.path.exists(os.path.join(folder, id, 'mask_uv.npy'))
# if not os.path.exists(os.path.join(output_folder, 'uv_mask', id + '.npz')):
# uv_mask = np.load(os.path.join(folder, id, 'mask_uv.npy'))
# np.savez_compressed(os.path.join(output_folder, 'uv_mask', id + '.npz'), uv_mask=uv_mask)
# uv_mask = np.load(os.path.join(folder, id, 'mask_uv.npy'))
# np.savez_compressed(os.path.join(output_folder, 'uv_mask', id + '.npz'), uv_mask=uv_mask)
# os.makedirs(os.path.join(output_folder, 'mesh_unposed'), exist_ok=True)
# for i in range(body_posed.shape[0]):
# shutil.copyfile(os.path.join(garment_dir, 'mesh_unposed', id + '_' + str(i) + '.npz'), os.path.join(output_folder, 'mesh_unposed', id + '_' + str(i) + '.npz'))
# os.makedirs(os.path.join(output_folder, 'uv_unposed'), exist_ok=True)
# for i in range(body_posed.shape[0]):
# shutil.copyfile(os.path.join(garment_dir, 'uv_unposed', garment + '_' + str(i) + '.npz'), os.path.join(output_folder, 'uv_unposed', id + '_' + str(i) + '.npz'))
# os.makedirs(os.path.join(output_folder, 'mesh_unposed_no_shape'), exist_ok=True)
# for i in range(body_posed.shape[0]):
# shutil.copyfile(os.path.join(garment_dir, 'mesh_unposed_no_shape', id + '_' + str(i) + '.npz'), os.path.join(output_folder, 'mesh_unposed_no_shape', id + '_' + str(i) + '.npz'))
# os.makedirs(os.path.join(output_folder, 'uv_unposed_no_shape'), exist_ok=True)
# for i in range(body_posed.shape[0]):
# shutil.copyfile(os.path.join(garment_dir, 'uv_unposed_no_shape', garment + '_' + str(i) + '.npz'), os.path.join(output_folder, 'uv_unposed_no_shape', id + '_' + str(i) + '.npz'))
# for i in range(body_posed.shape[0]):
# shutil.copyfile(os.path.join(garment_dir, 'curvature_uv', garment + '_' + str(i) + '.npz'), os.path.join(output_folder, 'uv_curvature', id + '_' + str(i) + '.npz'))
os.makedirs(os.path.join(output_folder, 'uv_curvature'), exist_ok=True)
for i in range(body_posed.shape[0]):
shutil.copyfile(os.path.join(garment_dir, 'curvature_uv', garment + '_' + str(i) + '.npz'), os.path.join(output_folder, 'uv_curvature', id + '_' + str(i) + '.npz'))
# mesh_curvature = np.load(os.path.join(garment_dir, 'curvature_label_6_25.npy'))
# for i in range(body_posed.shape[0]):
# np.savez_compressed(os.path.join(output_folder, 'mesh_curvature', id + '_' + str(i) + '.npz'), mesh_curvature=mesh_curvature[i])
os.makedirs(os.path.join(output_folder, 'mesh_curvature'), exist_ok=True)
mesh_curvature = np.load(os.path.join(garment_dir, 'curvature_label_6_25.npy'))
for i in range(body_posed.shape[0]):
np.savez_compressed(os.path.join(output_folder, 'mesh_curvature', id + '_' + str(i) + '.npz'), mesh_curvature=mesh_curvature[i])
# shutil.copyfile(os.path.join(folder, id, 'uv_shaped_body.npz'), os.path.join(output_folder, 'uv_shaped_body', id + '.npz'))
for i in range(body_posed.shape[0]):
shutil.copyfile(os.path.join(garment_dir, 'uv_posed_body_no_orient', garment + '_' + str(i) + '.npz'), os.path.join(output_folder, 'uv_posed_body_no_orient', id + '_' + str(i) + '.npz'))
# os.makedirs(os.path.join(output_folder, 'uv_posed_body_no_orient'), exist_ok=True)
# for i in range(body_posed.shape[0]):
# shutil.copyfile(os.path.join(garment_dir, 'uv_posed_body_no_orient', garment + '_' + str(i) + '.npz'), os.path.join(output_folder, 'uv_posed_body_no_orient', id + '_' + str(i) + '.npz'))
for i in range(body_posed.shape[0]):
shutil.copyfile(os.path.join(garment_dir, 'mesh_posed_body_no_orient', id + '_' + str(i) + '.npz'), os.path.join(output_folder, 'mesh_posed_body_no_orient', id + '_' + str(i) + '.npz'))
# os.makedirs(os.path.join(output_folder, 'mesh_posed_body_no_orient'), exist_ok=True)
# for i in range(body_posed.shape[0]):
# shutil.copyfile(os.path.join(garment_dir, 'mesh_posed_body_no_orient', id + '_' + str(i) + '.npz'), os.path.join(output_folder, 'mesh_posed_body_no_orient', id + '_' + str(i) + '.npz'))
pass