start using pytables
This commit is contained in:
+50
-19
@@ -326,6 +326,7 @@ def get_shapedirs():
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-f", "--folder", help = "end of range", default='/home/workspace/data/dataset/test_skirt_ready_2')
|
||||
parser.add_argument("-x", "--extras", help = "end of range", default='/home/workspace/data/dataset/test_skirt_ready_2_extras')
|
||||
parser.add_argument("-s", "--start", help = "start of range", default=0)
|
||||
parser.add_argument("-e", "--end", help = "end of range", default=30000)
|
||||
parser.add_argument("-n", "--name", help = "end of range", default='lhunor')
|
||||
@@ -335,6 +336,9 @@ if __name__ == '__main__':
|
||||
# smpl = SMPL('FeatureLines/superSMPL')
|
||||
|
||||
folder = args.folder
|
||||
extras_folder = args.extras
|
||||
|
||||
os.makedirs(extras_folder, exist_ok=True)
|
||||
|
||||
print("skirt" if args.skirt == 1 else "not skirt")
|
||||
|
||||
@@ -387,7 +391,8 @@ if __name__ == '__main__':
|
||||
shapedirs = get_shapedirs()
|
||||
|
||||
use_no_orient = True
|
||||
data_to_convert = ['mesh_posed']
|
||||
no_shape = False
|
||||
data_to_convert = ['mesh_posed', 'mesh_unposed', 'mesh_static', 'mesh_curvature', 'body_posed']
|
||||
|
||||
for id in tqdm.tqdm(ids):
|
||||
|
||||
@@ -395,12 +400,27 @@ if __name__ == '__main__':
|
||||
garments = info['outfit']
|
||||
assert info['poses'].shape[1] <= 300
|
||||
|
||||
garment = garments[0]
|
||||
|
||||
mask = read_garment_mask(folder, id, garment)
|
||||
verts_static = read_garment_template(folder, id, garment, mask)
|
||||
body = read_posed_body(folder, id, info['poses'], use_no_orient)
|
||||
gt = read_posed_garment(folder, id, garment, mask=mask, shape=info['shape'])
|
||||
|
||||
if 'mesh_posed' in data_to_convert:
|
||||
mesh_posed = read_posed_garment(folder, id, garment, mask=mask, shape=info['shape'], poses=info['poses'], use_no_orient=use_no_orient, no_shape=no_shape)
|
||||
if 'mesh_unposed' in data_to_convert:
|
||||
mesh_unposed = read_unposed_garment(folder, id, garment, mask=mask, shape=info['shape'], no_shape=no_shape)
|
||||
if 'mesh_static' in data_to_convert:
|
||||
mesh_static = read_garment_template(folder, id, garment, mask)
|
||||
if 'mesh_curvature' in data_to_convert:
|
||||
mesh_curvature = compute_curvature(mesh_posed, F)
|
||||
if 'body_posed' in data_to_convert:
|
||||
body_posed = read_posed_body(folder, id, info['poses'], use_no_orient)
|
||||
|
||||
|
||||
# verts_static = read_garment_template(folder, id, garment, mask)
|
||||
# body = read_posed_body(folder, id, info['poses'], use_no_orient)
|
||||
# gt = read_posed_garment(folder, id, garment, mask=mask, shape=info['shape'], ...)
|
||||
# gt = readPC2(os.path.join(folder, id, garment + '_registered.pc16'), True)['V']
|
||||
curvature = np.stack([np.load(os.path.join(folder, f'mesh_curvature_{neighbourhood}_2', f'{id}_{i}.npz'))['mesh_curvature'] for i in range(frames_len)])
|
||||
# curvature = np.stack([np.load(os.path.join(folder, f'mesh_curvature_{neighbourhood}_2', f'{id}_{i}.npz'))['mesh_curvature'] for i in range(frames_len)])
|
||||
# mesh_unposed = [np.load(os.path.join(folder, id, 'mesh_unposed', id + '_' + str(i) + '.npz')) for i in range(gt.shape[0])]
|
||||
# mesh_unposed = np.stack([mesh_unposed[i]['mesh_unposed'] for i in range(gt.shape[0])])
|
||||
# mesh_unposed_no_shape = [np.load(os.path.join(folder, id, 'mesh_unposed_no_shape', id + '_' + str(i) + '.npz')) for i in range(gt.shape[0])]
|
||||
@@ -422,26 +442,37 @@ if __name__ == '__main__':
|
||||
|
||||
start = time.perf_counter()
|
||||
|
||||
|
||||
|
||||
uv_verts_static, garment_uv_mask, garment_uv_mask_border = convert_to_uv(uv_res, m2uv, uv_map, verts_static, neighbours=3, mask=mask, method='rbf', garment_uv_mask=None)
|
||||
uv_verts_static = uv_verts_static.astype(np.float32)
|
||||
# uv_body_static = convert_to_uv(uv_res, m2uv, uv_map, body_static, neighbours=3, mask=None, method='rbf', garment_uv_mask=None).astype(np.float32)
|
||||
# uv_body = convert_to_uv_batch(uv_res, m2uv, uv_map, body[:, :, :], neighbours=3, mask=None, method='rbf', garment_uv_mask=None, garment_uv_mask_border=garment_uv_mask_border).astype(np.float32)
|
||||
# uv_posed_body_no_orient = convert_to_uv_batch(uv_res, m2uv, uv_map, body_no_orient[:, :, :], neighbours=3, mask=None, method='rbf', garment_uv_mask=None, garment_uv_mask_border=garment_uv_mask_border).astype(np.float32)
|
||||
# uv_gt = convert_to_uv_batch(uv_res, m2uv, uv_map, gt[:, :, :], neighbours=3, mask=mask, method='rbf', garment_uv_mask=garment_uv_mask, garment_uv_mask_border=garment_uv_mask_border).astype(np.float32)
|
||||
uv_curvature = convert_to_uv_batch_label(uv_res, m2uv, uv_map, curvature[:, :], neighbours=3, mask=mask, method='nearest', garment_uv_mask=garment_uv_mask, garment_uv_mask_border=garment_uv_mask_border).astype(np.float32)
|
||||
# uv_unposed = convert_to_uv_batch(uv_res, m2uv, uv_map, mesh_unposed[:, :, :], neighbours=3, mask=mask, method='rbf', garment_uv_mask=garment_uv_mask, garment_uv_mask_border=garment_uv_mask_border).astype(np.float32)
|
||||
# uv_unposed_no_shape = convert_to_uv_batch(uv_res, m2uv, uv_map, mesh_unposed_no_shape[:, :, :], neighbours=3, mask=mask, method='rbf', garment_uv_mask=garment_uv_mask, garment_uv_mask_border=garment_uv_mask_border).astype(np.float32)
|
||||
# uv_unposed_no_shape_one_hot = convert_to_uv_batch(uv_res, m2uv, uv_map, mesh_unposed_no_shape_one_hot, neighbours=3, mask=mask, method='rbf', garment_uv_mask=garment_uv_mask, garment_uv_mask_border=garment_uv_mask_border, id=id)
|
||||
# uv_posed_no_orient = convert_to_uv_batch(uv_res, m2uv, uv_map, mesh_posed_no_orient, neighbours=3, mask=mask, method='rbf', garment_uv_mask=garment_uv_mask, garment_uv_mask_border=garment_uv_mask_border, id=id)
|
||||
# uv_shaped_body = convert_to_uv(uv_res, m2uv, uv_map, shaped_body, neighbours=3, mask=None, method='rbf', garment_uv_mask=None).astype(np.float32)
|
||||
|
||||
if 'mesh_posed' in data_to_convert:
|
||||
uv_posed = convert_to_uv_batch(uv_res, m2uv, uv_map, gt[:, :, :], neighbours=3, mask=mask, method='rbf', garment_uv_mask=garment_uv_mask, garment_uv_mask_border=garment_uv_mask_border).astype(np.float32)
|
||||
if 'mesh_unposed' in data_to_convert:
|
||||
uv_unposed = convert_to_uv_batch(uv_res, m2uv, uv_map, mesh_unposed[:, :, :], neighbours=3, mask=mask, method='rbf', garment_uv_mask=garment_uv_mask, garment_uv_mask_border=garment_uv_mask_border).astype(np.float32)
|
||||
if 'mesh_curvature' in data_to_convert:
|
||||
uv_curvature = convert_to_uv_batch_label(uv_res, m2uv, uv_map, curvature[:, :], neighbours=3, mask=mask, method='nearest', garment_uv_mask=garment_uv_mask, garment_uv_mask_border=garment_uv_mask_border).astype(np.float32)
|
||||
if 'body_posed' in data_to_convert:
|
||||
uv_body_posed = convert_to_uv_batch(uv_res, m2uv, uv_map, body_posed[:, :, :], neighbours=3, mask=None, method='rbf', garment_uv_mask=None, garment_uv_mask_border=garment_uv_mask_border).astype(np.float32)
|
||||
|
||||
print(time.perf_counter() - start)
|
||||
|
||||
|
||||
if 'mesh_static' in data_to_convert:
|
||||
# np.save(os.path.join(folder, id, garment + '_offsets_static_uv.npy'), uv_verts_static)
|
||||
# np.save(os.path.join(folder, id, 'mask_uv.npy'), garment_uv_mask)
|
||||
if 'mesh_posed' in data_to_convert:
|
||||
mesh_posed = read_posed_garment(folder, id, garment, mask=mask, shape=info['shape'], poses=info['poses'], use_no_orient=use_no_orient, no_shape=no_shape)
|
||||
if 'mesh_unposed' in data_to_convert:
|
||||
mesh_unposed = read_unposed_garment(folder, id, garment, mask=mask, shape=info['shape'], no_shape=no_shape)
|
||||
if 'mesh_curvature' in data_to_convert:
|
||||
mesh_curvature = compute_curvature(mesh_posed, F)
|
||||
if 'body_posed' in data_to_convert:
|
||||
# for i in range(uv_body_posed.shape[0]):
|
||||
# np.savez_compressed(os.path.join(folder, id, 'uv_body_posed', garment + '_' + str(i) + '.npz'), uv_body=uv_body[i, :, :, :])
|
||||
|
||||
|
||||
# start = time.perf_counter()
|
||||
# np.save(os.path.join(folder, id, garment + '_offsets_static_uv.npy'), uv_verts_static)
|
||||
# np.save(os.path.join(folder, id, 'body_static_uv.npy'), uv_body_static)
|
||||
# np.save(os.path.join(folder, id, 'mask_uv.npy'), garment_uv_mask)
|
||||
|
||||
# os.makedirs(os.path.join(folder, id, 'body_posed_uv'), exist_ok=True)
|
||||
# for i in range(uv_body.shape[0]):
|
||||
|
||||
Reference in New Issue
Block a user