83 lines
2.9 KiB
Python
83 lines
2.9 KiB
Python
# check if upscaler is better then filling
|
|
import os
|
|
|
|
from models.upscaler import UpscalerBasic as Upscaler
|
|
os.environ["CUDA_VISIBLE_DEVICES"] = "3"
|
|
|
|
import tqdm
|
|
import numpy as np
|
|
import plotly.graph_objects as go
|
|
|
|
from custom_utils.custom_utils import UV2Mesh, _maskFaces, load_model
|
|
# from custom_utils.custom_utils import UV2Mesh, maskFacesBatch, _maskFaces
|
|
|
|
|
|
if __name__ == '__main__':
|
|
# folder = '/home/workspace/data/dataset/skirt_test'
|
|
folder = '/home/workspace/data/dataset/train_skirt_25_2'
|
|
mask = np.load('custom_utils/mask_256x512_skirt.npy')
|
|
F = np.load("custom_utils/smpl_faces_skirt.npy")
|
|
uv2mesh = UV2Mesh(res=256, is_skirt=True)
|
|
res = 32
|
|
res_modifier = '_' + str(res)
|
|
|
|
|
|
ids = os.listdir(os.path.join(folder))
|
|
visited = set()
|
|
meshes = []
|
|
count = 0
|
|
|
|
for id in tqdm.tqdm(ids):
|
|
garment_dir = os.path.join(folder, id)
|
|
|
|
if not os.path.isdir(garment_dir):
|
|
continue
|
|
|
|
# if os.path.exists(os.path.join(folder, id, 'gt_uv')):
|
|
# 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')]
|
|
# assert len (garments) == 1
|
|
if len (garments) != 1:
|
|
continue
|
|
garment = garments[0]
|
|
|
|
# id, frame_nr = frame.split('_')
|
|
# frame_nr = frame_nr.split('.')[0]
|
|
frame_nr = '0'
|
|
print(id)
|
|
uv_unposed_no_shape = np.load(os.path.join(folder, id, 'uv_unposed_no_shape', garment + '_' + frame_nr + '.npz')); uv_unposed_no_shape = uv_unposed_no_shape['uv_unposed_no_shape']
|
|
# uv_posed = np.load(os.path.join(folder, id, 'gt_uv', garment + '_' + frame_nr + '.npz')); uv_posed = uv_posed['uv_gt']
|
|
mesh_mask = np.load(os.path.join(folder, id, garment + '_mask.npy'))
|
|
uv_mask = np.load(os.path.join(folder, id, 'mask_uv.npy'))
|
|
|
|
# body_posed_uv = np.load(os.path.join(folder, id, 'body_posed_uv', garment + '_' + frame_nr + '.npz'))
|
|
# body_posed_uv = body_posed_uv['uv_body']
|
|
|
|
mesh = uv2mesh(uv_unposed_no_shape[np.newaxis,:,:,:]).numpy()[0]
|
|
# mesh = uv2mesh(body_posed_uv[np.newaxis,:,:,:]).numpy()[0]
|
|
|
|
mesh, faces = _maskFaces(mesh, F, mesh_mask)
|
|
# faces = F
|
|
x = mesh
|
|
meshes = [go.Mesh3d(
|
|
x=x[:,0],
|
|
y=x[:,2],
|
|
z=x[:,1],
|
|
i = faces[:,0],
|
|
j = faces[:,1],
|
|
k = faces[:,2]
|
|
),]
|
|
|
|
fig = go.Figure(data=meshes)
|
|
fig.update_layout(scene_aspectmode='manual', scene_aspectratio=dict(x=1, y=1, z=1))
|
|
fig.update_layout(
|
|
scene = dict(
|
|
xaxis = dict(nticks=4, range=[-1,1],),
|
|
yaxis = dict(nticks=4, range=[-1,1],),
|
|
zaxis = dict(nticks=4, range=[-1,1],),)
|
|
)
|
|
|
|
fig.show()
|
|
|
|
print() |