From f0159d8ea47cd3d08b177229ce56f8565d4e632a Mon Sep 17 00:00:00 2001 From: Hunor Laczko Date: Fri, 16 Sep 2022 16:47:07 +0000 Subject: [PATCH] verify low res quality --- verify_low_res.py | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 verify_low_res.py diff --git a/verify_low_res.py b/verify_low_res.py new file mode 100644 index 0000000..95b58e0 --- /dev/null +++ b/verify_low_res.py @@ -0,0 +1,69 @@ +import os +os.environ["CUDA_VISIBLE_DEVICES"] = "1" + +import tqdm +import numpy as np +import plotly.graph_objects as go + +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/uv_static_filled_32' + mask = np.load('custom_utils/mask_256x512.npy') + F = np.load("custom_utils/smpl_faces.npy") + uv2mesh = UV2Mesh(res=256) + + frames = os.listdir(folder) + visited = set() + meshes = [] + count = 0 + + for frame in tqdm.tqdm(frames): + id, _ = frame.split('.') + frame_nr = '' + + # 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, id + '' + frame_nr + '.npz')); uv_unposed_no_shape = uv_unposed_no_shape['uv_static_filled'] + mesh_mask = np.load(os.path.join('/home/workspace/local-data/train_100/mesh_mask', id + '.npy')) + mesh = uv2mesh(uv_unposed_no_shape[np.newaxis,:,:,:])[0].numpy() + mesh, faces = _maskFaces(mesh, F, mesh_mask) + x = mesh + # x[:, 2] += 1 * (i + 1) + x[:, 1] += 0.5 * count + meshes.append(go.Mesh3d( + # 8 vertices of a cube + x=x[:,0], + y=x[:,1], + z=x[:,2], + # i, j and k give the vertices of triangles + i = faces[:,0], + j = faces[:,1], + k = faces[:,2] + )) + count += 1 + + if count > 40: + break + + + + fig = go.Figure(data=meshes) + fig.update_layout(scene_aspectmode='manual', scene_aspectratio=dict(x=1, y=count/2-1, z=1)) + fig.update_layout( + scene = dict( + xaxis = dict(nticks=4, range=[-1,1],), + yaxis = dict(nticks=4, range=[-1,count/2+1],), + zaxis = dict(nticks=4, range=[-1,1],),) + ) + + fig.show() + + print() +