add pose verification and filtering to preprocess

This commit is contained in:
2022-10-07 21:59:30 +00:00
parent 75164b1672
commit 165fff9ec4
+33 -3
View File
@@ -1,4 +1,6 @@
import os
from custom_utils.supersmpl_io import readPC2
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
import sys
@@ -28,6 +30,9 @@ def create_no_orient_body(folder):
if not os.path.isdir(os.path.join(folder, id)):
continue
if os.path.exists(os.path.join(folder, id, 'mesh_posed_body_no_orient')):
continue
info = sio.loadmat(os.path.join(folder, id, 'info.mat'))
pose, shape, gender = info['poses'], info['shape'], info['gender']
@@ -114,6 +119,9 @@ def create_no_shape_unposed(folder):
garment_dir = os.path.join(folder, id)
if not os.path.isdir(garment_dir):
continue
if os.path.exists(os.path.join(folder, id, 'mesh_unposed_no_shape')):
continue
info = sio.loadmat(os.path.join(folder, id, 'info.mat'))
@@ -173,14 +181,36 @@ def gather_ids(folder, file_name):
f.write('\n'.join(to_print))
def verify_poses(folder):
ids = os.listdir(folder)
for id in tqdm.tqdm(ids):
if not os.path.isdir(os.path.join(folder, id)):
continue
garments = [f.replace('_registered.pc16','') for f in os.listdir(os.path.join(folder, id)) if f.endswith('_registered.pc16') and not f.startswith('Combined')]
assert len (garments) == 1
info = sio.loadmat(os.path.join(folder, id, 'info.mat'))
poses = info['poses']
verts = readPC2(os.path.join(folder, id, garments[0] + '_registered.pc16'), True)['V']
# print(id)
# assert type(poses) == np.ndarray and poses.shape[0] == 72 and poses.shape[1] == verts.shape[0], 'mv ' + os.path.join(folder, id) + ' /home/workspace/data/dataset/invalid/'
if not (type(poses) == np.ndarray and poses.shape[0] == 72 and poses.shape[1] == verts.shape[0]):
shutil.move(os.path.join(folder, id), '/home/workspace/data/dataset/invalid/')
print(id)
if __name__ == '__main__':
src_folder = '/home/workspace/data/dataset/train_skirt'
src_folder = '/home/workspace/data/dataset/test_skirt' #cloth3d_skirt
# src_folder = r'D:\Work\Dataset\validation_2'
dest_folder = '/home/workspace/data/dataset/validation'
create_no_orient_body(src_folder)
# create_no_shape_unposed(src_folder)
# create_no_orient_body(src_folder)
create_no_shape_unposed(src_folder)
# check_if_skirt(src_folder)
# gather_ids(src_folder, 'ids/test_non_skirt_ids.txt')
# verify_poses(src_folder)