Compare commits
3
Commits
iccv_abl
...
gnn_decoder
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb4e7dcc65 | ||
|
|
c1113379ec | ||
|
|
c5d576f11f |
@@ -3,11 +3,14 @@ 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" > 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_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_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" > 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_skirt" > nohup/iccv/encoders/body_iccv_1_skirt.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_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 " > 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_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_f" > nohup/iccv/encoders/curv_iccv_1_cape_f.out 2>&1 &
|
||||||
|
nohup python cvae.py --name="lhunor_cvae_iccv_gnn_decoder_1" > nohup/iccv/cvae_iccv_gnn_decoder_1.out 2>&1 &
|
||||||
|
|
||||||
skirts!!!!
|
skirts!!!!
|
||||||
pyramid next week
|
pyramid next week
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from configs.iccv.config_ae_static_cape_f import config
|
from configs.iccv.config_ae_static_cape_m import config
|
||||||
os.environ["CUDA_VISIBLE_DEVICES"] = config['gpu']
|
os.environ["CUDA_VISIBLE_DEVICES"] = config['gpu']
|
||||||
|
|
||||||
import tensorflow as tf
|
import tensorflow as tf
|
||||||
|
|||||||
@@ -14,17 +14,19 @@ config['use_extra_losses'] = True # edge, collision, 3d mesh
|
|||||||
config['use_offsets'] = True
|
config['use_offsets'] = True
|
||||||
|
|
||||||
config['use_norm_loss'] = True
|
config['use_norm_loss'] = True
|
||||||
|
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)
|
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
|
assert ablation_count == 1 or ablation_count == 0
|
||||||
|
|
||||||
config['gpu'] = '0'
|
config['gpu'] = '4'
|
||||||
config['name'] = 'abl_all'
|
config['name'] = 'iccv_gnn_decoder_1'
|
||||||
config['notes'] = ''
|
config['notes'] = ''
|
||||||
|
config['tags'] = ['iccv', 'gnn', 'ggn_decoder']
|
||||||
|
|
||||||
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
|
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']:
|
# if config['use_skinning']:
|
||||||
assert (config['use_offsets'] and config['avg_garment_path'] != '') or (not config['use_offsets'] and config['avg_garment_path'] == '')
|
# assert (config['use_offsets'] and config['avg_garment_path'] != '') or (not config['use_offsets'] and config['avg_garment_path'] == '')
|
||||||
|
|
||||||
config['reg_loss_coeff'] = 0.1 # set to 0 if don't want to use edge+collision
|
config['reg_loss_coeff'] = 0.1 # set to 0 if don't want to use edge+collision
|
||||||
|
|
||||||
@@ -38,39 +40,42 @@ config['train_dir'] = '/home/workspace/local-data/train'
|
|||||||
config['valid_dir'] = '/home/workspace/local-data/valid'
|
config['valid_dir'] = '/home/workspace/local-data/valid'
|
||||||
config['test_dir'] = '/home/workspace/data/dataset/test_ready'
|
config['test_dir'] = '/home/workspace/data/dataset/test_ready'
|
||||||
|
|
||||||
config['static_model'] = 'checkpoints/static_1'
|
# config['frames_file'] = 'frames_dress_30k.txt'
|
||||||
config['body_model'] = 'checkpoints/body_1'
|
# config['frames_file_valid'] = 'frames_dress_30k.txt'
|
||||||
config['curvature_model'] = 'checkpoints/curv_1'
|
# 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['smpl_res'] = 14475
|
config['smpl_res'] = 14475
|
||||||
if config['is_cape']:
|
if config['is_cape']:
|
||||||
config['smpl_res'] = 3638
|
config['smpl_res'] = 3638
|
||||||
|
|
||||||
config['latent_dim'] = 128
|
|
||||||
|
|
||||||
config['pretrained_model'] = ''
|
config['pretrained_model'] = ''
|
||||||
|
|
||||||
###############
|
###############
|
||||||
config['lr'] = 0.0001# 0.0001
|
config['lr'] = 0.0001# 0.0001
|
||||||
###############
|
###############
|
||||||
config['starting_balancing_coeff'] = 0.0001
|
config['starting_balancing_coeff'] = 0.001
|
||||||
|
|
||||||
config['signature_dynamic'] = { 'id': (), 'frame_nr': (),
|
config['signature_dynamic'] = { 'id': (), 'frame_nr': (),
|
||||||
'pose_shape': (72 + 11,),
|
'pose_shape': (72 + 11,),
|
||||||
'uv_body_posed': (512, 256, 3),
|
'uv_body_posed': (512, 256, 3),
|
||||||
'mesh_body_posed': (14475, 3,),
|
'mesh_body_posed': (config['smpl_res'], 3,),
|
||||||
'mesh_posed': (14475, 3,),
|
'mesh_posed': (config['smpl_res'], 3,),
|
||||||
'uv_curvature': (512, 256, 7),
|
'uv_curvature': (512, 256, 7),
|
||||||
}
|
}
|
||||||
config['signature_static'] = { 'uv_static': (512, 256, 3),
|
config['signature_static'] = { 'uv_static': (512, 256, 3),
|
||||||
'mesh_mask': (14475,),
|
'mesh_mask': (config['smpl_res'],),
|
||||||
'uv_mask': (512, 256,),
|
'uv_mask': (512, 256,),
|
||||||
}
|
}
|
||||||
|
|
||||||
if config['use_skinning']:
|
if config['use_skinning']:
|
||||||
config['signature_dynamic']['uv_unposed'] = (512, 256, 3)
|
config['signature_dynamic']['uv_unposed'] = (512, 256, 3)
|
||||||
config['signature_dynamic']['mesh_unposed'] = (14475, 3,)
|
config['signature_dynamic']['mesh_unposed'] = (config['smpl_res'], 3,)
|
||||||
else:
|
else:
|
||||||
config['signature_dynamic']['uv_posed'] = (512, 256, 3)
|
config['signature_dynamic']['uv_posed'] = (512, 256, 3)
|
||||||
|
|
||||||
@@ -81,37 +86,42 @@ config['use_one_hot'] = False
|
|||||||
|
|
||||||
config['cvae'] = dict()
|
config['cvae'] = dict()
|
||||||
config['cvae']['is_label'] = False
|
config['cvae']['is_label'] = False
|
||||||
config['cvae']['latent_dim'] = config['latent_dim']
|
|
||||||
config['cvae']['add_noise'] = True
|
config['cvae']['add_noise'] = True
|
||||||
config['cvae']['noise_amount'] = 0.025
|
config['cvae']['noise_amount'] = 0.001
|
||||||
|
|
||||||
config['cvae']['kernel_size'] = 7
|
config['cvae']['kernel_size'] = 7
|
||||||
config['cvae']['encoder_depths'] = [3, 3, 9, 3]
|
config['cvae']['encoder_depths'] = [3, 3, 3, 9, 3]
|
||||||
config['cvae']['encoder_dims'] = [32, 64, 128, 256]
|
config['cvae']['encoder_dims'] = [32, 64, 128, 256, 64]
|
||||||
config['cvae']['decoder_input'] = (16, 8, 80)
|
config['cvae']['decoder_depths'] = config['cvae']['encoder_depths']
|
||||||
config['cvae']['decoder_depths'] = [3, 3, 9, 3]
|
config['cvae']['decoder_dims'] = config['cvae']['encoder_dims']
|
||||||
config['cvae']['decoder_dims'] = [256, 128, 64, 16]
|
|
||||||
|
|
||||||
|
|
||||||
config['cond_ae'] = dict()
|
config['cond_ae_static'] = dict()
|
||||||
config['cond_ae']['is_label'] = False
|
config['cond_ae_static']['is_label'] = False
|
||||||
config['cond_ae']['upscale_output'] = False
|
config['cond_ae_static']['kernel_size'] = 7
|
||||||
config['cond_ae']['latent_dim'] = config['latent_dim']
|
config['cond_ae_static']['bottleneck_size'] = 8
|
||||||
config['cond_ae']['kernel_size'] = 7
|
config['cond_ae_static']['encoder_depths'] = [3, 3, 3, 9, 3]
|
||||||
config['cond_ae']['bottleneck_size'] = 64
|
config['cond_ae_static']['encoder_dims'] = [16, 32, 64, 64, config['cond_ae_static']['bottleneck_size']]
|
||||||
config['cond_ae']['encoder_depths'] = [3, 3, 9, 9, 3]
|
config['cond_ae_static']['decoder_depths'] = config['cond_ae_static']['encoder_depths']
|
||||||
config['cond_ae']['encoder_dims'] = [32, 64, 128, 256, config['cond_ae']['bottleneck_size']]
|
config['cond_ae_static']['decoder_dims'] = config['cond_ae_static']['encoder_dims']
|
||||||
config['cond_ae']['decoder_input'] = (8, 4, config['cond_ae']['bottleneck_size'])
|
config['cond_ae_static']['activation'] = 'tanh'
|
||||||
config['cond_ae']['decoder_depths'] = [3, 3, 9, 3, 3]
|
|
||||||
config['cond_ae']['decoder_dims'] = [config['cond_ae']['bottleneck_size'], 256, 128, 64, 16]
|
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['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'] = dict()
|
||||||
config['cond_ae_body']['latent_dim'] = config['latent_dim']
|
config['cond_ae_body']['is_label'] = False
|
||||||
config['cond_ae_body']['kernel_size'] = 7
|
config['cond_ae_body']['kernel_size'] = 7
|
||||||
config['cond_ae_body']['upscale_output'] = True
|
config['cond_ae_body']['bottleneck_size'] = 16
|
||||||
config['cond_ae_body']['bottleneck_size'] = 512
|
config['cond_ae_body']['encoder_depths'] = [3, 3, 9, 9, 3]
|
||||||
config['cond_ae_body']['encoder_depths'] = [3, 3, 9, 9, 3, 3]
|
config['cond_ae_body']['encoder_dims'] = [16, 32, 64, 128, config['cond_ae_body']['bottleneck_size']]
|
||||||
config['cond_ae_body']['encoder_dims'] = [32, 64, 128, 256, 256, config['cond_ae_body']['bottleneck_size']]
|
config['cond_ae_body']['decoder_depths'] = config['cond_ae_body']['encoder_depths']
|
||||||
config['cond_ae_body']['decoder_input'] = (4, 2, config['cond_ae_body']['bottleneck_size'])
|
config['cond_ae_body']['decoder_dims'] = config['cond_ae_body']['encoder_dims']
|
||||||
config['cond_ae_body']['decoder_depths'] = [3, 3, 9, 3]
|
config['cond_ae_body']['activation'] = 'tanh'
|
||||||
config['cond_ae_body']['decoder_dims'] = [config['cond_ae_body']['bottleneck_size'], 128, 64, 16]
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
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'] = '5'
|
||||||
|
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'] = ''
|
||||||
|
|
||||||
|
|
||||||
|
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,),
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from configs.config_abl_all_post import config
|
from configs.iccv.config_abl_all import config
|
||||||
|
|
||||||
os.environ["CUDA_VISIBLE_DEVICES"] = config['gpu']
|
os.environ["CUDA_VISIBLE_DEVICES"] = config['gpu']
|
||||||
import tensorflow as tf
|
import tensorflow as tf
|
||||||
@@ -42,6 +42,7 @@ from custom_utils.custom_utils import batch_to_dict, load_model, plot_3d, UV2Mes
|
|||||||
from dataset import DatasetFactory, StaticDataset
|
from dataset import DatasetFactory, StaticDataset
|
||||||
from custom_utils.smpl import SMPL
|
from custom_utils.smpl import SMPL
|
||||||
from models.cvae_model import CVAENew as CVAE
|
from models.cvae_model import CVAENew as CVAE
|
||||||
|
from models.gnn import Smoother
|
||||||
|
|
||||||
|
|
||||||
def init_wandb():
|
def init_wandb():
|
||||||
@@ -53,6 +54,7 @@ def init_wandb():
|
|||||||
# artifact.add_file('configs/config_base.py')
|
# artifact.add_file('configs/config_base.py')
|
||||||
# artifact.add_file('configs/config_cvae.py')
|
# artifact.add_file('configs/config_cvae.py')
|
||||||
artifact.add_file('models/base.py')
|
artifact.add_file('models/base.py')
|
||||||
|
artifact.add_file('models/gnn.py')
|
||||||
artifact.add_file('models/cond_encoder.py')
|
artifact.add_file('models/cond_encoder.py')
|
||||||
artifact.add_file('dataset.py')
|
artifact.add_file('dataset.py')
|
||||||
artifact.add_file('convnext/models/convnext_tf.py')
|
artifact.add_file('convnext/models/convnext_tf.py')
|
||||||
@@ -75,7 +77,7 @@ def kl_loss(mean, logvar):
|
|||||||
|
|
||||||
# 3d loss on posed !!!!!!!!!!!!
|
# 3d loss on posed !!!!!!!!!!!!
|
||||||
|
|
||||||
# @tf.function
|
@tf.function
|
||||||
def train_step(batch):
|
def train_step(batch):
|
||||||
|
|
||||||
with tf.GradientTape() as tape:
|
with tf.GradientTape() as tape:
|
||||||
@@ -86,7 +88,7 @@ def train_step(batch):
|
|||||||
|
|
||||||
pred, mean, logvar = model([uv_orig, batch['uv_static'], batch['uv_body_posed'], batch['uv_curvature'], batch['uv_mask']], training=True)
|
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 = pred
|
||||||
|
|
||||||
if config['use_skinning']:
|
if config['use_skinning']:
|
||||||
shape = batch['pose_shape'][:, 72:]
|
shape = batch['pose_shape'][:, 72:]
|
||||||
@@ -103,18 +105,18 @@ def train_step(batch):
|
|||||||
e_loss = tf.reduce_mean(edge_loss(mesh_pred, mesh_orig, batch['mesh_mask']))
|
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 = 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)
|
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_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))
|
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'])
|
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'])
|
# conc_loss = concept_loss(pred, batch['uv_unposed'])
|
||||||
kl = kl_loss(mean, logvar)
|
kl = kl_loss(mean, logvar)
|
||||||
|
|
||||||
reconstr_loss = l2_loss
|
reconstr_loss = l2_mesh_loss
|
||||||
if config['use_extra_losses']:
|
if config['use_extra_losses']:
|
||||||
if 'block_collision_loss' in config.keys() and config['block_collision_loss'] == True:
|
if 'block_collision_loss' in config.keys() and config['block_collision_loss'] == True:
|
||||||
reconstr_loss = reconstr_loss + l2_mesh_loss + (e_loss) * config['reg_loss_coeff']
|
reconstr_loss = reconstr_loss + (e_loss) * config['reg_loss_coeff']
|
||||||
else:
|
else:
|
||||||
reconstr_loss = reconstr_loss + l2_mesh_loss + (e_loss + c_loss) * config['reg_loss_coeff']
|
reconstr_loss = reconstr_loss + (e_loss + c_loss) * config['reg_loss_coeff']
|
||||||
if config['use_norm_loss'] and step > 2000:
|
if config['use_norm_loss'] and step > 2000:
|
||||||
reconstr_loss = reconstr_loss + n_loss * config['reg_loss_coeff']
|
reconstr_loss = reconstr_loss + n_loss * config['reg_loss_coeff']
|
||||||
|
|
||||||
@@ -130,7 +132,7 @@ def train_step(batch):
|
|||||||
return { 'train/loss': loss, 'train/edge_loss': e_loss, 'train/collision_loss': c_loss, 'train/euclid_error': metric,
|
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/reconstr_loss': reconstr_loss, 'train/collision_ratio': c_ratio,
|
||||||
'train/mean': mean, 'train/logvar': logvar, 'train/kl_loss': kl, 'train/var': np.e ** logvar,
|
'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/l2_mesh_loss': l2_mesh_loss, 'train/normal_loss': n_loss,
|
||||||
# 'train/ms_ssim': ms_ssim,
|
# 'train/ms_ssim': ms_ssim,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +146,7 @@ def valid_step(batch):
|
|||||||
|
|
||||||
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=False)
|
||||||
|
|
||||||
mesh_pred = uv2mesh(pred)
|
mesh_pred = pred
|
||||||
|
|
||||||
if config['use_skinning']:
|
if config['use_skinning']:
|
||||||
shape = batch['pose_shape'][:, 72:]
|
shape = batch['pose_shape'][:, 72:]
|
||||||
@@ -161,15 +163,15 @@ def valid_step(batch):
|
|||||||
e_loss = tf.reduce_mean(edge_loss(mesh_pred, mesh_orig, batch['mesh_mask']))
|
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 = 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)
|
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_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))
|
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'])
|
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'])
|
# conc_loss = concept_loss(pred, batch['uv_unposed'])
|
||||||
kl = kl_loss(mean, logvar)
|
kl = kl_loss(mean, logvar)
|
||||||
|
|
||||||
reconstr_loss = l2_loss
|
reconstr_loss = l2_mesh_loss
|
||||||
if config['use_extra_losses']:
|
if config['use_extra_losses']:
|
||||||
reconstr_loss = reconstr_loss + l2_mesh_loss + (e_loss + c_loss) * config['reg_loss_coeff']
|
reconstr_loss = reconstr_loss + (e_loss + c_loss) * config['reg_loss_coeff']
|
||||||
if config['use_norm_loss']:
|
if config['use_norm_loss']:
|
||||||
reconstr_loss = reconstr_loss + n_loss * config['reg_loss_coeff']
|
reconstr_loss = reconstr_loss + n_loss * config['reg_loss_coeff']
|
||||||
|
|
||||||
@@ -254,13 +256,12 @@ def plot_everything(batch: dict, type: str):
|
|||||||
|
|
||||||
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=False)
|
||||||
|
|
||||||
mesh_pred = uv2mesh(pred).numpy()
|
mesh_pred = pred.numpy()
|
||||||
|
|
||||||
orig_img = uv_orig
|
orig_img = uv_orig
|
||||||
uv_static_img = batch['uv_static']
|
uv_static_img = batch['uv_static']
|
||||||
uv_body_posed_img = batch['uv_body_posed']
|
uv_body_posed_img = batch['uv_body_posed']
|
||||||
pred_img = pred
|
img = tf.concat((uv_static_img, uv_body_posed_img, orig_img), axis=2)
|
||||||
img = tf.concat((uv_static_img, uv_body_posed_img, orig_img, pred_img), axis=2)
|
|
||||||
imgs = [wandb.Image((img[i] + 1) / 2.0) for i in range(4)]
|
imgs = [wandb.Image((img[i] + 1) / 2.0) for i in range(4)]
|
||||||
|
|
||||||
F = np.load("custom_utils/smpl_faces" + skirt_modifier + ("_orig" if config['is_cape'] else "") + ".npy")
|
F = np.load("custom_utils/smpl_faces" + skirt_modifier + ("_orig" if config['is_cape'] else "") + ".npy")
|
||||||
@@ -427,8 +428,6 @@ def sample(folder):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
str_split = config['name'].split('_')
|
str_split = config['name'].split('_')
|
||||||
test_idx = str_split.index('test')
|
test_idx = str_split.index('test')
|
||||||
@@ -478,7 +477,7 @@ def test():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# init_wandb()
|
init_wandb()
|
||||||
parser = argparse.ArgumentParser(description='')
|
parser = argparse.ArgumentParser(description='')
|
||||||
parser.add_argument('--name', type=str)
|
parser.add_argument('--name', type=str)
|
||||||
args = vars(parser.parse_args())
|
args = vars(parser.parse_args())
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import scipy as sp
|
|||||||
from custom_utils.custom_utils import load_model
|
from custom_utils.custom_utils import load_model
|
||||||
from models.base import AEEncoder, VariationalEncoder, Decoder
|
from models.base import AEEncoder, VariationalEncoder, Decoder
|
||||||
from models.base import AEEncoderNew, VariationalEncoderNew, DecoderNew
|
from models.base import AEEncoderNew, VariationalEncoderNew, DecoderNew
|
||||||
|
from models.gnn import GNNDecoder
|
||||||
|
|
||||||
class CVAE(tf.keras.Model):
|
class CVAE(tf.keras.Model):
|
||||||
|
|
||||||
@@ -150,8 +150,6 @@ class CVAE(tf.keras.Model):
|
|||||||
return x, mean, logvar
|
return x, mean, logvar
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CVAENew(tf.keras.Model):
|
class CVAENew(tf.keras.Model):
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
@@ -180,7 +178,8 @@ class CVAENew(tf.keras.Model):
|
|||||||
self.curv_enc.trainable = False
|
self.curv_enc.trainable = False
|
||||||
|
|
||||||
self.encoder = VariationalEncoderNew(config['cvae']['encoder_depths'], config['cvae']['encoder_dims'], kernel_size=config['cvae']['kernel_size'])
|
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.decoder = GNNDecoder()
|
||||||
|
|
||||||
|
|
||||||
self.reshape = tf.keras.layers.Reshape((8, 4, 64))
|
self.reshape = tf.keras.layers.Reshape((8, 4, 64))
|
||||||
|
|
||||||
@@ -273,13 +272,13 @@ class CVAENew(tf.keras.Model):
|
|||||||
z = tf.concat([z, z_cond], axis=-1)
|
z = tf.concat([z, z_cond], axis=-1)
|
||||||
x = self.decoder(z, training=training)
|
x = self.decoder(z, training=training)
|
||||||
|
|
||||||
if self.avg_garment is not None:
|
# if self.avg_garment is not None:
|
||||||
x = x + self.avg_garment[tf.newaxis,:,:,:]
|
# x = x + self.avg_garment[tf.newaxis,:,:,:]
|
||||||
|
|
||||||
if self.use_offsets_over_body:
|
# if self.use_offsets_over_body:
|
||||||
x = x + uv_body_posed
|
# x = x + uv_body_posed
|
||||||
|
|
||||||
x = x * uv_mask[:,:,:,tf.newaxis]
|
# x = x * uv_mask[:,:,:,tf.newaxis]
|
||||||
|
|
||||||
return x, mean, logvar
|
return x, mean, logvar
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import scipy.io as sio
|
||||||
|
import tensorflow as tf
|
||||||
|
from spektral.layers import GCNConv, GeneralConv, GATConv
|
||||||
|
from spektral.utils import sp_matrix_to_sp_tensor
|
||||||
|
from tensorflow.keras.layers import (Conv2D, Conv2DTranspose, Dense, DepthwiseConv2D,
|
||||||
|
GlobalAveragePooling2D, Layer,
|
||||||
|
LayerNormalization, Flatten, Reshape, UpSampling2D)
|
||||||
|
|
||||||
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
|
|
||||||
|
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 = GeneralConv(channels=32, batch_norm=True, dropout=0.1, aggregate='mean', activation='prelu', use_bias=True)
|
||||||
|
self.conv2 = GeneralConv(channels=128, batch_norm=True, dropout=0.1, aggregate='mean', activation='prelu', use_bias=True)
|
||||||
|
self.conv3 = GeneralConv(channels=64, batch_norm=True, dropout=0.0, aggregate='mean', activation='prelu', use_bias=True)
|
||||||
|
self.conv4 = GeneralConv(channels=16, batch_norm=True, dropout=0.0, aggregate='mean', activation='prelu', use_bias=True)
|
||||||
|
|
||||||
|
self.conv5 = GCNConv(3, activation='tanh', use_bias=False)
|
||||||
|
self.conv6 = GCNConv(3, activation='tanh', use_bias=False)
|
||||||
|
|
||||||
|
def call(self, inputs, training=None):
|
||||||
|
x = inputs
|
||||||
|
x = self.conv1([x, self.a], training=training)
|
||||||
|
x = self.conv2([x, self.a], training=training)
|
||||||
|
x = self.conv3([x, self.a], training=training)
|
||||||
|
x = self.conv4([x, self.a], training=training)
|
||||||
|
x = self.conv5([x, self.a], training=training)
|
||||||
|
x = self.conv6([x, self.a], training=training)
|
||||||
|
return x
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import scipy.sparse as sp
|
||||||
|
|
||||||
|
class GNNDecoder(tf.keras.Model):
|
||||||
|
def __init__(self, ):
|
||||||
|
super().__init__()
|
||||||
|
self.a = sp_matrix_to_sp_tensor(sio.loadmat("custom_utils/ssmpl0.mat")['L'].tocoo())
|
||||||
|
# self.a_dense = sio.loadmat("custom_utils/ssmpl0.mat")['L'].todense()
|
||||||
|
# self.a_dense = np.ones((100,100), dtype=np.float32)
|
||||||
|
# self.a = sp_matrix_to_sp_tensor(sp.coo_matrix(self.a_dense))
|
||||||
|
|
||||||
|
self.flatten = Flatten()
|
||||||
|
# self.conv1 = GATConv(channels=4, attn_heads=1, concat_heads=True, dropout_rate=0.0, return_attn_coef=False, add_self_loops=True, activation=None, use_bias=True)
|
||||||
|
# self.conv2 = GATConv(channels=4, attn_heads=1, concat_heads=True, dropout_rate=0.1, return_attn_coef=False, add_self_loops=True, activation=None, use_bias=True)
|
||||||
|
# self.conv3 = GATConv(channels=4, attn_heads=1, concat_heads=True, dropout_rate=0.1, return_attn_coef=False, add_self_loops=True, activation=None, use_bias=True)
|
||||||
|
self.dense1 = Dense(512)
|
||||||
|
self.dense2 = Dense(256)
|
||||||
|
self.conv1 = GCNConv(256, use_bias=True)
|
||||||
|
self.conv2 = GCNConv(256, use_bias=True)
|
||||||
|
self.conv3 = GeneralConv(channels=128, batch_norm=True, dropout=0.1, aggregate='sum', activation='prelu', use_bias=True)
|
||||||
|
self.conv4 = GeneralConv(channels=128, batch_norm=True, dropout=0.1, aggregate='sum', activation='prelu', use_bias=True)
|
||||||
|
self.conv5 = GeneralConv(channels=64, batch_norm=True, dropout=0.0, aggregate='sum', activation='prelu', use_bias=True)
|
||||||
|
self.conv6 = GCNConv(3, activation='tanh', use_bias=False)
|
||||||
|
|
||||||
|
def call(self, inputs, training=None):
|
||||||
|
x = inputs
|
||||||
|
x = self.flatten(x)
|
||||||
|
x = tf.tile(x[:,None,:], [1,14475,1])
|
||||||
|
x = self.dense1(x)
|
||||||
|
x = self.dense2(x)
|
||||||
|
x = self.conv1([x, self.a], training=training)
|
||||||
|
x = self.conv2([x, self.a], training=training)
|
||||||
|
x = self.conv3([x, self.a], training=training)
|
||||||
|
x = self.conv4([x, self.a], training=training)
|
||||||
|
x = self.conv5([x, self.a], training=training)
|
||||||
|
x = self.conv6([x, self.a], training=training)
|
||||||
|
return x
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user