Compare commits
3
Commits
seq_pyr
...
iccv_abl_gnn
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65fd3d9ded | ||
|
|
53a9382e1c | ||
|
|
ecde65a2c4 |
@@ -24,6 +24,8 @@ nohup python cvae.py --name="lhunor_abl_reg" > nohup/iccv/ablation/abl_reg.out 2
|
||||
nohup python cvae.py --name="lhunor_abl_off" > nohup/iccv/ablation/abl_off.out 2>&1 &
|
||||
nohup python cvae.py --name="lhunor_abl_skin_curv" > nohup/iccv/ablation/abl_skin_curv.out 2>&1 &
|
||||
|
||||
nohup python cvae.py --name="lhunor_abl_skin_gnn" > nohup/iccv/ablation/abl_skin_gnn.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 &
|
||||
|
||||
@@ -14,6 +14,7 @@ config['use_extra_losses'] = True # edge, collision, 3d mesh
|
||||
config['use_offsets'] = 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)
|
||||
assert ablation_count == 1 or ablation_count == 0
|
||||
@@ -43,35 +44,38 @@ 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['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
|
||||
if config['is_cape']:
|
||||
config['smpl_res'] = 3638
|
||||
|
||||
config['latent_dim'] = 128
|
||||
|
||||
config['pretrained_model'] = ''
|
||||
|
||||
###############
|
||||
config['lr'] = 0.0001# 0.0001
|
||||
###############
|
||||
config['starting_balancing_coeff'] = 0.0001
|
||||
config['starting_balancing_coeff'] = 0.001
|
||||
|
||||
config['signature_dynamic'] = { 'id': (), 'frame_nr': (),
|
||||
'pose_shape': (72 + 11,),
|
||||
'uv_body_posed': (512, 256, 3),
|
||||
'mesh_body_posed': (14475, 3,),
|
||||
'mesh_posed': (14475, 3,),
|
||||
'mesh_body_posed': (config['smpl_res'], 3,),
|
||||
'mesh_posed': (config['smpl_res'], 3,),
|
||||
'uv_curvature': (512, 256, 7),
|
||||
}
|
||||
config['signature_static'] = { 'uv_static': (512, 256, 3),
|
||||
'mesh_mask': (14475,),
|
||||
'mesh_mask': (config['smpl_res'],),
|
||||
'uv_mask': (512, 256,),
|
||||
}
|
||||
|
||||
if config['use_skinning']:
|
||||
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:
|
||||
config['signature_dynamic']['uv_posed'] = (512, 256, 3)
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ config['use_norm_loss'] = True
|
||||
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_skin'
|
||||
config['gpu'] = '4'
|
||||
config['name'] = 'abl_skin_gnn'
|
||||
config['notes'] = ''
|
||||
config['tags'] = ['iccv', 'abl_skin']
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
from configs.iccv.config_abl_skin_curv import config
|
||||
from configs.iccv.config_abl_skin import config
|
||||
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = config['gpu']
|
||||
import tensorflow as tf
|
||||
@@ -34,7 +34,6 @@ else:
|
||||
from losses import edge_loss
|
||||
|
||||
|
||||
|
||||
from losses import collision_ratio, kl_loss, normal_loss #, concept_loss
|
||||
# from losses import collision_penalty as collision_penalty
|
||||
from losses import collision_loss as collision_penalty
|
||||
@@ -42,6 +41,7 @@ from custom_utils.custom_utils import batch_to_dict, load_model, plot_3d, UV2Mes
|
||||
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
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ def init_wandb():
|
||||
# artifact.add_file('configs/config_base.py')
|
||||
# artifact.add_file('configs/config_cvae.py')
|
||||
artifact.add_file('models/base.py')
|
||||
artifact.add_file('models/gnn.py')
|
||||
artifact.add_file('models/cond_encoder.py')
|
||||
artifact.add_file('dataset.py')
|
||||
artifact.add_file('convnext/models/convnext_tf.py')
|
||||
@@ -88,6 +89,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)
|
||||
|
||||
mesh_pred = uv2mesh(pred)
|
||||
mesh_pred = smoother(mesh_pred, training=True)
|
||||
|
||||
if config['use_skinning']:
|
||||
shape = batch['pose_shape'][:, 72:]
|
||||
@@ -126,8 +128,8 @@ def train_step(batch):
|
||||
|
||||
# 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, model.trainable_variables)
|
||||
optimizer.apply_gradients(zip(gradients, model.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/kl_loss': kl, 'train/var': np.e ** logvar,
|
||||
@@ -146,6 +148,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)
|
||||
|
||||
mesh_pred = uv2mesh(pred)
|
||||
mesh_pred = smoother(mesh_pred, training=False)
|
||||
|
||||
if config['use_skinning']:
|
||||
shape = batch['pose_shape'][:, 72:]
|
||||
@@ -255,7 +258,8 @@ 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)
|
||||
|
||||
mesh_pred = uv2mesh(pred).numpy()
|
||||
mesh_pred = uv2mesh(pred)
|
||||
mesh_pred = smoother(mesh_pred, training=False).numpy()
|
||||
|
||||
orig_img = uv_orig
|
||||
uv_static_img = batch['uv_static']
|
||||
@@ -520,6 +524,7 @@ if __name__ == '__main__':
|
||||
is_cape=config['is_cape'])
|
||||
|
||||
model = CVAE(config)
|
||||
smoother = Smoother()
|
||||
|
||||
optimizer = tf.optimizers.Adam(learning_rate=config['lr'])
|
||||
balancing_activated_step = 0
|
||||
@@ -546,7 +551,7 @@ if __name__ == '__main__':
|
||||
train_loss = train_step(batch)
|
||||
train_accumulator.update(train_loss)
|
||||
|
||||
if step % 50 == 0:
|
||||
if step % 25 == 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)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
import scipy.io as sio
|
||||
import tensorflow as tf
|
||||
from spektral.layers import GCNConv, GeneralConv
|
||||
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 = GCNConv(16, activation='tanh', use_bias=False)
|
||||
self.conv2 = GCNConv(3, activation='tanh', use_bias=False)
|
||||
# self.conv3 = GCNConv(3, activation='tanh', use_bias=False)
|
||||
# self.conv4 = GCNConv(3, activation='tanh', use_bias=False)
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user