save
This commit is contained in:
+44
-35
@@ -41,13 +41,13 @@ from custom_utils.smpl import SMPL
|
||||
from convert_to_uv_api import convert_to_uv_api
|
||||
from models.upscaler import UpscalerBasicConv as Upscaler
|
||||
from postprocessing import fix_collision
|
||||
from models.pyramid_model_optimized import Pyramid
|
||||
# from models.pyramid_model_optimized import Pyramid
|
||||
|
||||
# from configs.config_abl_overfit_dress_var_3 import config as config_main
|
||||
# from configs.config_abl_overfit_jumpsuit_2 import config as config_main
|
||||
# from configs.config_cvae_curv import config as config_curv
|
||||
# from configs.iccv.config_abl_all_skirt_var import config as config_main
|
||||
from configs.iccv.config_abl_skin_var import config as config_main
|
||||
from configs.iccv.config_abl_all_skirt import config as config_main
|
||||
from configs.iccv.config_cvae_curv import config as config_curv
|
||||
# from models.cvae_model_overfit_jumpsuit import CVAE
|
||||
from models.cvae_model import CVAENew as CVAE
|
||||
@@ -296,52 +296,54 @@ def sampling_example(frame, camera, nr=15):
|
||||
mask = batch['mesh_mask'][0].numpy().astype(bool)
|
||||
_, faces = _maskFaces(np.zeros((14475, 3)), F, mask)
|
||||
|
||||
noise = tf.random.normal(shape=(nr, 8, 4, 128))
|
||||
out = model.sample(tf.tile(batch['uv_static'], [nr,1,1,1]), tf.tile(batch['uv_body_posed'], [nr,1,1,1]), tf.tile(batch['uv_curvature'], [nr,1,1,1]), tf.tile(batch['uv_mask'], [nr,1,1]), noise)
|
||||
# out,_,_ = model([tf.tile(batch['uv_unposed'], [nr,1,1,1]), tf.tile(batch['uv_static'], [nr,1,1,1]), tf.tile(batch['uv_body_posed'], [nr,1,1,1]), tf.tile(batch['uv_curvature'], [nr,1,1,1]), tf.tile(batch['uv_mask'], [nr,1,1])], training=False)
|
||||
# noise = tf.random.normal(shape=(nr, 8, 4, 128))
|
||||
# out = model.sample(tf.tile(batch['uv_static'], [nr,1,1,1]), tf.tile(batch['uv_body_posed'], [nr,1,1,1]), tf.tile(batch['uv_curvature'], [nr,1,1,1]), tf.tile(batch['uv_mask'], [nr,1,1]), noise)
|
||||
# # out,_,_ = model([tf.tile(batch['uv_unposed'], [nr,1,1,1]), tf.tile(batch['uv_static'], [nr,1,1,1]), tf.tile(batch['uv_body_posed'], [nr,1,1,1]), tf.tile(batch['uv_curvature'], [nr,1,1,1]), tf.tile(batch['uv_mask'], [nr,1,1])], training=False)
|
||||
|
||||
if config_main['use_skinning']:
|
||||
posed_mesh = [get_posed_mesh(uv, batch['pose_shape'], batch['mesh_body_posed'], mask) for uv in tf.unstack(out)]
|
||||
else:
|
||||
posed_mesh = [uv2mesh(uv[tf.newaxis,:,:,:]) for uv in tf.unstack(out)]
|
||||
gt_mesh = batch['mesh_posed'][0].numpy()[mask, :]
|
||||
# if config_main['use_skinning']:
|
||||
# posed_mesh = [get_posed_mesh(uv, batch['pose_shape'], batch['mesh_body_posed'], mask) for uv in tf.unstack(out)]
|
||||
# else:
|
||||
# posed_mesh = [uv2mesh(uv[tf.newaxis,:,:,:]) for uv in tf.unstack(out)]
|
||||
# gt_mesh = batch['mesh_posed'][0].numpy()[mask, :]
|
||||
|
||||
body = batch['mesh_body_posed'][0].numpy()
|
||||
posed_mesh_fixed = [postprocess(mesh, body, faces, mask, do_smoothing=True) for mesh in posed_mesh]
|
||||
# posed_mesh_fixed = [mesh[0].numpy()[mask, :] for mesh in posed_mesh]
|
||||
# posed_mesh_fixed = [postprocess(mesh, body, faces, mask, do_smoothing=True) for mesh in posed_mesh]
|
||||
# # posed_mesh_fixed = [mesh[0].numpy()[mask, :] for mesh in posed_mesh]
|
||||
|
||||
# error = [np.sqrt(((gt_mesh-m) ** 2).sum(-1)).mean() for m in posed_mesh_fixed]
|
||||
# # error = [np.sqrt(((gt_mesh-m) ** 2).sum(-1)).mean() for m in posed_mesh_fixed]
|
||||
|
||||
# row_sampling = []
|
||||
# fig = plot_fixed(gt_mesh, body, faces, camera)
|
||||
# fig.write_image('/tmp/exp_temp_7.png')
|
||||
# img = cv2.imread('/tmp/exp_temp_7.png')
|
||||
# row_sampling.append(img[:, 100:700, :])
|
||||
# for mesh in posed_mesh_fixed:
|
||||
# fig = plot_fixed(mesh, body, faces, camera)
|
||||
# fig.write_image('/tmp/exp_temp_7.png')
|
||||
# img = cv2.imread('/tmp/exp_temp_7.png')
|
||||
# row_sampling.append(img[:, 100:700, :])
|
||||
# # row_sampling = []
|
||||
# # fig = plot_fixed(gt_mesh, body, faces, camera)
|
||||
# # fig.write_image('/tmp/exp_temp_7.png')
|
||||
# # img = cv2.imread('/tmp/exp_temp_7.png')
|
||||
# # row_sampling.append(img[:, 100:700, :])
|
||||
# # for mesh in posed_mesh_fixed:
|
||||
# # fig = plot_fixed(mesh, body, faces, camera)
|
||||
# # fig.write_image('/tmp/exp_temp_7.png')
|
||||
# # img = cv2.imread('/tmp/exp_temp_7.png')
|
||||
# # row_sampling.append(img[:, 100:700, :])
|
||||
|
||||
|
||||
# custom_imshow(np.concatenate(row_sampling, axis=1)).show()
|
||||
os.makedirs(os.path.join(out_folder, frame), exist_ok=True)
|
||||
# os.makedirs(os.path.join(out_folder, frame), exist_ok=True)
|
||||
|
||||
plot_fixed(np.zeros_like(gt_mesh), body, faces, camera).write_image(os.path.join(out_folder, frame, frame + '_body.png'))
|
||||
plot_fixed(gt_mesh, body, faces, camera).write_image(os.path.join(out_folder, frame, frame + '_gt.png'))
|
||||
for i in range(nr):
|
||||
plot_fixed(posed_mesh_fixed[i], body, faces, camera).write_image(os.path.join(out_folder, frame, frame + '_' + str(i) + '.png'))
|
||||
# plot_fixed(np.zeros_like(gt_mesh), body, faces, camera).write_image(os.path.join(out_folder, frame, frame + '_body.png'))
|
||||
# plot_fixed(gt_mesh, body, faces, camera).write_image(os.path.join(out_folder, frame, frame + '_gt.png'))
|
||||
# for i in range(nr):
|
||||
# plot_fixed(posed_mesh_fixed[i], body, faces, camera).write_image(os.path.join(out_folder, frame, frame + '_' + str(i) + '.png'))
|
||||
|
||||
# save_stl(os.path.join(out_folder, frame, frame + '_body.stl'), body, F_body)
|
||||
# save_stl(os.path.join(out_folder, frame, frame + '_gt.stl'), gt_mesh, faces.astype(np.int32))
|
||||
# for i in range(nr):
|
||||
# save_stl(os.path.join(out_folder, frame, frame + '_' + str(i) + '.stl'), posed_mesh_fixed[i], faces.astype(np.int32))
|
||||
np.save(os.path.join(out_folder, frame, frame + '_gt.npy'), gt_mesh)
|
||||
np.save(os.path.join(out_folder, frame, frame + '_body.npy'), body)
|
||||
np.save(os.path.join(out_folder, frame, frame + '_faces.npy'), faces.astype(np.int32))
|
||||
for i in range(nr):
|
||||
np.save(os.path.join(out_folder, frame, frame + '_' + str(i) + '.npy'), posed_mesh_fixed[i])
|
||||
# np.save(os.path.join(out_folder, frame, frame + '_gt.npy'), gt_mesh)
|
||||
# np.save(os.path.join(out_folder, frame, frame + '_body.npy'), body)
|
||||
# np.save(os.path.join(out_folder, frame, frame + '_faces.npy'), faces.astype(np.int32))
|
||||
# for i in range(nr):
|
||||
# np.save(os.path.join(out_folder, frame, frame + '_' + str(i) + '.npy'), posed_mesh_fixed[i])
|
||||
|
||||
save_stl(os.path.join(out_folder, frame + '_gt_body.stl'), body, F_body)
|
||||
save_stl(os.path.join(out_folder, frame + '_posed_body.stl'), body, F_body)
|
||||
|
||||
# custom_imshow(np.concatenate(row_sampling, axis=1)).write_image(os.path.join(out_folder, frame + '_sampling.png'))
|
||||
print()
|
||||
@@ -417,6 +419,7 @@ def sampling_garment(frame, camera):
|
||||
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='')
|
||||
parser.add_argument('--name', type=str)
|
||||
@@ -476,9 +479,15 @@ if __name__ == '__main__':
|
||||
# frame = '04925_272'
|
||||
|
||||
# frames = ['01070_13', '02276_232', '02978_242', '04008_295', '04173_193']
|
||||
frames = ['02276_232', '02978_242', '04173_193']
|
||||
# frames = ['00073_160', '00073_217', '00096_86', \
|
||||
# '04347_100', '04360_2', '04404_41', '04442_85', '04466_59', '04620_68', '04620_129', \
|
||||
# '04655_28', '04668_255', '04682_96', '04709_37', '06117_123', '06141_162']
|
||||
|
||||
frames = ['00265_257', '04070_263', '00239_9', '04608_170', '04372_289', '00077_106', '00205_164', '00323_97', '00185_7', '00079_250', \
|
||||
'04143_56', '00240_136', '00185_33']
|
||||
|
||||
out_folder = 'examples/sampling_analysis'
|
||||
|
||||
out_folder = 'examples/qualitative/bodies'
|
||||
os.makedirs(out_folder, exist_ok=True)
|
||||
for frame in tqdm.tqdm(frames):
|
||||
sampling_example(frame, camera_1)
|
||||
|
||||
Reference in New Issue
Block a user