Compare commits
7
Commits
gnn_frozen
..
gnn
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45cbfe4da0 | ||
|
|
5ecf87c401 | ||
|
|
53bfbabcd7 | ||
|
|
9a74c476a6 | ||
|
|
68b2d0d3af | ||
|
|
21bd18cbe2 | ||
|
|
c5d576f11f |
+1
-31
@@ -3,42 +3,12 @@ nohup python calculate_error.py --name error_al_all_150k > nohup/error/post_al_a
|
||||
nohup python auto_encoder_static.py --name="lhunor_static_iccv_1" > nohup/iccv/encoders/static_iccv_1.out 2>&1 &
|
||||
nohup python auto_encoder_static.py --name="lhunor_static_iccv_1_skirt" > nohup/iccv/encoders/static_iccv_1_skirt.out 2>&1 &
|
||||
nohup python auto_encoder_static.py --name="lhunor_static_iccv_1_cape_f" > nohup/iccv/encoders/static_iccv_1_cape_f.out 2>&1 &
|
||||
nohup python auto_encoder_static.py --name="lhunor_static_iccv_1_cape_m" > nohup/iccv/encoders/static_iccv_1_cape_m.out 2>&1 &
|
||||
nohup python auto_encoder_body.py --name="lhunor_body_iccv_1" > nohup/iccv/encoders/body_iccv_1.out 2>&1 &
|
||||
nohup python auto_encoder_body.py --name="lhunor_body_iccv_1_skirt" > nohup/iccv/encoders/body_iccv_1_skirt.out 2>&1 &
|
||||
nohup python auto_encoder_body.py --name="lhunor_body_iccv_1_cape_m" > nohup/iccv/encoders/body_iccv_1_cape_m.out 2>&1 &
|
||||
nohup python auto_encoder_curv.py --name="lhunor_curv_iccv_1 " > nohup/iccv/encoders/curv_iccv_1.out 2>&1 &
|
||||
nohup python auto_encoder_curv.py --name="lhunor_curv_iccv_1_skirt" > nohup/iccv/encoders/curv_iccv_1_skirt.out 2>&1 &
|
||||
nohup python auto_encoder_curv.py --name="lhunor_curv_iccv_1_cape_f" > nohup/iccv/encoders/curv_iccv_1_cape_f.out 2>&1 &
|
||||
nohup python auto_encoder_curv.py --name="lhunor_curv_iccv_1_cape_m" > nohup/iccv/encoders/curv_iccv_1_cape_m.out 2>&1 &
|
||||
nohup python cvae.py --name="lhunor_cvae_iccv_gnn_1" > nohup/iccv/cvae_iccv_gnn_1.out 2>&1 &
|
||||
|
||||
nohup python cvae.py --name="lhunor_abl_all" > nohup/iccv/ablation/abl_all.out 2>&1 &
|
||||
nohup python cvae.py --name="lhunor_abl_all_gnn" > nohup/iccv/ablation/abl_all_gnn.out 2>&1 &
|
||||
nohup python cvae.py --name="lhunor_abl_all_gnn_3" > nohup/iccv/ablation/abl_all_gnn_3.out 2>&1 &
|
||||
|
||||
nohup python upscale_test.py --name="iccv_32_2" > nohup/iccv/upscale/iccv_32_2.out 2>&1 &
|
||||
nohup python upscale_test.py --name="iccv_64_2" > nohup/iccv/upscale/iccv_64_2.out 2>&1 &
|
||||
nohup python upscale_test.py --name="iccv_128_2" > nohup/iccv/upscale/iccv_128_2.out 2>&1 &
|
||||
nohup python upscale_test.py --name="iccv_256_2" > nohup/iccv/upscale/iccv_256_2.out 2>&1 &
|
||||
|
||||
nohup python upscale_test.py --name="iccv_32_2_skirt" > nohup/iccv/upscale/iccv_32_2_skirt.out 2>&1 &
|
||||
nohup python upscale_test.py --name="iccv_64_2_skirt" > nohup/iccv/upscale/iccv_64_2_skirt.out 2>&1 &
|
||||
nohup python upscale_test.py --name="iccv_128_2_skirt" > nohup/iccv/upscale/iccv_128_2_skirt.out 2>&1 &
|
||||
nohup python upscale_test.py --name="iccv_256_2_skirt" > nohup/iccv/upscale/iccv_256_2_skirt.out 2>&1 &
|
||||
|
||||
nohup python upscale_test.py --name="iccv_32_2_cape_f" > nohup/iccv/upscale/iccv_32_2_cape_f_real.out 2>&1 &
|
||||
nohup python upscale_test.py --name="iccv_64_2_cape_f" > nohup/iccv/upscale/iccv_64_2_cape_f.out 2>&1 &
|
||||
nohup python upscale_test.py --name="iccv_128_2_cape_f" > nohup/iccv/upscale/iccv_128_2_cape_f.out 2>&1 &
|
||||
nohup python upscale_test.py --name="iccv_256_2_cape_f" > nohup/iccv/upscale/iccv_256_2_cape_f.out 2>&1 &
|
||||
|
||||
nohup python upscale_test.py --name="iccv_32_2_cape_m" > nohup/iccv/upscale/iccv_32_2_cape_m.out 2>&1 &
|
||||
nohup python upscale_test.py --name="iccv_64_2_cape_m" > nohup/iccv/upscale/iccv_64_2_cape_m.out 2>&1 &
|
||||
nohup python upscale_test.py --name="iccv_128_2_cape_m" > nohup/iccv/upscale/iccv_128_2_cape_m.out 2>&1 &
|
||||
nohup python upscale_test.py --name="iccv_256_2_cape_m" > nohup/iccv/upscale/iccv_256_2_cape_m.out 2>&1 &
|
||||
|
||||
nohup python cvae_pyramid.py --name="lhunor_iccv_pyr_32" > nohup/iccv/pyr/iccv_pyr_32.out 2>&1 &
|
||||
nohup python cvae_pyramid.py --name="lhunor_iccv_pyr_32_skirt" > nohup/iccv/pyr/iccv_pyr_32_skirt.out 2>&1 &
|
||||
nohup python cvae.py --name="lhunor_cvae_iccv_gnn_5" > nohup/iccv/cvae_iccv_gnn_5.out 2>&1 &
|
||||
|
||||
skirts!!!!
|
||||
pyramid next week
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
from configs.iccv.config_ae_body_cape_m import config
|
||||
from configs.iccv.config_ae_body_cape_f import config
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = config['gpu']
|
||||
|
||||
import tensorflow as tf
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
from configs.iccv.config_ae_curv_cape_m import config
|
||||
from configs.iccv.config_ae_curv_cape_f import config
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = config['gpu']
|
||||
|
||||
import tensorflow as tf
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
from configs.iccv.config_ae_static_cape_m import config
|
||||
from configs.iccv.config_ae_static_cape_f import config
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = config['gpu']
|
||||
|
||||
import tensorflow as tf
|
||||
@@ -247,9 +247,9 @@ if __name__ == '__main__':
|
||||
load_model(model.decoder, config['pretrained_model'] + '_dec')
|
||||
|
||||
ckpt_enc = tf.train.Checkpoint(model=model.encoder)
|
||||
manager_enc = tf.train.CheckpointManager(ckpt_enc, 'checkpoints/iccv/' + config['name'] + '_enc', max_to_keep=20)
|
||||
manager_enc = tf.train.CheckpointManager(ckpt_enc, 'checkpoints/post/' + config['name'] + '_enc', max_to_keep=20)
|
||||
ckpt_dec = tf.train.Checkpoint(model=model.decoder)
|
||||
manager_dec = tf.train.CheckpointManager(ckpt_dec, 'checkpoints/iccv/' + config['name'] + '_dec', max_to_keep=20)
|
||||
manager_dec = tf.train.CheckpointManager(ckpt_dec, 'checkpoints/post/' + config['name'] + '_dec', max_to_keep=20)
|
||||
|
||||
# test()
|
||||
train()
|
||||
@@ -7,7 +7,7 @@ config = dict()
|
||||
# DON'T FORGET TO LOAD FINAL UPSCALER UNLESS HAVE LEVEL 512
|
||||
# DON'T FORGET TO CHECK AVG GARMENT USED
|
||||
|
||||
config['use_skinning'] = False # and deshaping
|
||||
config['use_skinning'] = True # and deshaping
|
||||
config['remove_global_orientation'] = True
|
||||
config['use_curvature'] = True
|
||||
config['use_extra_losses'] = True # edge, collision, 3d mesh
|
||||
@@ -19,12 +19,12 @@ config['only_curvatures'] = False
|
||||
ablation_count = [config['use_skinning'], config['remove_global_orientation'], config['use_curvature'], config['use_extra_losses'], config['use_offsets']].count(False)
|
||||
assert ablation_count == 1 or ablation_count == 0
|
||||
|
||||
config['gpu'] = '2'
|
||||
config['name'] = 'abl_all_gnn_3'
|
||||
config['gpu'] = '0'
|
||||
config['name'] = 'iccv_gnn_5'
|
||||
config['notes'] = ''
|
||||
config['tags'] = ['iccv', 'abl_all_gnn']
|
||||
config['tags'] = ['iccv', 'gnn']
|
||||
|
||||
config['avg_garment_path'] = '' #custom_data/train_no_shape_avg_uv.npy # train_no_shape_avg_uv train_no_shape_one_hot_avg_uv
|
||||
config['avg_garment_path'] = 'custom_data/train_no_shape_avg_uv.npy' #custom_data/train_no_shape_avg_uv.npy # train_no_shape_avg_uv train_no_shape_one_hot_avg_uv
|
||||
if config['use_skinning']:
|
||||
assert (config['use_offsets'] and config['avg_garment_path'] != '') or (not config['use_offsets'] and config['avg_garment_path'] == '')
|
||||
|
||||
@@ -40,13 +40,13 @@ config['train_dir'] = '/home/workspace/local-data/train'
|
||||
config['valid_dir'] = '/home/workspace/local-data/valid'
|
||||
config['test_dir'] = '/home/workspace/data/dataset/test_ready'
|
||||
|
||||
config['static_model'] = 'checkpoints/iccv/static_iccv_1'
|
||||
config['body_model'] = 'checkpoints/iccv/body_iccv_1'
|
||||
config['curvature_model'] = 'checkpoints/iccv/curv_iccv_1'
|
||||
# config['frames_file'] = 'frames_dress_30k.txt'
|
||||
# config['frames_file_valid'] = 'frames_dress_30k.txt'
|
||||
# config['frames_file_test'] = 'frames_dress_30k.txt'
|
||||
|
||||
# config['static_model'] = 'checkpoints/post/static_post_2'
|
||||
# config['body_model'] = 'checkpoints/post/body_post_2'
|
||||
# config['curvature_model'] = 'checkpoints/post/curv_post_1'
|
||||
config['static_model'] = 'checkpoints/post/static_post_2'
|
||||
config['body_model'] = 'checkpoints/post/body_post_2'
|
||||
config['curvature_model'] = 'checkpoints/post/curv_post_1'
|
||||
|
||||
|
||||
config['smpl_res'] = 14475
|
||||
@@ -54,7 +54,7 @@ if config['is_cape']:
|
||||
config['smpl_res'] = 3638
|
||||
|
||||
|
||||
config['pretrained_model'] = 'checkpoints/iccv/abl_skin'
|
||||
config['pretrained_model'] = ''
|
||||
|
||||
###############
|
||||
config['lr'] = 0.0001# 0.0001
|
||||
@@ -83,17 +83,15 @@ else:
|
||||
config['upscale_enhancer'] = ''
|
||||
config['freeze_encoders'] = True
|
||||
config['use_one_hot'] = False
|
||||
config['bottleneck_scale'] = 2
|
||||
|
||||
config['cvae'] = dict()
|
||||
config['cvae']['is_label'] = False
|
||||
config['cvae']['latent_dim'] = 64 * config['bottleneck_scale']
|
||||
config['cvae']['add_noise'] = False
|
||||
config['cvae']['noise_amount'] = 0.0
|
||||
config['cvae']['add_noise'] = True
|
||||
config['cvae']['noise_amount'] = 0.001
|
||||
|
||||
config['cvae']['kernel_size'] = 7
|
||||
config['cvae']['encoder_depths'] = [3, 3, 3, 9, 3]
|
||||
config['cvae']['encoder_dims'] = [32, 64, 128, 256, config['cvae']['latent_dim']]
|
||||
config['cvae']['encoder_dims'] = [32, 64, 128, 256, 64]
|
||||
config['cvae']['decoder_depths'] = config['cvae']['encoder_depths']
|
||||
config['cvae']['decoder_dims'] = config['cvae']['encoder_dims']
|
||||
|
||||
@@ -101,9 +99,9 @@ config['cvae']['decoder_dims'] = config['cvae']['encoder_dims']
|
||||
config['cond_ae_static'] = dict()
|
||||
config['cond_ae_static']['is_label'] = False
|
||||
config['cond_ae_static']['kernel_size'] = 7
|
||||
config['cond_ae_static']['bottleneck_size'] = 8 * config['bottleneck_scale']
|
||||
config['cond_ae_static']['encoder_depths'] = [3, 3, 3, 27, 3]
|
||||
config['cond_ae_static']['encoder_dims'] = [8, 16, 32, 64, config['cond_ae_static']['bottleneck_size']]
|
||||
config['cond_ae_static']['bottleneck_size'] = 8
|
||||
config['cond_ae_static']['encoder_depths'] = [3, 3, 3, 9, 3]
|
||||
config['cond_ae_static']['encoder_dims'] = [16, 32, 64, 64, config['cond_ae_static']['bottleneck_size']]
|
||||
config['cond_ae_static']['decoder_depths'] = config['cond_ae_static']['encoder_depths']
|
||||
config['cond_ae_static']['decoder_dims'] = config['cond_ae_static']['encoder_dims']
|
||||
config['cond_ae_static']['activation'] = 'tanh'
|
||||
@@ -111,7 +109,7 @@ config['cond_ae_static']['activation'] = 'tanh'
|
||||
config['cond_ae_curv'] = dict()
|
||||
config['cond_ae_curv']['is_label'] = True
|
||||
config['cond_ae_curv']['kernel_size'] = 7
|
||||
config['cond_ae_curv']['bottleneck_size'] = 40 * config['bottleneck_scale']
|
||||
config['cond_ae_curv']['bottleneck_size'] = 40
|
||||
config['cond_ae_curv']['encoder_depths'] = [3, 3, 9, 9, 3]
|
||||
config['cond_ae_curv']['encoder_dims'] = [16, 32, 64, 128, config['cond_ae_curv']['bottleneck_size']]
|
||||
config['cond_ae_curv']['decoder_depths'] = config['cond_ae_curv']['encoder_depths']
|
||||
@@ -121,7 +119,7 @@ config['cond_ae_curv']['activation'] = 'tanh'
|
||||
config['cond_ae_body'] = dict()
|
||||
config['cond_ae_body']['is_label'] = False
|
||||
config['cond_ae_body']['kernel_size'] = 7
|
||||
config['cond_ae_body']['bottleneck_size'] = 16 * config['bottleneck_scale']
|
||||
config['cond_ae_body']['bottleneck_size'] = 16
|
||||
config['cond_ae_body']['encoder_depths'] = [3, 3, 9, 9, 3]
|
||||
config['cond_ae_body']['encoder_dims'] = [16, 32, 64, 128, config['cond_ae_body']['bottleneck_size']]
|
||||
config['cond_ae_body']['decoder_depths'] = config['cond_ae_body']['encoder_depths']
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
config = dict()
|
||||
|
||||
config['gpu'] = '0'
|
||||
config['name'] = 'iccv_pyr_32'
|
||||
config['notes'] = ''
|
||||
config['tags'] = ['pyr', 'iccv']
|
||||
|
||||
# DON'T FORGET TO RESET SSIM LOSS USAGE
|
||||
# DON'T FORGET TO CHECK MODEL LOADING
|
||||
# DON'T FORGET TO CHECK IF STORE IN MEMORY
|
||||
# DON'T FORGET TO CHECK REG LOSS COEFF
|
||||
# DON'T FORGET TO LOAD FINAL UPSCALER UNLESS HAVE LEVEL 512
|
||||
# DON'T FORGET TO CHECK IF SKIRT
|
||||
# DON'T FORGET TO CHECK IF CAPE
|
||||
# DON'T FORGET TO CHECK IF USING DOWNSCALE NONE OR _2
|
||||
# DON'T FORGET TO CHECK UPSCALING and ENCODER CHECKPOINTS
|
||||
|
||||
config['use_skinning'] = True # and deshaping
|
||||
config['remove_global_orientation'] = True
|
||||
config['use_extra_losses'] = True # edge, collision, 3d mesh
|
||||
config['use_offsets'] = False
|
||||
config['use_norm_loss'] = True
|
||||
|
||||
config['pretrained_model'] = ''
|
||||
config['pretrained_model_iteration'] = ''
|
||||
|
||||
config['pyramid'] = dict()
|
||||
config['pyramid']['resolutions'] = [32]
|
||||
config['pyramid']['pretrained_pyramid'] = ''
|
||||
config['pyramid']['final_upscale_enhancer'] = ''
|
||||
|
||||
config['train_dir'] = '/home/workspace/local-data/train'
|
||||
config['valid_dir'] = '/home/workspace/local-data/valid'
|
||||
config['test_dir'] = '/home/workspace/data/dataset/test_ready'
|
||||
config['batch_size'] = 4
|
||||
config['is_skirt'] = False
|
||||
config['is_cape'] = False
|
||||
|
||||
config['dataset_in_memory'] = False
|
||||
config['resolution'] = None
|
||||
|
||||
config['smpl_res'] = 14475
|
||||
if config['is_cape']:
|
||||
config['smpl_res'] = 3638
|
||||
|
||||
config['lr'] = 0.0001
|
||||
config['starting_balancing_coeff'] = 0.001
|
||||
config['reg_loss_coeff'] = 0.1 # set to 0 if don't want to use edge+collision
|
||||
config['avg_garment_path'] = ''
|
||||
config['bottleneck_scale'] = 2
|
||||
|
||||
config['signature_dynamic'] = { 'id': (), 'frame_nr': (),
|
||||
'pose_shape': (72 + 11,),
|
||||
'uv_body_posed': (512, 256, 3),
|
||||
'mesh_body_posed': (config['smpl_res'], 3,),
|
||||
'mesh_posed': (config['smpl_res'], 3,),
|
||||
'mesh_unposed': (config['smpl_res'], 3,),
|
||||
'uv_unposed': (512, 256, 3),
|
||||
'uv_curvature': (512, 256, 7),
|
||||
}
|
||||
config['signature_static'] = { 'uv_static': (512, 256, 3),
|
||||
'mesh_mask': (config['smpl_res'],),
|
||||
'uv_mask': (512, 256,),
|
||||
}
|
||||
|
||||
config['pyramid']['is_label'] = False
|
||||
config['pyramid']['add_noise'] = False
|
||||
config['pyramid']['noise_amount'] = 0.0
|
||||
|
||||
config['pyramid']['loss_weights'] = [1,1,1,1,1]
|
||||
|
||||
for res in config['pyramid']['resolutions']:
|
||||
if res != 512:
|
||||
res_modifier = '_' + str(res)
|
||||
config['signature_dynamic']['uv_body_posed' + res_modifier] = (res, res//2, 3)
|
||||
config['signature_dynamic']['uv_unposed' + res_modifier] = (res, res//2, 3)
|
||||
config['signature_dynamic']['uv_curvature' + res_modifier] = (res, res//2, 7)
|
||||
config['signature_static']['uv_static' + res_modifier] = (res, res//2, 3)
|
||||
config['signature_static']['uv_mask' + res_modifier] = (res, res//2)
|
||||
|
||||
|
||||
config['pyramid']['static_model'] = 'checkpoints/iccv/static_iccv_1'
|
||||
config['pyramid']['body_model'] = 'checkpoints/iccv/body_iccv_1'
|
||||
config['pyramid']['curvature_model'] = 'checkpoints/iccv/curv_iccv_1'
|
||||
config['pyramid']['freeze_encoders'] = True
|
||||
|
||||
|
||||
config['pyramid']['levels'] = []
|
||||
for res in config['pyramid']['resolutions']:
|
||||
if res == 512:
|
||||
level = dict()
|
||||
level['resolution'] = 512
|
||||
level['latent_dim'] = 64 * config['bottleneck_scale']
|
||||
level['kernel_size'] = 7
|
||||
level['encoder_depths'] = [3, 3, 9, 3]
|
||||
level['encoder_dims'] = [32, 64, 128, level['latent_dim']]
|
||||
level['decoder_input'] = (16, 8, 80)
|
||||
level['decoder_depths'] = [3, 3, 9, 3]
|
||||
level['decoder_dims'] = [256, 128, 64, 16]
|
||||
level['avg_garment_path'] = ''
|
||||
level['upscale_enhancer'] = ''
|
||||
config['pyramid']['levels'].append(level)
|
||||
elif res == 256:
|
||||
level = dict()
|
||||
level['resolution'] = 256
|
||||
level['latent_dim'] = 64 * config['bottleneck_scale']
|
||||
level['kernel_size'] = 5
|
||||
level['encoder_depths'] = [9, 9, 9, 9]
|
||||
level['encoder_dims'] = [32, 64, 128, level['latent_dim']]
|
||||
level['decoder_input'] = (8, 4, 128)
|
||||
level['decoder_depths'] = [9, 9, 9, 9]
|
||||
level['decoder_dims'] = [256, 128, 64, 16]
|
||||
level['avg_garment_path'] = ''
|
||||
level['upscale_enhancer'] = 'checkpoints/iccv/iccv_'#'checkpoints/up_3_d256_512_2'
|
||||
level['upscale_enhancer_freeze'] = True
|
||||
config['pyramid']['levels'].append(level)
|
||||
elif res == 128:
|
||||
level = dict()
|
||||
level['resolution'] = 128
|
||||
level['latent_dim'] = 64 * config['bottleneck_scale']
|
||||
level['kernel_size'] = 5
|
||||
level['encoder_depths'] = [16, 9, 9, 9]
|
||||
level['encoder_dims'] = [64, 128, 128, 64]
|
||||
level['decoder_input'] = (4, 2, 128)
|
||||
level['decoder_depths'] = [16, 9, 9, 9]
|
||||
level['decoder_dims'] = [256, 128, 128, level['latent_dim']]
|
||||
level['avg_garment_path'] = ''
|
||||
level['upscale_enhancer'] = 'checkpoints/iccv/iccv_'#'checkpoints/up_3_d128_256_2'
|
||||
level['upscale_enhancer_freeze'] = True
|
||||
config['pyramid']['levels'].append(level)
|
||||
elif res == 64:
|
||||
level = dict()
|
||||
level['resolution'] = 64
|
||||
level['latent_dim'] = 64 * config['bottleneck_scale']
|
||||
level['kernel_size'] = 3
|
||||
level['encoder_depths'] = [9, 9]
|
||||
level['encoder_dims'] = [64, level['latent_dim']]
|
||||
level['decoder_depths'] = level['encoder_depths']
|
||||
level['decoder_dims'] = level['encoder_dims']
|
||||
level['avg_garment_path'] = ''
|
||||
level['upscale_enhancer'] = 'checkpoints/iccv/iccv_'#checkpoints/up_3_d64_128_2'
|
||||
level['upscale_enhancer_freeze'] = True
|
||||
config['pyramid']['levels'].append(level)
|
||||
elif res == 32:
|
||||
level = dict()
|
||||
level['resolution'] = 32
|
||||
level['latent_dim'] = 64 * config['bottleneck_scale']
|
||||
level['kernel_size'] = 3
|
||||
level['encoder_depths'] = [16]
|
||||
level['encoder_dims'] = [level['latent_dim']]
|
||||
level['decoder_depths'] = level['encoder_depths']
|
||||
level['decoder_dims'] = level['encoder_dims']
|
||||
level['avg_garment_path'] = ''
|
||||
level['upscale_enhancer'] = 'checkpoints/iccv/iccv_32_2_skirt'#'checkpoints/up_3_d32_64_2'
|
||||
level['upscale_enhancer_freeze'] = True
|
||||
config['pyramid']['levels'].append(level)
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
config['cond_ae_static'] = dict()
|
||||
config['cond_ae_static']['is_label'] = False
|
||||
config['cond_ae_static']['kernel_size'] = 7
|
||||
config['cond_ae_static']['bottleneck_size'] = 8 * config['bottleneck_scale']
|
||||
config['cond_ae_static']['encoder_depths'] = [3, 3, 3, 27, 3]
|
||||
config['cond_ae_static']['encoder_dims'] = [8, 16, 32, 64, config['cond_ae_static']['bottleneck_size']]
|
||||
config['cond_ae_static']['decoder_depths'] = config['cond_ae_static']['encoder_depths']
|
||||
config['cond_ae_static']['decoder_dims'] = config['cond_ae_static']['encoder_dims']
|
||||
config['cond_ae_static']['activation'] = 'tanh'
|
||||
|
||||
config['cond_ae_curv'] = dict()
|
||||
config['cond_ae_curv']['is_label'] = True
|
||||
config['cond_ae_curv']['kernel_size'] = 7
|
||||
config['cond_ae_curv']['bottleneck_size'] = 40 * config['bottleneck_scale']
|
||||
config['cond_ae_curv']['encoder_depths'] = [3, 3, 9, 9, 3]
|
||||
config['cond_ae_curv']['encoder_dims'] = [16, 32, 64, 128, config['cond_ae_curv']['bottleneck_size']]
|
||||
config['cond_ae_curv']['decoder_depths'] = config['cond_ae_curv']['encoder_depths']
|
||||
config['cond_ae_curv']['decoder_dims'] = config['cond_ae_curv']['encoder_dims']
|
||||
config['cond_ae_curv']['activation'] = 'tanh'
|
||||
|
||||
config['cond_ae_body'] = dict()
|
||||
config['cond_ae_body']['is_label'] = False
|
||||
config['cond_ae_body']['kernel_size'] = 7
|
||||
config['cond_ae_body']['bottleneck_size'] = 16 * config['bottleneck_scale']
|
||||
config['cond_ae_body']['encoder_depths'] = [3, 3, 9, 9, 3]
|
||||
config['cond_ae_body']['encoder_dims'] = [16, 32, 64, 128, config['cond_ae_body']['bottleneck_size']]
|
||||
config['cond_ae_body']['decoder_depths'] = config['cond_ae_body']['encoder_depths']
|
||||
config['cond_ae_body']['decoder_dims'] = config['cond_ae_body']['encoder_dims']
|
||||
config['cond_ae_body']['activation'] = 'tanh'
|
||||
@@ -1,188 +0,0 @@
|
||||
config = dict()
|
||||
|
||||
config['gpu'] = '5'
|
||||
config['name'] = 'iccv_pyr_32_skirt'
|
||||
config['notes'] = ''
|
||||
config['tags'] = ['pyr', 'iccv']
|
||||
|
||||
# DON'T FORGET TO RESET SSIM LOSS USAGE
|
||||
# DON'T FORGET TO CHECK MODEL LOADING
|
||||
# DON'T FORGET TO CHECK IF STORE IN MEMORY
|
||||
# DON'T FORGET TO CHECK REG LOSS COEFF
|
||||
# DON'T FORGET TO LOAD FINAL UPSCALER UNLESS HAVE LEVEL 512
|
||||
# DON'T FORGET TO CHECK IF SKIRT
|
||||
# DON'T FORGET TO CHECK IF CAPE
|
||||
# DON'T FORGET TO CHECK IF USING DOWNSCALE NONE OR _2
|
||||
# DON'T FORGET TO CHECK UPSCALING and ENCODER CHECKPOINTS
|
||||
|
||||
config['use_skinning'] = True # and deshaping
|
||||
config['remove_global_orientation'] = True
|
||||
config['use_extra_losses'] = True # edge, collision, 3d mesh
|
||||
config['use_offsets'] = False
|
||||
config['use_norm_loss'] = True
|
||||
|
||||
config['pretrained_model'] = ''
|
||||
config['pretrained_model_iteration'] = ''
|
||||
|
||||
config['pyramid'] = dict()
|
||||
config['pyramid']['resolutions'] = [32]
|
||||
config['pyramid']['pretrained_pyramid'] = ''
|
||||
config['pyramid']['final_upscale_enhancer'] = ''
|
||||
|
||||
config['train_dir'] = '/home/workspace/data/dataset/local-cache/train_skirt'
|
||||
config['valid_dir'] = '/home/workspace/local-data/valid_skirt'
|
||||
config['test_dir'] = '/home/workspace/data/dataset/test_skirt_ready_2'
|
||||
config['batch_size'] = 4
|
||||
config['is_skirt'] = False
|
||||
config['is_cape'] = False
|
||||
|
||||
config['dataset_in_memory'] = False
|
||||
config['resolution'] = None
|
||||
|
||||
config['smpl_res'] = 14475
|
||||
if config['is_cape']:
|
||||
config['smpl_res'] = 3638
|
||||
|
||||
config['lr'] = 0.0001
|
||||
config['starting_balancing_coeff'] = 0.001
|
||||
config['reg_loss_coeff'] = 0.1 # set to 0 if don't want to use edge+collision
|
||||
config['avg_garment_path'] = ''
|
||||
config['bottleneck_scale'] = 2
|
||||
|
||||
config['signature_dynamic'] = { 'id': (), 'frame_nr': (),
|
||||
'pose_shape': (72 + 11,),
|
||||
'uv_body_posed': (512, 256, 3),
|
||||
'mesh_body_posed': (config['smpl_res'], 3,),
|
||||
'mesh_posed': (config['smpl_res'], 3,),
|
||||
'mesh_unposed': (config['smpl_res'], 3,),
|
||||
'uv_unposed': (512, 256, 3),
|
||||
'uv_curvature': (512, 256, 7),
|
||||
}
|
||||
config['signature_static'] = { 'uv_static': (512, 256, 3),
|
||||
'mesh_mask': (config['smpl_res'],),
|
||||
'uv_mask': (512, 256,),
|
||||
}
|
||||
|
||||
config['pyramid']['is_label'] = False
|
||||
config['pyramid']['add_noise'] = False
|
||||
config['pyramid']['noise_amount'] = 0.0
|
||||
|
||||
config['pyramid']['loss_weights'] = [1,1,1,1,1]
|
||||
|
||||
for res in config['pyramid']['resolutions']:
|
||||
if res != 512:
|
||||
res_modifier = '_' + str(res)
|
||||
config['signature_dynamic']['uv_body_posed' + res_modifier] = (res, res//2, 3)
|
||||
config['signature_dynamic']['uv_unposed' + res_modifier] = (res, res//2, 3)
|
||||
config['signature_dynamic']['uv_curvature' + res_modifier] = (res, res//2, 7)
|
||||
config['signature_static']['uv_static' + res_modifier] = (res, res//2, 3)
|
||||
config['signature_static']['uv_mask' + res_modifier] = (res, res//2)
|
||||
|
||||
|
||||
config['pyramid']['static_model'] = 'checkpoints/iccv/static_iccv_1'
|
||||
config['pyramid']['body_model'] = 'checkpoints/iccv/body_iccv_1'
|
||||
config['pyramid']['curvature_model'] = 'checkpoints/iccv/curv_iccv_1'
|
||||
config['pyramid']['freeze_encoders'] = True
|
||||
|
||||
|
||||
config['pyramid']['levels'] = []
|
||||
for res in config['pyramid']['resolutions']:
|
||||
if res == 512:
|
||||
level = dict()
|
||||
level['resolution'] = 512
|
||||
level['latent_dim'] = 64 * config['bottleneck_scale']
|
||||
level['kernel_size'] = 7
|
||||
level['encoder_depths'] = [3, 3, 9, 3]
|
||||
level['encoder_dims'] = [32, 64, 128, level['latent_dim']]
|
||||
level['decoder_input'] = (16, 8, 80)
|
||||
level['decoder_depths'] = [3, 3, 9, 3]
|
||||
level['decoder_dims'] = [256, 128, 64, 16]
|
||||
level['avg_garment_path'] = ''
|
||||
level['upscale_enhancer'] = ''
|
||||
config['pyramid']['levels'].append(level)
|
||||
elif res == 256:
|
||||
level = dict()
|
||||
level['resolution'] = 256
|
||||
level['latent_dim'] = 64 * config['bottleneck_scale']
|
||||
level['kernel_size'] = 5
|
||||
level['encoder_depths'] = [9, 9, 9, 9]
|
||||
level['encoder_dims'] = [32, 64, 128, level['latent_dim']]
|
||||
level['decoder_input'] = (8, 4, 128)
|
||||
level['decoder_depths'] = [9, 9, 9, 9]
|
||||
level['decoder_dims'] = [256, 128, 64, 16]
|
||||
level['avg_garment_path'] = ''
|
||||
level['upscale_enhancer'] = 'checkpoints/iccv/iccv_'#'checkpoints/up_3_d256_512_2'
|
||||
level['upscale_enhancer_freeze'] = True
|
||||
config['pyramid']['levels'].append(level)
|
||||
elif res == 128:
|
||||
level = dict()
|
||||
level['resolution'] = 128
|
||||
level['latent_dim'] = 64 * config['bottleneck_scale']
|
||||
level['kernel_size'] = 5
|
||||
level['encoder_depths'] = [16, 9, 9, 9]
|
||||
level['encoder_dims'] = [64, 128, 128, 64]
|
||||
level['decoder_input'] = (4, 2, 128)
|
||||
level['decoder_depths'] = [16, 9, 9, 9]
|
||||
level['decoder_dims'] = [256, 128, 128, level['latent_dim']]
|
||||
level['avg_garment_path'] = ''
|
||||
level['upscale_enhancer'] = 'checkpoints/iccv/iccv_'#'checkpoints/up_3_d128_256_2'
|
||||
level['upscale_enhancer_freeze'] = True
|
||||
config['pyramid']['levels'].append(level)
|
||||
elif res == 64:
|
||||
level = dict()
|
||||
level['resolution'] = 64
|
||||
level['latent_dim'] = 64 * config['bottleneck_scale']
|
||||
level['kernel_size'] = 3
|
||||
level['encoder_depths'] = [9, 9]
|
||||
level['encoder_dims'] = [64, level['latent_dim']]
|
||||
level['decoder_depths'] = level['encoder_depths']
|
||||
level['decoder_dims'] = level['encoder_dims']
|
||||
level['avg_garment_path'] = ''
|
||||
level['upscale_enhancer'] = 'checkpoints/iccv/iccv_'#checkpoints/up_3_d64_128_2'
|
||||
level['upscale_enhancer_freeze'] = True
|
||||
config['pyramid']['levels'].append(level)
|
||||
elif res == 32:
|
||||
level = dict()
|
||||
level['resolution'] = 32
|
||||
level['latent_dim'] = 64 * config['bottleneck_scale']
|
||||
level['kernel_size'] = 3
|
||||
level['encoder_depths'] = [16]
|
||||
level['encoder_dims'] = [level['latent_dim']]
|
||||
level['decoder_depths'] = level['encoder_depths']
|
||||
level['decoder_dims'] = level['encoder_dims']
|
||||
level['avg_garment_path'] = ''
|
||||
level['upscale_enhancer'] = 'checkpoints/iccv/iccv_32_2'#'checkpoints/up_3_d32_64_2'
|
||||
level['upscale_enhancer_freeze'] = True
|
||||
config['pyramid']['levels'].append(level)
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
config['cond_ae_static'] = dict()
|
||||
config['cond_ae_static']['is_label'] = False
|
||||
config['cond_ae_static']['kernel_size'] = 7
|
||||
config['cond_ae_static']['bottleneck_size'] = 8 * config['bottleneck_scale']
|
||||
config['cond_ae_static']['encoder_depths'] = [3, 3, 3, 27, 3]
|
||||
config['cond_ae_static']['encoder_dims'] = [8, 16, 32, 64, config['cond_ae_static']['bottleneck_size']]
|
||||
config['cond_ae_static']['decoder_depths'] = config['cond_ae_static']['encoder_depths']
|
||||
config['cond_ae_static']['decoder_dims'] = config['cond_ae_static']['encoder_dims']
|
||||
config['cond_ae_static']['activation'] = 'tanh'
|
||||
|
||||
config['cond_ae_curv'] = dict()
|
||||
config['cond_ae_curv']['is_label'] = True
|
||||
config['cond_ae_curv']['kernel_size'] = 7
|
||||
config['cond_ae_curv']['bottleneck_size'] = 40 * config['bottleneck_scale']
|
||||
config['cond_ae_curv']['encoder_depths'] = [3, 3, 9, 9, 3]
|
||||
config['cond_ae_curv']['encoder_dims'] = [16, 32, 64, 128, config['cond_ae_curv']['bottleneck_size']]
|
||||
config['cond_ae_curv']['decoder_depths'] = config['cond_ae_curv']['encoder_depths']
|
||||
config['cond_ae_curv']['decoder_dims'] = config['cond_ae_curv']['encoder_dims']
|
||||
config['cond_ae_curv']['activation'] = 'tanh'
|
||||
|
||||
config['cond_ae_body'] = dict()
|
||||
config['cond_ae_body']['is_label'] = False
|
||||
config['cond_ae_body']['kernel_size'] = 7
|
||||
config['cond_ae_body']['bottleneck_size'] = 16 * config['bottleneck_scale']
|
||||
config['cond_ae_body']['encoder_depths'] = [3, 3, 9, 9, 3]
|
||||
config['cond_ae_body']['encoder_dims'] = [16, 32, 64, 128, config['cond_ae_body']['bottleneck_size']]
|
||||
config['cond_ae_body']['decoder_depths'] = config['cond_ae_body']['encoder_depths']
|
||||
config['cond_ae_body']['decoder_dims'] = config['cond_ae_body']['encoder_dims']
|
||||
config['cond_ae_body']['activation'] = 'tanh'
|
||||
@@ -1,52 +0,0 @@
|
||||
config = dict()
|
||||
|
||||
|
||||
config['batch_size'] = 4
|
||||
config['train_dir'] = '/home/workspace/local-data/cape_processed/train/male'
|
||||
config['valid_dir'] = '/home/workspace/local-data/cape_processed/test/male'
|
||||
config['test_dir'] = '/home/workspace/local-data/cape_processed/test/male'
|
||||
config['use_filled'] = False
|
||||
config['resolution'] = 512
|
||||
config['is_skirt'] = False
|
||||
config['dataset_in_memory'] = False
|
||||
config['is_cape'] = True
|
||||
config['remove_global_orientation'] = True
|
||||
|
||||
config['smpl_res'] = 14475
|
||||
if config['is_cape']:
|
||||
config['smpl_res'] = 3638
|
||||
|
||||
config['latent_dim'] = 128
|
||||
config['bottleneck_scale'] = 2
|
||||
|
||||
config['cond_ae'] = dict()
|
||||
config['cond_ae']['is_label'] = False
|
||||
config['cond_ae']['upscale_output'] = False
|
||||
config['cond_ae']['latent_dim'] = config['latent_dim']
|
||||
config['cond_ae']['kernel_size'] = 7
|
||||
config['cond_ae']['bottleneck_size'] = 16 * config['bottleneck_scale']
|
||||
config['cond_ae']['encoder_depths'] = [3, 3, 9, 9, 3]
|
||||
config['cond_ae']['encoder_dims'] = [16, 32, 64, 128, config['cond_ae']['bottleneck_size']]
|
||||
config['cond_ae']['decoder_depths'] = config['cond_ae']['encoder_depths']
|
||||
config['cond_ae']['decoder_dims'] = config['cond_ae']['encoder_dims']
|
||||
config['cond_ae']['activation'] = 'tanh'
|
||||
|
||||
|
||||
config['gpu'] = '4'
|
||||
config['lr'] = 0.0001
|
||||
config['name'] = 'body_iccv_1_cape_m'
|
||||
config['notes'] = ''
|
||||
config['tags'] = ['iccv', 'body', 'cape_m']
|
||||
|
||||
config['cond_ae']['upscale_output'] = False
|
||||
config['pretrained_model'] = ''
|
||||
|
||||
|
||||
config['signature_dynamic'] = { 'id': (), 'frame_nr': (),
|
||||
'pose_shape': (72 + 11,),
|
||||
'uv_body_posed': (3, 512, 256,),
|
||||
'mesh_body_posed': (config['smpl_res'], 3,),
|
||||
}
|
||||
config['signature_static'] = {
|
||||
'mesh_mask': (config['smpl_res'],),
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
config = dict()
|
||||
|
||||
|
||||
config['batch_size'] = 4
|
||||
config['train_dir'] = '/home/workspace/local-data/cape_processed/train/male'
|
||||
config['valid_dir'] = '/home/workspace/local-data/cape_processed/test/male'
|
||||
config['test_dir'] = '/home/workspace/local-data/cape_processed/test/male'
|
||||
config['use_filled'] = False
|
||||
config['resolution'] = 512
|
||||
config['is_skirt'] = False
|
||||
config['dataset_in_memory'] = False
|
||||
config['is_cape'] = True
|
||||
config['remove_global_orientation'] = True
|
||||
|
||||
config['smpl_res'] = 14475
|
||||
if config['is_cape']:
|
||||
config['smpl_res'] = 3638
|
||||
|
||||
config['latent_dim'] = 128
|
||||
config['bottleneck_scale'] = 2
|
||||
|
||||
config['cond_ae'] = dict()
|
||||
config['cond_ae']['is_label'] = True
|
||||
config['cond_ae']['upscale_output'] = False
|
||||
config['cond_ae']['latent_dim'] = config['latent_dim']
|
||||
config['cond_ae']['kernel_size'] = 7
|
||||
config['cond_ae']['bottleneck_size'] = 40 * config['bottleneck_scale']
|
||||
config['cond_ae']['encoder_depths'] = [3, 3, 9, 9, 3]
|
||||
config['cond_ae']['encoder_dims'] = [16, 32, 64, 128, config['cond_ae']['bottleneck_size']]
|
||||
config['cond_ae']['decoder_depths'] = config['cond_ae']['encoder_depths']
|
||||
config['cond_ae']['decoder_dims'] = config['cond_ae']['encoder_dims']
|
||||
config['cond_ae']['activation'] = 'tanh'
|
||||
|
||||
|
||||
config['gpu'] = '5'
|
||||
config['lr'] = 0.001
|
||||
config['name'] = 'curv_iccv_1_cape_m'
|
||||
config['notes'] = ''
|
||||
config['tags'] = ['iccv', 'curv', 'cape_m']
|
||||
|
||||
config['cond_ae']['upscale_output'] = False
|
||||
config['pretrained_model'] = ''
|
||||
|
||||
|
||||
config['signature_dynamic'] = { 'id': (), 'frame_nr': (),
|
||||
'uv_curvature': (512, 256, 7),
|
||||
'mesh_curvature': (config['smpl_res'])
|
||||
}
|
||||
config['signature_static'] = { 'mesh_mask': (config['smpl_res'],),
|
||||
'uv_mask': (512, 256,),
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
config = dict()
|
||||
|
||||
|
||||
config['batch_size'] = 4
|
||||
config['train_dir'] = '/home/workspace/local-data/cape_processed/train/male'
|
||||
config['valid_dir'] = '/home/workspace/local-data/cape_processed/test/male'
|
||||
config['test_dir'] = '/home/workspace/local-data/cape_processed/test/male'
|
||||
config['use_filled'] = False
|
||||
config['resolution'] = 512
|
||||
config['is_skirt'] = False
|
||||
config['dataset_in_memory'] = True
|
||||
config['is_cape'] = True
|
||||
config['remove_global_orientation'] = True
|
||||
|
||||
config['smpl_res'] = 14475
|
||||
if config['is_cape']:
|
||||
config['smpl_res'] = 3638
|
||||
|
||||
config['latent_dim'] = 128
|
||||
|
||||
config['bottleneck_scale'] = 2
|
||||
|
||||
config['cond_ae'] = dict()
|
||||
config['cond_ae']['is_label'] = False
|
||||
config['cond_ae']['upscale_output'] = False
|
||||
config['cond_ae']['latent_dim'] = config['latent_dim']
|
||||
config['cond_ae']['kernel_size'] = 7
|
||||
config['cond_ae']['bottleneck_size'] = 8 * config['bottleneck_scale']
|
||||
config['cond_ae']['encoder_depths'] = [3, 3, 3, 27, 3]
|
||||
config['cond_ae']['encoder_dims'] = [8, 16, 32, 64, config['cond_ae']['bottleneck_size']]
|
||||
config['cond_ae']['decoder_depths'] = config['cond_ae']['encoder_depths']
|
||||
config['cond_ae']['decoder_dims'] = config['cond_ae']['encoder_dims']
|
||||
config['cond_ae']['activation'] = 'tanh'
|
||||
|
||||
|
||||
config['gpu'] = '3'
|
||||
config['lr'] = 0.0005
|
||||
config['name'] = 'static_iccv_1_cape_m'
|
||||
config['notes'] = ' '
|
||||
config['tags'] = ['iccv', 'static', 'cape_m']
|
||||
|
||||
config['cond_ae']['upscale_output'] = False
|
||||
config['pretrained_model'] = 'checkpoints/iccv/static_iccv_1_cape_m_old'
|
||||
|
||||
|
||||
config['signature_dynamic'] = { 'id': (), 'frame_nr': (), }
|
||||
config['signature_static'] = { 'uv_static': (512, 256, 3),
|
||||
'mesh_static': (config['smpl_res'], 3,),
|
||||
'mesh_mask': (config['smpl_res'],),
|
||||
'uv_mask': (512, 256,),
|
||||
}
|
||||
@@ -43,7 +43,6 @@ from dataset import DatasetFactory, StaticDataset
|
||||
from custom_utils.smpl import SMPL
|
||||
from models.cvae_model import CVAENew as CVAE
|
||||
from models.gnn import Smoother
|
||||
from custom_utils.custom_utils import Accumulator
|
||||
|
||||
|
||||
def init_wandb():
|
||||
@@ -87,7 +86,7 @@ def train_step(batch):
|
||||
else:
|
||||
mesh_orig, uv_orig = batch['mesh_posed'], batch['uv_posed']
|
||||
|
||||
pred, mean, logvar = model([uv_orig, batch['uv_static'], batch['uv_body_posed'], batch['uv_curvature'], batch['uv_mask']], training=False)
|
||||
pred, mean, logvar = model([uv_orig, batch['uv_static'], batch['uv_body_posed'], batch['uv_curvature'], batch['uv_mask']], training=True)
|
||||
|
||||
mesh_pred = uv2mesh(pred)
|
||||
mesh_pred = smoother(mesh_pred, training=True)
|
||||
@@ -107,29 +106,34 @@ def train_step(batch):
|
||||
e_loss = tf.reduce_mean(edge_loss(mesh_pred, mesh_orig, batch['mesh_mask']))
|
||||
c_loss, c_ratio = collision_penalty(mesh_pred_posed, batch['mesh_body_posed'], batch['mesh_mask'])
|
||||
c_loss, c_ratio = tf.reduce_mean(c_loss), tf.reduce_mean(c_ratio)
|
||||
l2_loss = tf.reduce_mean(1e3 * tf.reduce_mean(tf.reduce_sum(((uv_orig - pred) ** 2), axis=-1), axis=[1, 2]))
|
||||
l2_mesh_loss = tf.reduce_mean(1e3 * tf.reduce_mean(tf.reduce_sum(batch['mesh_mask'][:,:,tf.newaxis] * (batch['mesh_posed'] - mesh_pred_posed) ** 2, axis=-1), axis=-1))
|
||||
n_loss = normal_loss(mesh_pred_posed, batch['mesh_posed'], batch['mesh_mask'], is_skirt=config['is_skirt'], is_smpl_orig=config['is_cape'])
|
||||
# conc_loss = concept_loss(pred, batch['uv_unposed'])
|
||||
kl = kl_loss(mean, logvar)
|
||||
|
||||
reconstr_loss = l2_mesh_loss
|
||||
reconstr_loss = l2_loss
|
||||
if config['use_extra_losses']:
|
||||
if 'block_collision_loss' in config.keys() and config['block_collision_loss'] == True:
|
||||
reconstr_loss = reconstr_loss + (e_loss) * config['reg_loss_coeff']
|
||||
reconstr_loss = reconstr_loss + l2_mesh_loss + (e_loss) * config['reg_loss_coeff']
|
||||
else:
|
||||
reconstr_loss = reconstr_loss + (e_loss + c_loss) * config['reg_loss_coeff']
|
||||
reconstr_loss = reconstr_loss + l2_mesh_loss + (e_loss + c_loss) * config['reg_loss_coeff']
|
||||
if config['use_norm_loss'] and step > 2000:
|
||||
reconstr_loss = reconstr_loss + n_loss * config['reg_loss_coeff']
|
||||
|
||||
loss = reconstr_loss
|
||||
loss = reconstr_loss + g_balancing_coeff * kl
|
||||
|
||||
mean = tf.reduce_mean(mean)
|
||||
logvar = tf.reduce_mean(logvar)
|
||||
|
||||
# ms_ssim = tf.reduce_mean(tf.image.ssim_multiscale(pred + 5, batch['uv_unposed'] + 5, max_val=10, power_factors=(0.5, 0.2, 0.1, 0.1, 0.1)))
|
||||
metric = tf.reduce_sum(tf.math.sqrt(tf.reduce_sum(batch['mesh_mask'][:,:,tf.newaxis] * (mesh_orig - mesh_pred) ** 2, axis=-1))) / tf.reduce_sum(batch['mesh_mask'])
|
||||
gradients = tape.gradient(loss, smoother.trainable_variables)
|
||||
optimizer.apply_gradients(zip(gradients, smoother.trainable_variables))
|
||||
gradients = tape.gradient(loss, model.trainable_variables + smoother.trainable_variables)
|
||||
optimizer.apply_gradients(zip(gradients, model.trainable_variables + smoother.trainable_variables))
|
||||
return { 'train/loss': loss, 'train/edge_loss': e_loss, 'train/collision_loss': c_loss, 'train/euclid_error': metric,
|
||||
'train/reconstr_loss': reconstr_loss, 'train/collision_ratio': c_ratio,
|
||||
'train/mean': mean, 'train/logvar': logvar, 'train/var': np.e ** logvar,
|
||||
'train/l2_mesh_loss': l2_mesh_loss, 'train/normal_loss': n_loss,
|
||||
'train/mean': mean, 'train/logvar': logvar, 'train/kl_loss': kl, 'train/var': np.e ** logvar,
|
||||
'train/l2_loss': l2_loss, 'train/l2_mesh_loss': l2_mesh_loss, 'train/normal_loss': n_loss,
|
||||
# 'train/ms_ssim': ms_ssim,
|
||||
}
|
||||
|
||||
@@ -161,16 +165,22 @@ def valid_step(batch):
|
||||
e_loss = tf.reduce_mean(edge_loss(mesh_pred, mesh_orig, batch['mesh_mask']))
|
||||
c_loss, c_ratio = collision_penalty(mesh_pred_posed, batch['mesh_body_posed'], batch['mesh_mask'])
|
||||
c_loss, c_ratio = tf.reduce_mean(c_loss), tf.reduce_mean(c_ratio)
|
||||
l2_loss = tf.reduce_mean(1e3 * tf.reduce_mean(tf.reduce_sum(((uv_orig - pred) ** 2), axis=-1), axis=[1, 2]))
|
||||
l2_mesh_loss = tf.reduce_mean(1e3 * tf.reduce_mean(tf.reduce_sum(batch['mesh_mask'][:,:,tf.newaxis] * (batch['mesh_posed'] - mesh_pred_posed) ** 2, axis=-1), axis=-1))
|
||||
n_loss = normal_loss(mesh_pred_posed, batch['mesh_posed'], batch['mesh_mask'], is_skirt=config['is_skirt'], is_smpl_orig=config['is_cape'])
|
||||
# conc_loss = concept_loss(pred, batch['uv_unposed'])
|
||||
kl = kl_loss(mean, logvar)
|
||||
|
||||
reconstr_loss = l2_mesh_loss
|
||||
reconstr_loss = l2_loss
|
||||
if config['use_extra_losses']:
|
||||
reconstr_loss = reconstr_loss + (e_loss + c_loss) * config['reg_loss_coeff']
|
||||
reconstr_loss = reconstr_loss + l2_mesh_loss + (e_loss + c_loss) * config['reg_loss_coeff']
|
||||
if config['use_norm_loss']:
|
||||
reconstr_loss = reconstr_loss + n_loss * config['reg_loss_coeff']
|
||||
|
||||
loss = reconstr_loss
|
||||
loss = reconstr_loss + g_balancing_coeff * kl
|
||||
|
||||
mean = tf.reduce_mean(mean)
|
||||
logvar = tf.reduce_mean(logvar)
|
||||
|
||||
# ms_ssim = tf.reduce_mean(tf.image.ssim_multiscale(pred + 5, batch['uv_unposed'] + 5, max_val=10, power_factors=(0.5, 0.2, 0.1, 0.1, 0.1)))
|
||||
metric = tf.reduce_sum(tf.math.sqrt(tf.reduce_sum(batch['mesh_mask'][:,:,tf.newaxis] * (mesh_orig - mesh_pred) ** 2, axis=-1))) / tf.reduce_sum(batch['mesh_mask'])
|
||||
@@ -178,7 +188,7 @@ def valid_step(batch):
|
||||
|
||||
return { 'valid/loss': loss, 'valid/edge_loss': e_loss, 'valid/collision_loss': c_loss, 'valid/euclid_error': metric,
|
||||
'valid/reconstr_loss': reconstr_loss, 'valid/l2_mesh_loss': l2_mesh_loss, 'valid/collision_ratio': c_ratio,
|
||||
'valid/mean': mean, 'valid/logvar': logvar, 'valid/var': np.e ** logvar,
|
||||
'valid/mean': mean, 'valid/logvar': logvar, 'valid/kl_loss': kl, 'valid/var': np.e ** logvar,
|
||||
'valid/normal_loss': n_loss,# 'valid/ms_ssim': ms_ssim,
|
||||
}
|
||||
|
||||
@@ -280,6 +290,7 @@ def plot_everything(batch: dict, type: str):
|
||||
|
||||
gt_posed = [batch['mesh_posed'].numpy()[i, mask[i], :] for i in range(mask.shape[0])]
|
||||
|
||||
|
||||
body = batch['mesh_body_posed'].numpy()
|
||||
mesh_posed_fixed = fix_collision(mesh_posed, body, mask).numpy()
|
||||
|
||||
@@ -513,7 +524,6 @@ if __name__ == '__main__':
|
||||
is_cape=config['is_cape'])
|
||||
|
||||
model = CVAE(config)
|
||||
model.trainable = False
|
||||
smoother = Smoother()
|
||||
|
||||
optimizer = tf.optimizers.Adam(learning_rate=config['lr'])
|
||||
@@ -524,9 +534,8 @@ if __name__ == '__main__':
|
||||
# test()
|
||||
|
||||
ckpt = tf.train.Checkpoint(model=model)
|
||||
manager = tf.train.CheckpointManager(ckpt, 'checkpoints/iccv/' + config['name'], max_to_keep=20)
|
||||
train_accumulator = Accumulator()
|
||||
valid_accumulator = Accumulator()
|
||||
manager = tf.train.CheckpointManager(ckpt, 'checkpoints/post/' + config['name'], max_to_keep=20)
|
||||
|
||||
|
||||
if config['pretrained_model'] != '':
|
||||
load_model(model, config['pretrained_model'])
|
||||
@@ -539,37 +548,30 @@ if __name__ == '__main__':
|
||||
batch = static_dataset_train.expand_batch(batch_to_dict(batch, config['signature_dynamic']))
|
||||
|
||||
train_loss = train_step(batch)
|
||||
train_accumulator.update(train_loss)
|
||||
|
||||
if step % 50 == 0:
|
||||
data_valid = valid_iterator.get_next()
|
||||
data_valid = static_dataset_valid.expand_batch(batch_to_dict(data_valid, config['signature_dynamic']))
|
||||
valid_loss = valid_step(data_valid)
|
||||
valid_accumulator.update(valid_loss)
|
||||
|
||||
to_log = { **train_loss, **valid_loss, **{ 'current_step': step} }
|
||||
if step % 5000 == 0 or (step < 5000 and step % 500 == 0):
|
||||
train_figs = plot_everything(batch, 'train')
|
||||
valid_figs = plot_everything(data_valid, 'valid')
|
||||
to_log = { **to_log, **train_figs, **valid_figs }
|
||||
|
||||
if step % 5000 == 0:
|
||||
manager.save(checkpoint_number=step)
|
||||
if step == 0:
|
||||
to_log = { **to_log, **{ 'model/summary': wandb.Html(get_summary_html(model)) } }
|
||||
|
||||
if train_loss['train/euclid_error'] < (config['balancing_activation_limit'] if 'balancing_activation_limit' in config.keys() else 0.017):
|
||||
if balancing_activated_step == 0:
|
||||
balancing_activated_step = step
|
||||
g_balancing_coeff = g_balancing_coeff + 1 / 10000
|
||||
|
||||
|
||||
if step % 1000 == 0 or (step < 1000 and step % 100 == 0):
|
||||
to_log = dict({ **train_loss, **valid_loss, **{ 'current_step': step } })
|
||||
if step % 5000 == 0 or (step < 5000 and step % 1000 == 0):
|
||||
train_figs = plot_everything(batch, 'train')
|
||||
valid_figs = plot_everything(data_valid, 'valid')
|
||||
to_log = { **to_log, **train_figs, **valid_figs }
|
||||
if step == 0:
|
||||
to_log = { **to_log, **{ 'model/summary': wandb.Html(get_summary_html(model)) } }
|
||||
|
||||
to_log = { **to_log, **{ 'train/balancing_coeff': g_balancing_coeff } }
|
||||
|
||||
wandb.log(to_log, step = step)
|
||||
train_accumulator.reset()
|
||||
valid_accumulator.reset()
|
||||
|
||||
if step % 5000 == 0:
|
||||
manager.save(checkpoint_number=step)
|
||||
|
||||
print(step)
|
||||
|
||||
|
||||
+15
-23
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
from configs.iccv.config_abl_pyr_32_skirt import config
|
||||
from configs.post.config_abl_pyr_64_128_5 import config
|
||||
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = config['gpu']
|
||||
import tensorflow as tf
|
||||
@@ -43,11 +43,10 @@ from dataset import DatasetFactory, StaticDataset
|
||||
from custom_utils.smpl import SMPL
|
||||
from models.pyramid_model_optimized import PyramidNew as Pyramid
|
||||
from postprocessing import fix_collision
|
||||
from custom_utils.custom_utils import Accumulator
|
||||
|
||||
|
||||
def init_wandb():
|
||||
run = wandb.init(project='iccv', name=config['name'], notes=config['notes'], dir='/tmp', tags=config['tags'])
|
||||
run = wandb.init(project='ablation', name=config['name'], notes=config['notes'], dir='/wandb', tags=config['tags'])
|
||||
|
||||
artifact = wandb.Artifact('code', type='code')
|
||||
artifact.add_file('cvae_pyramid.py')
|
||||
@@ -62,14 +61,11 @@ def init_wandb():
|
||||
artifact.add_file('convnext/models/convnext_tf.py')
|
||||
config_file_names = [key for key in sys.modules.keys() if key.startswith('configs.post.')]
|
||||
for config_file_name in config_file_names:
|
||||
file_name = '/'.join(config_file_name.split('.')) + '.py'
|
||||
if os.path.exists(file_name):
|
||||
artifact.add_file(file_name)
|
||||
artifact.add_file('/'.join(config_file_name.split('.')) + '.py')
|
||||
run.log_artifact(artifact)
|
||||
|
||||
uv2mesh = UV2Mesh(res=256, is_skirt=config['is_skirt'], is_smpl_orig=config['is_cape'])
|
||||
|
||||
|
||||
def plot_3d(mesh_gt, mesh_pred_unposed_levels, faces, mesh_posed, collision, collision_faces, collision_color):
|
||||
fig = make_subplots(rows=1, cols=1+len(mesh_pred_unposed_levels)+1+1, start_cell="top-left", specs = [ [{ 'type': 'scene' } for _ in range(1+len(mesh_pred_unposed_levels)+1+1)] ])
|
||||
|
||||
@@ -795,8 +791,6 @@ if __name__ == '__main__':
|
||||
|
||||
ckpt = tf.train.Checkpoint(model=model)
|
||||
manager = tf.train.CheckpointManager(ckpt, 'checkpoints/post/' + config['name'], max_to_keep=20)
|
||||
train_accumulator = Accumulator()
|
||||
valid_accumulator = Accumulator()
|
||||
|
||||
# load_model(model, 'checkpoints/pyr_abl_32_skirt', iteration='180000')
|
||||
|
||||
@@ -852,33 +846,31 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
train_loss = train_step(batch)
|
||||
train_accumulator.update(train_loss)
|
||||
|
||||
if step % 50 == 0:
|
||||
data_valid = valid_iterator.get_next()
|
||||
data_valid = static_dataset_valid.expand_batch(batch_to_dict(data_valid, config['signature_dynamic']))
|
||||
valid_loss = valid_step(data_valid)
|
||||
valid_accumulator.update(valid_loss)
|
||||
|
||||
if train_loss['train/euclid_error'] < 0.015:
|
||||
to_log = { **train_loss, **valid_loss, **{ 'current_step': step} }
|
||||
if step % 5000 == 0 or (step < 5000 and step % 500 == 0):
|
||||
train_figs = plot_everything(batch, 'train')
|
||||
valid_figs = plot_everything(data_valid, 'valid')
|
||||
to_log = { **to_log, **train_figs, **valid_figs }
|
||||
|
||||
if step % 5000 == 0:
|
||||
manager.save(checkpoint_number=step)
|
||||
if step == 0:
|
||||
to_log = { **to_log, **{ 'model/summary': wandb.Html(get_summary_html(model)) } }
|
||||
|
||||
if train_loss['train/euclid_error'] < 0.004:
|
||||
if balancing_activated_step == 0:
|
||||
balancing_activated_step = step
|
||||
balancing_coeff = balancing_coeff + 1 / 20000
|
||||
|
||||
if step % 1000 == 0 or (step < 1000 and step % 100 == 0):
|
||||
to_log = dict({ **train_loss, **valid_loss, **{ 'current_step': step } })
|
||||
if step % 5000 == 0 or (step < 5000 and step % 1000 == 0):
|
||||
train_figs = plot_everything(batch, 'train')
|
||||
valid_figs = plot_everything(data_valid, 'valid')
|
||||
to_log = { **to_log, **train_figs, **valid_figs }
|
||||
if step == 0:
|
||||
to_log = { **to_log, **{ 'model/summary': wandb.Html(get_summary_html(model)) } }
|
||||
|
||||
to_log = { **to_log, **{ 'train/balancing_coeff': balancing_coeff, 'train/gamma': gamma } }
|
||||
|
||||
wandb.log(to_log, step = step)
|
||||
train_accumulator.reset()
|
||||
valid_accumulator.reset()
|
||||
|
||||
print(step)
|
||||
|
||||
|
||||
+3
-3
@@ -111,18 +111,18 @@ class Decoder(tf.keras.Model):
|
||||
|
||||
class VariationalEncoderNew(tf.keras.Model):
|
||||
|
||||
def __init__(self, depths, dims, kernel_size=7, latent_dim=64):
|
||||
def __init__(self, depths, dims, kernel_size=7):
|
||||
super(VariationalEncoderNew, self).__init__()
|
||||
|
||||
self.encoder = ConvNeXt(depths=depths, dims=dims, include_top=False, kernel_size=kernel_size)
|
||||
|
||||
self.mean_branch = tf.keras.Sequential(
|
||||
[Block(dim=latent_dim, drop_path=0, kernel_size=kernel_size,
|
||||
[Block(dim=64, drop_path=0, kernel_size=kernel_size,
|
||||
layer_scale_init_value=1e-6, prefix=f'bottleneck{j}') for j in range(5)]
|
||||
)
|
||||
|
||||
self.var_branch = tf.keras.Sequential(
|
||||
[Block(dim=latent_dim, drop_path=0, kernel_size=kernel_size,
|
||||
[Block(dim=64, drop_path=0, kernel_size=kernel_size,
|
||||
layer_scale_init_value=1e-6, prefix=f'bottleneck{j}') for j in range(5)]
|
||||
)
|
||||
|
||||
|
||||
@@ -179,10 +179,10 @@ class CVAENew(tf.keras.Model):
|
||||
if config['use_curvature']:
|
||||
self.curv_enc.trainable = False
|
||||
|
||||
self.encoder = VariationalEncoderNew(config['cvae']['encoder_depths'], config['cvae']['encoder_dims'], kernel_size=config['cvae']['kernel_size'], latent_dim=config['cvae']['latent_dim'])
|
||||
self.encoder = VariationalEncoderNew(config['cvae']['encoder_depths'], config['cvae']['encoder_dims'], kernel_size=config['cvae']['kernel_size'])
|
||||
self.decoder = DecoderNew(config['cvae']['decoder_depths'], config['cvae']['decoder_dims'], config['cvae']['kernel_size'])
|
||||
|
||||
self.reshape = tf.keras.layers.Reshape((8, 4, config['cvae']['latent_dim']))
|
||||
self.reshape = tf.keras.layers.Reshape((8, 4, 64))
|
||||
|
||||
if config['avg_garment_path'] != '':
|
||||
self.avg_garment = np.load(config['avg_garment_path'])
|
||||
|
||||
+3
-3
@@ -16,10 +16,10 @@ class Smoother(tf.keras.Model):
|
||||
def __init__(self, ):
|
||||
super().__init__()
|
||||
self.a = sp_matrix_to_sp_tensor(sio.loadmat("custom_utils/ssmpl0.mat")['L'].tocoo())
|
||||
self.conv1 = GCNConv(16, activation='tanh', use_bias=False)
|
||||
self.conv1 = GCNConv(3, activation='tanh', use_bias=False)
|
||||
self.conv2 = GCNConv(3, activation='tanh', use_bias=False)
|
||||
# self.conv3 = GCNConv(512, activation='tanh', use_bias=False)
|
||||
# self.conv4 = GCNConv(512, activation='tanh', use_bias=False)
|
||||
# self.conv3 = GCNConv(3, activation='tanh', use_bias=False)
|
||||
# self.conv4 = GCNConv(64, activation='tanh', use_bias=False)
|
||||
# self.conv5 = GCNConv(64, activation='tanh', use_bias=False)
|
||||
self.conv6 = GCNConv(3, activation='tanh', use_bias=False)
|
||||
|
||||
|
||||
@@ -102,12 +102,13 @@ class PyramidLevelNew(tf.keras.Model):
|
||||
super(PyramidLevelNew, self).__init__()
|
||||
self.size = config['resolution']
|
||||
|
||||
self.encoder = VariationalEncoderNew(config['encoder_depths'], config['encoder_dims'], kernel_size=config['kernel_size'], latent_dim=config['latent_dim'])
|
||||
self.encoder = VariationalEncoderNew(config['encoder_depths'], config['encoder_dims'], kernel_size=config['kernel_size'])
|
||||
self.decoder = DecoderNew(config['decoder_depths'], config['decoder_dims'], config['kernel_size'])
|
||||
|
||||
self.upscale_enhancer = None
|
||||
if config['upscale_enhancer'] != '':
|
||||
self.upscale_enhancer = UpscalerBasicConv(config['resolution'], kernel_size=config['kernel_size'])
|
||||
k_size = config['upscale_enhancer_kernel_size'] if 'upscale_enhancer_kernel_size' in config.keys() else ((3 if config['resolution'] <= 64 else 5))
|
||||
self.upscale_enhancer = UpscalerBasicConv(config['resolution'], kernel_size=k_size)
|
||||
load_model(self.upscale_enhancer, config['upscale_enhancer'])
|
||||
self.upscale_enhancer.trainable = not config['upscale_enhancer_freeze']
|
||||
|
||||
@@ -116,7 +117,7 @@ class PyramidLevelNew(tf.keras.Model):
|
||||
else:
|
||||
self.avg_garment = None
|
||||
|
||||
self.reshape = tf.keras.layers.Reshape((8, 4, config['latent_dim']))
|
||||
self.reshape = tf.keras.layers.Reshape((8, 4, 64))
|
||||
|
||||
|
||||
def enhance(self, low, mask, training=None):
|
||||
|
||||
@@ -343,7 +343,11 @@ class PyramidNew(tf.keras.Model):
|
||||
for i in range(1, len(self.levels)):
|
||||
input = levels_input[i]
|
||||
input[0] = input[0] - pred
|
||||
input_min, input_max = tf.reduce_min(input[0], axis=[1,2,3]), tf.reduce_max(input[0], axis=[1,2,3])
|
||||
input[0] = (input[0] - input_min[:,None,None,None]) / (input_max - input_min)[:,None,None,None]
|
||||
input[0] = input[0] * input[-2][:,:,:,None] # uv_mask_res
|
||||
pred_level, mean, logvar = self.levels[i](input, z_cond, training=training)
|
||||
pred_level = ( (pred_level * (input_max - input_min)[:,None,None,None]) + input_min[:,None,None,None] ) * input[-2][:,:,:,None] # uv_mask_res
|
||||
pred = pred + pred_level
|
||||
if i != len(self.levels) - 1:
|
||||
pred = self.levels[i].enhance(pred, levels_input[i][-2], training=training)
|
||||
|
||||
+4
-4
@@ -131,13 +131,13 @@ class UpscalerBasicConv(tf.keras.Model):
|
||||
self.low_res = low_res
|
||||
|
||||
self.seq = tf.keras.Sequential([
|
||||
tf.keras.layers.Conv2D(64, kernel_size=kernel_size, padding='same', activation='relu', name='upscale_enhancer_conv_1'),
|
||||
tf.keras.layers.Conv2D(256, kernel_size=kernel_size, padding='same', activation='relu', name='upscale_enhancer_conv_1'),
|
||||
tf.keras.layers.BatchNormalization(name='upscale_enhancer_batch_norm_1'),
|
||||
tf.keras.layers.Conv2D(64, kernel_size=kernel_size, padding='same', activation='relu', name='upscale_enhancer_conv_2'),
|
||||
tf.keras.layers.Conv2D(128, kernel_size=kernel_size, padding='same', activation='relu', name='upscale_enhancer_conv_2'),
|
||||
tf.keras.layers.BatchNormalization(name='upscale_enhancer_batch_norm_2'),
|
||||
tf.keras.layers.Conv2D(16, kernel_size=kernel_size, padding='same', activation='relu', name='upscale_enhancer_conv_3'),
|
||||
tf.keras.layers.Conv2D(64, kernel_size=kernel_size, padding='same', activation='relu', name='upscale_enhancer_conv_3'),
|
||||
tf.keras.layers.BatchNormalization(name='upscale_enhancer_batch_norm_3'),
|
||||
tf.keras.layers.Conv2D(16, kernel_size=kernel_size, padding='same', activation='relu', name='upscale_enhancer_conv_4'),
|
||||
tf.keras.layers.Conv2D(32, kernel_size=kernel_size, padding='same', activation='relu', name='upscale_enhancer_conv_4'),
|
||||
tf.keras.layers.BatchNormalization(name='upscale_enhancer_batch_norm_4'),
|
||||
tf.keras.layers.Dense(3, activation='tanh', name='upscale_enhancer_dense_final'),
|
||||
])
|
||||
|
||||
+26
-56
@@ -1,5 +1,5 @@
|
||||
import os
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = "2"
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = "6"
|
||||
import tensorflow as tf
|
||||
|
||||
gpus = tf.config.experimental.list_physical_devices('GPU')
|
||||
@@ -35,18 +35,7 @@ from models.upscaler import UpscalerBasicConv as Upscaler
|
||||
# !!!!!!!!!! CHANGE SSIM BASED ON RES
|
||||
# !!!!!!!!!! CHANGE SKIRT OR NOT
|
||||
|
||||
|
||||
low_res = 256
|
||||
is_skirt = True
|
||||
is_cape = False
|
||||
is_male = False
|
||||
skirt_modifier = '_skirt' if is_skirt else ''
|
||||
cape_modifier = '_cape' if is_cape else ''
|
||||
gender_modifier = '' if not is_cape else ('_m' if is_male else '_f')
|
||||
smpl_res = 3638 if is_cape else 14475
|
||||
|
||||
|
||||
name=f'iccv_{low_res}_2' + skirt_modifier + cape_modifier + gender_modifier
|
||||
name='256_512_skirt'
|
||||
def init_wandb():
|
||||
run = wandb.init(project='upscale', name=name,
|
||||
notes='\
|
||||
@@ -70,10 +59,15 @@ smaller features | \
|
||||
artifact.add_file('convnext/models/convnext_tf.py')
|
||||
run.log_artifact(artifact)
|
||||
|
||||
is_skirt = True
|
||||
is_cape = False
|
||||
skirt_modifier = '_skirt' if is_skirt else ''
|
||||
smpl_res = 3638 if is_cape else 14475
|
||||
|
||||
uv2mesh = UV2Mesh(res=256, is_skirt=is_skirt, is_smpl_orig=is_cape)
|
||||
|
||||
|
||||
|
||||
def plot_3d(mesh_gt, mesh_pred_unposed, faces):
|
||||
mesh_pred_unposed[:,2] += 1
|
||||
fig = go.Figure(data=[
|
||||
@@ -111,22 +105,18 @@ def plot_3d(mesh_gt, mesh_pred_unposed, faces):
|
||||
return fig
|
||||
|
||||
|
||||
@tf.function
|
||||
# @tf.function
|
||||
def train_step(batch):
|
||||
with tf.GradientTape() as tape:
|
||||
pred = model([batch['uv_unposed' + low_resolution_modifier], batch['uv_mask' + low_resolution_modifier]], training=True)
|
||||
pred = tf.image.resize(pred, size=(high_res, high_res//2), method=tf.image.ResizeMethod.BILINEAR)
|
||||
pred = tf.image.resize(pred, size=(high_res, high_res//2), method=tf.image.ResizeMethod.LANCZOS5)
|
||||
|
||||
mesh_pred = uv2mesh(pred)
|
||||
mesh_orig = batch['mesh_unposed']
|
||||
|
||||
l1_loss = tf.reduce_mean(tf.reduce_sum(((tf.math.abs(batch['uv_unposed' + high_resolution_modifier] - pred * batch['uv_mask' + high_resolution_modifier][:,:,:,tf.newaxis]) )), axis=-1))
|
||||
|
||||
if low_res == 32:
|
||||
ms_ssim = tf.reduce_mean(tf.image.ssim(pred * batch['uv_mask' + high_resolution_modifier][:,:,:,tf.newaxis] + 1, batch['uv_unposed' + high_resolution_modifier] * batch['uv_mask' + high_resolution_modifier][:,:,:,tf.newaxis] + 1, max_val=2))
|
||||
else:
|
||||
ms_ssim = tf.reduce_mean(tf.image.ssim_multiscale(pred * batch['uv_mask' + high_resolution_modifier][:,:,:,tf.newaxis] + 1, batch['uv_unposed' + high_resolution_modifier] * batch['uv_mask' + high_resolution_modifier][:,:,:,tf.newaxis] + 1, max_val=2, power_factors=(0.5, 0.2, 0.2, 0.1)))
|
||||
|
||||
# ms_ssim = tf.reduce_mean(tf.image.ssim(pred * batch['uv_mask' + high_resolution_modifier][:,:,:,tf.newaxis] + 1, batch['uv_unposed' + high_resolution_modifier] * batch['uv_mask' + high_resolution_modifier][:,:,:,tf.newaxis] + 1, max_val=2))
|
||||
loss = 1e3 * (1 - ms_ssim)
|
||||
|
||||
metric = tf.reduce_sum(tf.math.sqrt(tf.reduce_sum(batch['mesh_mask'][:,:,tf.newaxis] * (mesh_orig - mesh_pred) ** 2, axis=-1))) / tf.reduce_sum(batch['mesh_mask'])
|
||||
@@ -135,31 +125,29 @@ def train_step(batch):
|
||||
return { 'train/loss': loss, 'train/l1_loss': l1_loss, 'train/euclid_error': metric, 'train/ms_ssim': ms_ssim }
|
||||
|
||||
|
||||
|
||||
@tf.function
|
||||
def valid_step(batch):
|
||||
pred = model([batch['uv_unposed' + low_resolution_modifier], batch['uv_mask' + low_resolution_modifier]], training=False)
|
||||
pred = tf.image.resize(pred, size=(high_res, high_res//2), method=tf.image.ResizeMethod.BILINEAR)
|
||||
pred = tf.image.resize(pred, size=(high_res, high_res//2), method=tf.image.ResizeMethod.LANCZOS5)
|
||||
|
||||
mesh_pred = uv2mesh(pred)
|
||||
mesh_orig = batch['mesh_unposed']
|
||||
|
||||
l1_loss = tf.reduce_mean(tf.reduce_sum(((tf.math.abs(batch['uv_unposed' + high_resolution_modifier] - pred * batch['uv_mask' + high_resolution_modifier][:,:,:,tf.newaxis]) )), axis=-1))
|
||||
|
||||
if low_res == 32:
|
||||
ms_ssim = tf.reduce_mean(tf.image.ssim(pred * batch['uv_mask' + high_resolution_modifier][:,:,:,tf.newaxis] + 1, batch['uv_unposed' + high_resolution_modifier] * batch['uv_mask' + high_resolution_modifier][:,:,:,tf.newaxis] + 1, max_val=2))
|
||||
else:
|
||||
ms_ssim = tf.reduce_mean(tf.image.ssim_multiscale(pred * batch['uv_mask' + high_resolution_modifier][:,:,:,tf.newaxis] + 1, batch['uv_unposed' + high_resolution_modifier] * batch['uv_mask' + high_resolution_modifier][:,:,:,tf.newaxis] + 1, max_val=2, power_factors=(0.5, 0.2, 0.2, 0.1)))
|
||||
|
||||
# ms_ssim = tf.reduce_mean(tf.image.ssim(pred * batch['uv_mask' + high_resolution_modifier][:,:,:,tf.newaxis] + 1, batch['uv_unposed' + high_resolution_modifier] * batch['uv_mask' + high_resolution_modifier][:,:,:,tf.newaxis] + 1, max_val=2))
|
||||
loss = 1e3 * (1 - ms_ssim)
|
||||
|
||||
metric = tf.reduce_sum(tf.math.sqrt(tf.reduce_sum(batch['mesh_mask'][:,:,tf.newaxis] * (mesh_orig - mesh_pred) ** 2, axis=-1))) / tf.reduce_sum(batch['mesh_mask'])
|
||||
return { 'valid/loss': loss, 'valid/l1_loss': l1_loss, 'valid/euclid_error': metric, 'valid/ms_ssim': ms_ssim }
|
||||
|
||||
|
||||
|
||||
def plot_everything(batch: dict, type: str):
|
||||
|
||||
pred = model([batch['uv_unposed' + low_resolution_modifier], batch['uv_mask' + low_resolution_modifier]], training=False)
|
||||
pred = tf.image.resize(pred, size=(high_res, high_res//2), method=tf.image.ResizeMethod.BILINEAR)
|
||||
pred = tf.image.resize(pred, size=(high_res, high_res//2), method=tf.image.ResizeMethod.LANCZOS5)
|
||||
|
||||
mesh_pred = uv2mesh(pred)
|
||||
mesh_orig = batch['mesh_unposed']
|
||||
@@ -180,6 +168,7 @@ def plot_everything(batch: dict, type: str):
|
||||
return { **figs, **{ type + '/images': imgs} }
|
||||
|
||||
|
||||
|
||||
def train():
|
||||
valid_iterator = iter(dataset_valid)
|
||||
|
||||
@@ -188,7 +177,6 @@ def train():
|
||||
batch = static_dataset_train.expand_batch(batch_to_dict(batch, signature_dynamic))
|
||||
train_loss = train_step(batch)
|
||||
|
||||
if step % 100 == 0:
|
||||
data_valid = valid_iterator.get_next()
|
||||
data_valid = static_dataset_valid.expand_batch(batch_to_dict(data_valid, signature_dynamic))
|
||||
valid_loss = valid_step(data_valid)
|
||||
@@ -205,6 +193,7 @@ def train():
|
||||
if step % 5000 == 0:
|
||||
manager.save(checkpoint_number=step)
|
||||
|
||||
|
||||
wandb.log(to_log, step = step)
|
||||
|
||||
print(step)
|
||||
@@ -215,8 +204,8 @@ def train():
|
||||
step += 1
|
||||
|
||||
if __name__ == '__main__':
|
||||
init_wandb()
|
||||
# allow_memory_growth()
|
||||
# init_wandb()
|
||||
allow_memory_growth()
|
||||
parser = argparse.ArgumentParser(description='')
|
||||
parser.add_argument('--name', type=str)
|
||||
args = vars(parser.parse_args())
|
||||
@@ -225,6 +214,7 @@ if __name__ == '__main__':
|
||||
# uv_mask_body = np.load('custom_utils/mask_256x512.npy')
|
||||
# uv_mask_body = cv2.dilate(uv_mask_body.astype(np.float32), cv2.getStructuringElement(cv2.MORPH_RECT, (2 * 2 + 1, 2 * 2 + 1), (2, 2)), iterations=2)
|
||||
|
||||
low_res = 32
|
||||
high_res = 512
|
||||
uv_mask_body = tf.ones((low_res, low_res//2))
|
||||
low_resolution_modifier = '_' + str(low_res)
|
||||
@@ -244,44 +234,24 @@ if __name__ == '__main__':
|
||||
'uv_mask' + low_resolution_modifier: (low_res, low_res//2,),
|
||||
}
|
||||
|
||||
if not is_skirt:
|
||||
dataset_train = factory.get_dataset(folder='/home/workspace/local-data/train', batch_size=8, signature=signature_dynamic, resolutions=[high_res, low_res], in_memory=False, is_cape=is_cape)
|
||||
static_dataset_train = StaticDataset(folder='/home/workspace/local-data/train', signature=signature_static, resolutions=[high_res, low_res], in_memory=True, is_cape=is_cape)
|
||||
dataset_valid = factory.get_dataset(folder='/home/workspace/local-data/valid', batch_size=8, signature=signature_dynamic,resolutions=[high_res, low_res], in_memory=False, is_cape=is_cape)
|
||||
static_dataset_valid = StaticDataset(folder='/home/workspace/local-data/valid', signature=signature_static, resolutions=[high_res, low_res], in_memory=True, is_cape=is_cape)
|
||||
|
||||
if is_skirt:
|
||||
dataset_train = factory.get_dataset(folder='/home/workspace/data/dataset/local-cache/train_skirt', batch_size=8, signature=signature_dynamic, resolutions=[high_res, low_res], in_memory=False, is_cape=is_cape)
|
||||
static_dataset_train = StaticDataset(folder='/home/workspace/data/dataset/local-cache/train_skirt', signature=signature_static, resolutions=[high_res, low_res], in_memory=True, is_cape=is_cape)
|
||||
dataset_valid = factory.get_dataset(folder='/home/workspace/local-data/valid_skirt', batch_size=8, signature=signature_dynamic,resolutions=[high_res, low_res], in_memory=False, is_cape=is_cape)
|
||||
static_dataset_valid = StaticDataset(folder='/home/workspace/local-data/valid_skirt', signature=signature_static, resolutions=[high_res, low_res], in_memory=True, is_cape=is_cape)
|
||||
|
||||
if is_cape:
|
||||
if is_male:
|
||||
dataset_train = factory.get_dataset(folder='/home/workspace/local-data/cape_processed/train/male', batch_size=8, signature=signature_dynamic, resolutions=[high_res, low_res], in_memory=False, is_cape=is_cape)
|
||||
static_dataset_train = StaticDataset(folder='/home/workspace/local-data/cape_processed/train/male', signature=signature_static, resolutions=[high_res, low_res], in_memory=True, is_cape=is_cape)
|
||||
dataset_valid = factory.get_dataset(folder='/home/workspace/local-data/cape_processed/test/male', batch_size=8, signature=signature_dynamic, resolutions=[high_res, low_res], in_memory=False, is_cape=is_cape)
|
||||
static_dataset_valid = StaticDataset(folder='/home/workspace/local-data/cape_processed/test/male', signature=signature_static, resolutions=[high_res, low_res], in_memory=True, is_cape=is_cape)
|
||||
else:
|
||||
dataset_train = factory.get_dataset(folder='/home/workspace/local-data/cape_processed/train/female', batch_size=8, signature=signature_dynamic, resolutions=[high_res, low_res], in_memory=False, is_cape=is_cape)
|
||||
static_dataset_train = StaticDataset(folder='/home/workspace/local-data/cape_processed/train/female', signature=signature_static, resolutions=[high_res, low_res], in_memory=True, is_cape=is_cape)
|
||||
dataset_valid = factory.get_dataset(folder='/home/workspace/local-data/cape_processed/test/female', batch_size=8, signature=signature_dynamic, resolutions=[high_res, low_res], in_memory=False, is_cape=is_cape)
|
||||
static_dataset_valid = StaticDataset(folder='/home/workspace/local-data/cape_processed/test/female', signature=signature_static, resolutions=[high_res, low_res], in_memory=True, is_cape=is_cape)
|
||||
# dataset_train = factory.get_dataset(folder='/home/workspace/local-data/cape_processed/train/male', batch_size=8, signature=signature_dynamic, resolutions=[high_res, low_res], in_memory=False, is_cape=is_cape)
|
||||
# static_dataset_train = StaticDataset(folder='/home/workspace/local-data/cape_processed/train/male', signature=signature_static, resolutions=[high_res, low_res], in_memory=True, is_cape=is_cape)
|
||||
# dataset_valid = factory.get_dataset(folder='/home/workspace/local-data/cape_processed/test/male', batch_size=8, signature=signature_dynamic, resolutions=[high_res, low_res], in_memory=False, is_cape=is_cape)
|
||||
# static_dataset_valid = StaticDataset(folder='/home/workspace/local-data/cape_processed/test/male', signature=signature_static, resolutions=[high_res, low_res], in_memory=True, is_cape=is_cape)
|
||||
|
||||
|
||||
if low_res == 32 or low_res == 64:
|
||||
model = Upscaler(low_res=low_res, kernel_size=3)
|
||||
elif low_res == 128 or low_res == 256:
|
||||
model = Upscaler(low_res=low_res, kernel_size=5)
|
||||
else:
|
||||
model = Upscaler(low_res=low_res, kernel_size=7)
|
||||
|
||||
|
||||
optimizer = tf.optimizers.Adam(learning_rate=0.0001)
|
||||
folder = 'models/ae_logs/'
|
||||
|
||||
ckpt = tf.train.Checkpoint(model=model)
|
||||
manager = tf.train.CheckpointManager(ckpt, 'checkpoints/iccv/' + name, max_to_keep=20)
|
||||
# load_model(model, f'checkpoints/iccv/iccv_{low_res}' + skirt_modifier)
|
||||
manager = tf.train.CheckpointManager(ckpt, 'checkpoints/' + name, max_to_keep=20)
|
||||
load_model(model, 'checkpoints/32_512_4')
|
||||
|
||||
train()
|
||||
Reference in New Issue
Block a user