update downscale to output non filled

This commit is contained in:
2022-09-20 22:57:14 +00:00
parent 494ceaa276
commit c26ce887ef
+36 -15
View File
@@ -45,9 +45,11 @@ def downscale_uv_maps_posed_body(folder, type, size: int):
for frame in tqdm.tqdm(frames): for frame in tqdm.tqdm(frames):
id, _ = frame.split('_') id, _ = frame.split('_')
img = np.load(os.path.join(folder, type, frame)); img = img['uv_posed_body_no_orient_filled'] img = np.load(os.path.join(folder, type + '_filled', frame)); img = img['uv_posed_body_no_orient_filled']
mask = np.load(os.path.join(folder, 'uv_mask' + '_' + str(size), id + '.npz')); mask = mask['uv_mask']
down = tf.image.resize(img, size=(size, int(size/2)), method=tf.image.ResizeMethod.LANCZOS5) down = tf.image.resize(img, size=(size, int(size/2)), method=tf.image.ResizeMethod.LANCZOS5)
np.savez_compressed(os.path.join(folder, type + '_' + str(size), frame), uv_posed_body_no_orient_filled = down) down = down * mask[:,:,np.newaxis]
np.savez_compressed(os.path.join(folder, type + '_' + str(size), frame), uv_posed_body_no_orient = down)
def downscale_uv_maps_curv(folder, type, size): def downscale_uv_maps_curv(folder, type, size):
@@ -57,9 +59,11 @@ def downscale_uv_maps_curv(folder, type, size):
for frame in tqdm.tqdm(frames): for frame in tqdm.tqdm(frames):
id, _ = frame.split('_') id, _ = frame.split('_')
img = np.load(os.path.join(folder, type, frame)); img = img['uv_curvature_filled'] img = np.load(os.path.join(folder, type + '_filled', frame)); img = img['uv_curvature_filled']
down = cv2.resize(img, (int(size/2), size), interpolation=cv2.INTER_NEAREST) mask = np.load(os.path.join(folder, 'uv_mask' + '_' + str(size), id + '.npz')); mask = mask['uv_mask']
np.savez_compressed(os.path.join(folder, type + '_' + str(size), frame), uv_curvature_filled = down) down = tf.image.resize(img[:,:,tf.newaxis], size=(size, int(size/2)), method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
down = np.squeeze(down) * mask[:,:]
np.savez_compressed(os.path.join(folder, type + '_' + str(size), frame), uv_curvature = down)
@@ -70,10 +74,11 @@ def downscale_uv_maps_unposed(folder, type, size):
for frame in tqdm.tqdm(frames): for frame in tqdm.tqdm(frames):
id, _ = frame.split('_') id, _ = frame.split('_')
img = np.load(os.path.join(folder, type, frame)); img = img['uv_unposed_no_shape_filled'] img = np.load(os.path.join(folder, type + '_filled', frame)); img = img['uv_unposed_no_shape_filled']
mask = np.load(os.path.join(folder, 'uv_mask' + '_' + str(size), id + '.npz')); mask = mask['uv_mask']
down = tf.image.resize(img, size=(size, int(size/2)), method=tf.image.ResizeMethod.LANCZOS5) down = tf.image.resize(img, size=(size, int(size/2)), method=tf.image.ResizeMethod.LANCZOS5)
np.savez_compressed(os.path.join(folder, type + '_' + str(size), frame), uv_unposed_no_shape_filled = down) down = down * mask[:,:,np.newaxis]
np.savez_compressed(os.path.join(folder, type + '_' + str(size), frame), uv_unposed_no_shape = down)
def downscale_uv_maps_static(folder, type, size): def downscale_uv_maps_static(folder, type, size):
@@ -83,18 +88,34 @@ def downscale_uv_maps_static(folder, type, size):
for frame in tqdm.tqdm(frames): for frame in tqdm.tqdm(frames):
id, _ = frame.split('.') id, _ = frame.split('.')
img = np.load(os.path.join(folder, type, frame)); img = img['uv_static_filled'] img = np.load(os.path.join(folder, type + '_filled', frame)); img = img['uv_static_filled']
mask = np.load(os.path.join(folder, 'uv_mask' + '_' + str(size), id + '.npz')); mask = mask['uv_mask']
down = tf.image.resize(img, size=(size, int(size/2)), method=tf.image.ResizeMethod.LANCZOS5) down = tf.image.resize(img, size=(size, int(size/2)), method=tf.image.ResizeMethod.LANCZOS5)
np.savez_compressed(os.path.join(folder, type + '_' + str(size), frame), uv_static_filled = down) down = down * mask[:,:,np.newaxis]
np.savez_compressed(os.path.join(folder, type + '_' + str(size), frame), uv_static = down)
def downscale_uv_maps_mask(folder, type, size):
os.makedirs(os.path.join(folder, type + '_' + str(size)), exist_ok=True)
frames = os.listdir(os.path.join(folder, type))
for frame in tqdm.tqdm(frames):
id, _ = frame.split('.')
img = np.load(os.path.join(folder, type, frame)); img = img['uv_mask'].astype(np.float32)
down = tf.image.resize(img[:,:,tf.newaxis], size=(size, int(size/2)), method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
down = np.squeeze(down.numpy().astype(bool))
np.savez_compressed(os.path.join(folder, type + '_' + str(size), frame), uv_mask = down)
if __name__ == '__main__': if __name__ == '__main__':
size = 128 size = 32
downscale_uv_maps_static(folder='/home/workspace/local-data/train_100', type='uv_static_filled', size=size) # downscale_uv_maps_mask(folder='/home/workspace/local-data/train_100', type='uv_mask', size=size)
downscale_uv_maps_unposed(folder='/home/workspace/local-data/train_100', type='uv_unposed_no_shape_filled', size=size) downscale_uv_maps_static(folder='/home/workspace/local-data/train_100', type='uv_static', size=size)
downscale_uv_maps_curv(folder='/home/workspace/local-data/train_100', type='uv_curvature_filled', size=size) downscale_uv_maps_unposed(folder='/home/workspace/local-data/train_100', type='uv_unposed_no_shape', size=size)
downscale_uv_maps_posed_body(folder='/home/workspace/local-data/train_100', type='uv_posed_body_no_orient_filled', size=size) downscale_uv_maps_curv(folder='/home/workspace/local-data/train_100', type='uv_curvature', size=size)
downscale_uv_maps_posed_body(folder='/home/workspace/local-data/train_100', type='uv_posed_body_no_orient', size=size)
print() print()