verify uv mask alignement

This commit is contained in:
2022-09-20 23:00:59 +00:00
parent 2572ae7788
commit aa1e7be0e6
+50
View File
@@ -0,0 +1,50 @@
# check if downscaled mask amtches the uv maps, not losing information
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "3"
import tqdm
import numpy as np
import plotly.graph_objects as go
import plotly.express as ex
from custom_utils.custom_utils import UV2Mesh, _maskFaces
# from custom_utils.custom_utils import UV2Mesh, maskFacesBatch, _maskFaces
if __name__ == '__main__':
folder = '/home/workspace/local-data/train_100'
mask = np.load('custom_utils/mask_256x512.npy')
F = np.load("custom_utils/smpl_faces.npy")
uv2mesh = UV2Mesh(res=256)
res = 32
res_modifier = '_' + str(res)
frames = os.listdir(os.path.join(folder, 'pose_shape'))
visited = set()
meshes = []
count = 0
for frame in tqdm.tqdm(frames):
id, frame_nr = frame.split('_')
frame_nr = frame_nr.split('.')[0]
if id in visited:
continue
visited.add(id)
print(id)
uv_unposed_no_shape = np.load(os.path.join(folder, 'uv_unposed_no_shape' + res_modifier, id + '_' + frame_nr + '.npz')); uv_unposed_no_shape = uv_unposed_no_shape['uv_unposed_no_shape']
uv_mask = np.load(os.path.join(folder, 'uv_mask' + res_modifier, id + '.npz')); uv_mask = uv_mask['uv_mask']
check_1 = uv_unposed_no_shape * uv_mask[:,:,np.newaxis]
check_2 = uv_unposed_no_shape * uv_mask[:,:,np.newaxis] - uv_unposed_no_shape
img = np.concatenate((uv_unposed_no_shape, np.tile(uv_mask[:,:,np.newaxis], [1,1,3]), check_1, check_2), axis=1)
ex.imshow(img).show()
print()
# WORKS!