uv conversion acceleration
This commit is contained in:
+17
-11
@@ -448,7 +448,7 @@ def test(verts, faces, values):
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-f", "--folder", help = "end of range", default='/home/workspace/data/dataset/train_skirt_25_2')
|
||||
parser.add_argument("-f", "--folder", help = "end of range", default='/home/workspace/data/dataset/train')
|
||||
parser.add_argument("-s", "--start", help = "start of range", default=0)
|
||||
parser.add_argument("-e", "--end", help = "end of range", default=10)
|
||||
parser.add_argument("-n", "--name", help = "end of range", default='lhunor')
|
||||
@@ -503,7 +503,7 @@ if __name__ == '__main__':
|
||||
if not os.path.isdir(garment_dir):
|
||||
continue
|
||||
|
||||
# if os.path.exists(os.path.join(folder, id, 'gt_uv')):
|
||||
# if os.path.exists(os.path.join(folder, id, 'uv_posed_body_no_orient')):
|
||||
# continue
|
||||
|
||||
garments = [f.replace('.pc16','') for f in os.listdir(garment_dir) if f.find('_') == -1 and f != 'info.mat' and not f.endswith('.obj')]
|
||||
@@ -526,19 +526,21 @@ if __name__ == '__main__':
|
||||
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))
|
||||
# body = readPC2(os.path.join(folder, id, 'Body_posed.pc16'), True)['V']
|
||||
gt = readPC2(os.path.join(folder, id, garment + '_registered.pc16'), True)['V']
|
||||
body = readPC2(os.path.join(folder, id, 'Body_posed.pc16'), True)['V']
|
||||
# gt = readPC2(os.path.join(folder, id, garment + '_registered.pc16'), True)['V']
|
||||
# curvature = np.load(os.path.join(folder, id, 'curvature_label_' + curvature_label_type + '.npy'))
|
||||
# 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])]
|
||||
mesh_unposed_no_shape = np.stack([mesh_unposed_no_shape[i]['mesh_unposed_no_shape'] 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])]
|
||||
# mesh_unposed_no_shape = np.stack([mesh_unposed_no_shape[i]['mesh_unposed_no_shape'] for i in range(gt.shape[0])])
|
||||
# body_no_orient = [np.load(os.path.join(folder, id, 'mesh_posed_body_no_orient', id + '_' + str(i) + '.npz')) for i in range(gt.shape[0])]
|
||||
# body_no_orient = np.stack([body_no_orient[i]['mesh_posed_body_no_orient'] for i in range(gt.shape[0])])
|
||||
mesh_unposed_no_shape_one_hot = [np.load(os.path.join(folder, id, 'mesh_unposed_no_shape_one_hot', id + '_' + str(i) + '.npz')) for i in range(body.shape[0])]
|
||||
mesh_unposed_no_shape_one_hot = np.stack([mesh_unposed_no_shape_one_hot[i]['mesh_unposed_no_shape'] for i in range(body.shape[0])])
|
||||
|
||||
|
||||
verts_static = (body_static + offsets_static) # * mask[:, np.newaxis]
|
||||
verts_dynamic = gt
|
||||
# verts_dynamic = gt
|
||||
|
||||
# TODO: check if have to mask out non garment vertices or not? are they the same vertices erpeated many times? if remove, have to interpolate from almost nothing?
|
||||
|
||||
@@ -608,7 +610,8 @@ if __name__ == '__main__':
|
||||
# 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 = 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).astype(np.float32)
|
||||
# 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)
|
||||
print(time.perf_counter() - start)
|
||||
|
||||
@@ -637,10 +640,13 @@ if __name__ == '__main__':
|
||||
# for i in range(uv_unposed.shape[0]):
|
||||
# np.savez_compressed(os.path.join(folder, id, 'uv_unposed', garment + '_' + str(i) + '.npz'), uv_unposed=uv_unposed[i, :, :, :])
|
||||
|
||||
os.makedirs(os.path.join(folder, id, 'uv_unposed_no_shape'), exist_ok=True)
|
||||
for i in range(uv_unposed_no_shape.shape[0]):
|
||||
np.savez_compressed(os.path.join(folder, id, 'uv_unposed_no_shape', garment + '_' + str(i) + '.npz'), uv_unposed_no_shape=uv_unposed_no_shape[i, :, :, :])
|
||||
# os.makedirs(os.path.join(folder, id, 'uv_unposed_no_shape'), exist_ok=True)
|
||||
# for i in range(uv_unposed_no_shape.shape[0]):
|
||||
# np.savez_compressed(os.path.join(folder, id, 'uv_unposed_no_shape', garment + '_' + str(i) + '.npz'), uv_unposed_no_shape=uv_unposed_no_shape[i, :, :, :])
|
||||
|
||||
os.makedirs(os.path.join(folder, id, 'uv_unposed_no_shape_one_hot'), exist_ok=True)
|
||||
for i in range(uv_unposed_no_shape_one_hot.shape[0]):
|
||||
np.savez_compressed(os.path.join(folder, id, 'uv_unposed_no_shape_one_hot', garment + '_' + str(i) + '.npz'), uv_unposed_no_shape=uv_unposed_no_shape_one_hot[i, :, :, :])
|
||||
|
||||
# os.makedirs(os.path.join(folder, id, 'uv_shaped_body'), exist_ok=True)
|
||||
# np.savez_compressed(os.path.join(folder, id, 'uv_shaped_body.npz'), uv_shaped_body=uv_shaped_body)
|
||||
|
||||
Reference in New Issue
Block a user