From f4249cb6b00de083557f727791e78c85fa81375c Mon Sep 17 00:00:00 2001 From: Hunor Laczko Date: Tue, 23 May 2023 18:20:17 +0200 Subject: [PATCH] small --- configs/pyr_64_cape_m_3.py | 296 +++++++++++++++++++++++++++++++++++++ run.py | 2 +- scripts/cvae_pyramid.py | 8 +- 3 files changed, 301 insertions(+), 5 deletions(-) create mode 100644 configs/pyr_64_cape_m_3.py diff --git a/configs/pyr_64_cape_m_3.py b/configs/pyr_64_cape_m_3.py new file mode 100644 index 0000000..9ff549b --- /dev/null +++ b/configs/pyr_64_cape_m_3.py @@ -0,0 +1,296 @@ +from utils.convnext_utils import CNBlockConfig + +config = dict() + +config['gpu'] = '0' +config['name'] = 'pyr_torch_64_cape_m_3' +config['notes'] = 'without edge loss' +config['tags'] = ['pyr', 'iccv', 'torch'] +config['script'] = 'scripts/cvae_pyramid.py' + +config['batch_size'] = 4 +config['is_skirt'] = False +config['is_cape'] = True +config['device'] = 'cuda' + + +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['use_curvature'] = True + +config['pretrained_model'] = '' +config['pretrained_model_iteration'] = '' + +config['pyramid'] = dict() +config['pyramid']['resolutions'] = [64] +config['pyramid']['pretrained_pyramid'] = '' +config['pyramid']['pretrained_pyramid_iteration'] = '' +config['pyramid']['final_upscale_enhancer'] = '' + +config['train_dir'] = '/data-local/127/cape_processed/train/male' +config['valid_dir'] = '/data-local/127/cape_processed/test/male' +config['test_dir'] = '/data-local/127/cape_processed/test/male' +config['train_frames'] = None +config['valid_frames'] = None + +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.0001 +config['balancing_activation_limit'] = 0.015 +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']: set = { 'id', + 'frame_nr', + 'pose_shape', + 'uv_body_posed', + 'mesh_body_posed', + 'mesh_posed', + 'mesh_unposed', + 'uv_unposed', + 'uv_curvature', + 'uv_static', + 'mesh_mask', + 'uv_mask', + } + +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'].add('uv_body_posed' + res_modifier) + config['signature'].add('uv_unposed' + res_modifier) + config['signature'].add('uv_curvature' + res_modifier) + config['signature'].add('uv_static' + res_modifier) + config['signature'].add('uv_mask' + res_modifier) + + +config['static_model'] = 'checkpoints/iccv/torch/static_torch_cape_m' +config['body_model'] = 'checkpoints/iccv/torch/body_torch_cape_m' +config['curvature_model'] = 'checkpoints/iccv/torch/curv_torch_cape_m' +config['freeze_encoders'] = True + + +config['pyramid']['levels'] = [] +for res in config['pyramid']['resolutions']: + if res == 512: + level = dict() + level['resolution'] = 512 + level['bottleneck_size'] = 64 * config['bottleneck_scale'] + level['kernel_size'] = 7 + level['upscale_enhancer'] = '' + level['input_features'] = 3+3+3+7 if config['use_curvature'] else 3+3+3 + + block_setting = [ + CNBlockConfig(16, 32, 3), + CNBlockConfig(32, 64, 3), + CNBlockConfig(64, 128, 3), + CNBlockConfig(128, level['bottleneck_size'], 9), + CNBlockConfig(level['bottleneck_size'], None, 3), + ] + + block_setting_reverse = [ + CNBlockConfig(level['bottleneck_size'] * 2, 128, 3), + CNBlockConfig(128, 64, 9), + CNBlockConfig(64, 32, 3), + CNBlockConfig(32, 16, 3), + CNBlockConfig(16, 3, 3), + ] + + level['encoder_block_settings'] = block_setting + level['decoder_block_settings'] = block_setting_reverse + config['pyramid']['levels'].append(level) + elif res == 256: + level = dict() + level['resolution'] = 256 + level['kernel_size'] = 5 + level['upscale_enhancer'] = 'checkpoints/iccv/torch/iccv_256_cape_m' + level['upscale_enhancer_freeze'] = True + level['bottleneck_size'] = 64 * config['bottleneck_scale'] + level['input_features'] = 3+3+3+7 if config['use_curvature'] else 3+3+3 + + block_setting = [ + CNBlockConfig(64, 128, 3), + CNBlockConfig(128, 128, 3), + CNBlockConfig(128, level['bottleneck_size'], 9), + CNBlockConfig(level['bottleneck_size'], None, 3), + ] + + block_setting_reverse = [ + CNBlockConfig(level['bottleneck_size'] * 2, 128, 3), + CNBlockConfig(128, 128, 9), + CNBlockConfig(128, 65, 3), + CNBlockConfig(64, 3, 3), + ] + + level['encoder_block_settings'] = block_setting + level['decoder_block_settings'] = block_setting_reverse + config['pyramid']['levels'].append(level) + elif res == 128: + level = dict() + level['resolution'] = 128 + level['kernel_size'] = 5 + level['upscale_enhancer'] = 'checkpoints/iccv/torch/iccv_128_cape_m' + level['upscale_enhancer_freeze'] = True + level['bottleneck_size'] = 64 * config['bottleneck_scale'] + level['input_features'] = 3+3+3+7 if config['use_curvature'] else 3+3+3 + + block_setting = [ + CNBlockConfig(64, 128, 9), + CNBlockConfig(128, level['bottleneck_size'], 9), + CNBlockConfig(level['bottleneck_size'], None, 9), + ] + + block_setting_reverse = [ + CNBlockConfig(level['bottleneck_size'] * 2, 128, 9), + CNBlockConfig(128, 128, 9), + CNBlockConfig(64, 3, 9), + ] + + level['encoder_block_settings'] = block_setting + level['decoder_block_settings'] = block_setting_reverse + config['pyramid']['levels'].append(level) + elif res == 64: + level = dict() + level['resolution'] = 64 + level['kernel_size'] = 3 + level['upscale_enhancer'] = 'checkpoints/iccv/torch/iccv_64_cape_m' + level['upscale_enhancer_freeze'] = True + level['bottleneck_size'] = 64 * config['bottleneck_scale'] + level['input_features'] = 3+3+3+7 if config['use_curvature'] else 3+3+3 + + block_setting = [ + CNBlockConfig(64, level['bottleneck_size'], 9), + CNBlockConfig(level['bottleneck_size'], None, 9), + ] + + block_setting_reverse = [ + CNBlockConfig(level['bottleneck_size'] * 2, 64, 9), + CNBlockConfig(64, 3, 9), + ] + + level['encoder_block_settings'] = block_setting + level['decoder_block_settings'] = block_setting_reverse + config['pyramid']['levels'].append(level) + elif res == 32: + level = dict() + level['resolution'] = 32 + level['kernel_size'] = 3 + level['upscale_enhancer'] = 'checkpoints/iccv/torch/iccv_32_cape_m' + level['upscale_enhancer_freeze'] = True + level['bottleneck_size'] = 64 * config['bottleneck_scale'] + level['input_features'] = 3+3+3+7 if config['use_curvature'] else 3+3+3 + + block_setting = [ + CNBlockConfig(level['bottleneck_size'], None, 16), + ] + + block_setting_reverse = [ + CNBlockConfig(level['bottleneck_size'] * 2, 3, 16), + ] + + level['encoder_block_settings'] = block_setting + level['decoder_block_settings'] = block_setting_reverse + config['pyramid']['levels'].append(level) + else: + raise NotImplementedError + + +####################### cond_ae_curv ############################ +config['cond_ae_curv'] = dict() +config['cond_ae_curv']['device'] = config['device'] +config['cond_ae_curv']['is_label'] = True +# config['cond_ae_curv']['latent_dim'] = config['latent_dim'] +config['cond_ae_curv']['kernel_size'] = 7 +config['cond_ae_curv']['bottleneck_size'] = 40 * config['bottleneck_scale'] + +block_setting = [ + CNBlockConfig(16, 32, 3), + CNBlockConfig(32, 64, 3), + CNBlockConfig(64, 128, 9), + CNBlockConfig(128, config['cond_ae_curv']['bottleneck_size'], 9), + CNBlockConfig(config['cond_ae_curv']['bottleneck_size'], None, 3), +] + +block_setting_reverse = [ + CNBlockConfig(config['cond_ae_curv']['bottleneck_size'], 128, 3), + CNBlockConfig(128, 64, 9), + CNBlockConfig(64, 32, 9), + CNBlockConfig(32, 16, 3), + CNBlockConfig(16, 3, 3), +] + +config['cond_ae_curv']['encoder_block_settings'] = block_setting +config['cond_ae_curv']['decoder_block_settings'] = block_setting_reverse +config['cond_ae_curv']['activation'] = 'tanh' + +####################### cond_ae_body ############################ +config['cond_ae_body'] = dict() +config['cond_ae_body']['device'] = config['device'] +config['cond_ae_body']['is_label'] = False +# config['cond_ae_body']['latent_dim'] = config['latent_dim'] +config['cond_ae_body']['kernel_size'] = 7 +config['cond_ae_body']['bottleneck_size'] = 16 * config['bottleneck_scale'] + +block_setting = [ + CNBlockConfig(16, 32, 3), + CNBlockConfig(32, 64, 3), + CNBlockConfig(64, 128, 9), + CNBlockConfig(128, config['cond_ae_body']['bottleneck_size'], 9), + CNBlockConfig(config['cond_ae_body']['bottleneck_size'], None, 3), +] + +block_setting_reverse = [ + CNBlockConfig(config['cond_ae_body']['bottleneck_size'], 128, 3), + CNBlockConfig(128, 64, 9), + CNBlockConfig(64, 32, 9), + CNBlockConfig(32, 16, 3), + CNBlockConfig(16, 3, 3), +] + +config['cond_ae_body']['encoder_block_settings'] = block_setting +config['cond_ae_body']['decoder_block_settings'] = block_setting_reverse +config['cond_ae_body']['activation'] = 'tanh' + +####################### cond_ae_static ############################ +config['cond_ae_static'] = dict() +config['cond_ae_static']['device'] = config['device'] +config['cond_ae_static']['is_label'] = False +# config['cond_ae_static']['latent_dim'] = config['latent_dim'] +config['cond_ae_static']['kernel_size'] = 7 +config['cond_ae_static']['bottleneck_size'] = 8 * config['bottleneck_scale'] + +block_setting = [ + CNBlockConfig(8, 16, 3), + CNBlockConfig(16, 32, 3), + CNBlockConfig(32, 64, 3), + CNBlockConfig(64, config['cond_ae_static']['bottleneck_size'], 9), + CNBlockConfig(config['cond_ae_static']['bottleneck_size'], None, 3), +] + +block_setting_reverse = [ + CNBlockConfig(config['cond_ae_static']['bottleneck_size'], 64, 3), + CNBlockConfig(64, 32, 9), + CNBlockConfig(32, 16, 3), + CNBlockConfig(16, 8, 3), + CNBlockConfig(8, 3, 3), +] + +config['cond_ae_static']['encoder_block_settings'] = block_setting +config['cond_ae_static']['decoder_block_settings'] = block_setting_reverse +config['cond_ae_static']['activation'] = 'tanh' \ No newline at end of file diff --git a/run.py b/run.py index 0e01c69..e1d7d52 100644 --- a/run.py +++ b/run.py @@ -1,6 +1,6 @@ import os import sys -from configs.abl_all import config +from configs.pyr_64_cape_m import config import argparse # parser = argparse.ArgumentParser(description='') diff --git a/scripts/cvae_pyramid.py b/scripts/cvae_pyramid.py index 52bfd41..32c3fcd 100644 --- a/scripts/cvae_pyramid.py +++ b/scripts/cvae_pyramid.py @@ -260,9 +260,9 @@ def train_step(batch): kl = kl_loss(mean, logvar) if config['use_extra_losses']: - reconstr_loss_total = reconstr_loss_total + config['pyramid']['loss_weights'][i] * (e_loss + l2_loss + l2_mesh_loss) + reconstr_loss_total = reconstr_loss_total + config['pyramid']['loss_weights'][i] * (l2_loss + l2_mesh_loss) if not config['is_cape']: - reconstr_loss_total = reconstr_loss_total + config['pyramid']['loss_weights'][i] * (c_loss) * config['reg_loss_coeff'] + reconstr_loss_total = reconstr_loss_total + config['pyramid']['loss_weights'][i] * (e_loss + c_loss) * config['reg_loss_coeff'] else: reconstr_loss_total = reconstr_loss_total + config['pyramid']['loss_weights'][i] * (l2_loss) @@ -345,9 +345,9 @@ def valid_step(batch): kl = kl_loss(mean, logvar) if config['use_extra_losses']: - reconstr_loss_total = reconstr_loss_total + config['pyramid']['loss_weights'][i] * (e_loss + l2_loss + l2_mesh_loss) + reconstr_loss_total = reconstr_loss_total + config['pyramid']['loss_weights'][i] * (l2_loss + l2_mesh_loss) if not config['is_cape']: - reconstr_loss_total = reconstr_loss_total + config['pyramid']['loss_weights'][i] * (c_loss) * config['reg_loss_coeff'] + reconstr_loss_total = reconstr_loss_total + config['pyramid']['loss_weights'][i] * (e_loss + c_loss) * config['reg_loss_coeff'] else: reconstr_loss_total = reconstr_loss_total + config['pyramid']['loss_weights'][i] * (l2_loss)