From 532f5e12f4e11bd90de680d200cb38b1696485af Mon Sep 17 00:00:00 2001 From: Hunor Laczko Date: Tue, 28 Feb 2023 00:13:07 +0000 Subject: [PATCH] resnet trials --- aaa_helpers.txt | 4 +++- auto_encoder_body.py | 4 ++-- auto_encoder_static.py | 8 ++++---- configs/iccv/config_ae_body.py | 2 +- configs/iccv/config_ae_curv.py | 2 +- configs/iccv/config_ae_static.py | 2 +- models/base.py | 6 +++--- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/aaa_helpers.txt b/aaa_helpers.txt index ca3d638..9de0bd6 100644 --- a/aaa_helpers.txt +++ b/aaa_helpers.txt @@ -1,7 +1,9 @@ nohup python cvae.py --name="lhunor_weights_test_6" > nohup/iccv/weights_test_6.out 2>&1 & nohup python evaluate_ae.py --name iccv_weights_test_6 > nohup/iccv/evaluate_iccv_weights_test_6.out 2>&1 & nohup python calculate_error.py --name iccv_weights_test_6 > nohup/iccv/error_iccv_weights_test_6.out 2>&1 & -nohup python auto_encoder_static.py --name="lhunor_ae_static_iccv_resnet_1" > nohup/iccv/encoders/ae_static_iccv_resnet_1.out 2>&1 & +nohup python auto_encoder_static.py --name="lhunor_ae_static_iccv_resnet_2" > nohup/iccv/encoders/ae_static_iccv_resnet_2.out 2>&1 & +nohup python auto_encoder_curv.py --name="lhunor_ae_curv_iccv_resnet_2" > nohup/iccv/encoders/ae_curv_iccv_resnet_2.out 2>&1 & +nohup python auto_encoder_body.py --name="lhunor_ae_body_iccv_resnet_2" > nohup/iccv/encoders/ae_body_iccv_resnet_2.out 2>&1 & one final convolutional layer for smoothing, on the final coordinates diff --git a/auto_encoder_body.py b/auto_encoder_body.py index e531bf2..5b7a0b9 100644 --- a/auto_encoder_body.py +++ b/auto_encoder_body.py @@ -66,7 +66,7 @@ def train_step(batch): # ms_ssim = tf.reduce_mean(tf.image.ssim_multiscale(pred + 1, batch['uv_body_posed' + resolution_modifier] + 1, max_val=3, power_factors=(0.5, 0.2, 0.1, 0.1, 0.1))) ms_ssim = tf.reduce_mean(tf.image.ssim(pred + 1, batch['uv_body_posed' + resolution_modifier] + 1, max_val=3)) - loss = 1e3 * (1 - ms_ssim) + loss = l1_loss metric = tf.reduce_mean(tf.math.sqrt(tf.reduce_sum((mesh_orig - mesh_pred) ** 2, axis=-1))) gradients = tape.gradient(loss, model.trainable_variables) @@ -87,7 +87,7 @@ def valid_step(batch): # ms_ssim = tf.reduce_mean(tf.image.ssim_multiscale(pred + 1, batch['uv_body_posed' + resolution_modifier] + 1, max_val=3, power_factors=(0.5, 0.2, 0.1, 0.1, 0.1))) ms_ssim = tf.reduce_mean(tf.image.ssim(pred + 1, batch['uv_body_posed' + resolution_modifier] + 1, max_val=3)) - loss = 1e3 * (1 - ms_ssim) + loss = l1_loss metric = tf.reduce_mean(tf.math.sqrt(tf.reduce_sum((mesh_orig - mesh_pred) ** 2, axis=-1))) return { 'valid/loss': loss, 'valid/edge_loss': e_loss, 'valid/l1_loss': l1_loss, 'valid/euclid_error': metric, 'valid/ms_ssim': ms_ssim, } diff --git a/auto_encoder_static.py b/auto_encoder_static.py index fc90622..fe400f3 100644 --- a/auto_encoder_static.py +++ b/auto_encoder_static.py @@ -70,8 +70,8 @@ def train_step(batch): l1_loss = tf.reduce_mean(tf.reduce_sum((tf.math.abs(batch['uv_static'] - pred)), axis=1)) # ms_ssim = tf.reduce_mean(tf.image.ssim_multiscale(pred + 1, batch['uv_static'] + 1, max_val=3, power_factors=(0.5, 0.2, 0.1, 0.1, 0.1))) ms_ssim = tf.reduce_mean(tf.image.ssim(pred + 1, batch['uv_static'] + 1, max_val=3)) - loss = 1e3 * (1 - ms_ssim) - # loss = l1_loss + # loss = 1e3 * (1 - ms_ssim) + loss = l1_loss 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) @@ -92,8 +92,8 @@ def valid_step(batch): l1_loss = tf.reduce_mean(tf.reduce_sum((tf.math.abs(batch['uv_static'] - pred)), axis=1)) # ms_ssim = tf.reduce_mean(tf.image.ssim_multiscale(pred + 1, batch['uv_static'] + 1, max_val=3, power_factors=(0.5, 0.2, 0.1, 0.1, 0.1))) ms_ssim = tf.reduce_mean(tf.image.ssim(pred + 1, batch['uv_static'] + 1, max_val=3)) - loss = 1e3 * (1 - ms_ssim) - # loss = l1_loss + # loss = 1e3 * (1 - ms_ssim) + loss = l1_loss 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/edge_loss': e_loss, 'valid/l1_loss': l1_loss, 'valid/euclid_error': metric, 'valid/ms_ssim': ms_ssim, } diff --git a/configs/iccv/config_ae_body.py b/configs/iccv/config_ae_body.py index 308abc3..b52c76d 100644 --- a/configs/iccv/config_ae_body.py +++ b/configs/iccv/config_ae_body.py @@ -30,7 +30,7 @@ config['cond_ae']['activation'] = 'tanh' config['gpu'] = '3' config['lr'] = 0.0001 -config['name'] = 'body_resnet_1' +config['name'] = 'body_resnet_3' config['notes'] = '' config['tags'] = ['iccv', 'resnet'] diff --git a/configs/iccv/config_ae_curv.py b/configs/iccv/config_ae_curv.py index a3a2b0c..f8f6e3b 100644 --- a/configs/iccv/config_ae_curv.py +++ b/configs/iccv/config_ae_curv.py @@ -31,7 +31,7 @@ config['cond_ae']['activation'] = 'tanh' config['gpu'] = '2' config['lr'] = 0.001 -config['name'] = 'curv_resnet_1' +config['name'] = 'curv_resnet_3' config['notes'] = '' config['tags'] = ['iccv', 'resnet'] diff --git a/configs/iccv/config_ae_static.py b/configs/iccv/config_ae_static.py index 13a5c64..1d00b64 100644 --- a/configs/iccv/config_ae_static.py +++ b/configs/iccv/config_ae_static.py @@ -31,7 +31,7 @@ config['cond_ae']['activation'] = 'tanh' config['gpu'] = '1' config['lr'] = 3e-4 -config['name'] = 'static_resnet_1' +config['name'] = 'static_resnet_3' config['notes'] = '' config['tags'] = ['iccv', 'resnet', 'static'] diff --git a/models/base.py b/models/base.py index d077ecb..1b767c6 100644 --- a/models/base.py +++ b/models/base.py @@ -166,7 +166,7 @@ class AEEncoderNew(tf.keras.Model): def __init__(self, layer_params, features, activation='tanh'): super(AEEncoderNew, self).__init__() - self.encoder = resnet_101(layer_params, features) + self.encoder = resnet_18(layer_params, features) self.act = tf.keras.layers.Activation(activation) @@ -193,9 +193,9 @@ class DecoderNew(tf.keras.Model): self.is_label = is_label if not is_label: - self.decoder = resnet_101(layer_params, features, reversed=True, is_cvae=is_cvae) + self.decoder = resnet_18(layer_params, features, reversed=True, is_cvae=is_cvae) else: - self.decoder = resnet_101(layer_params, features, reversed=True, labels=6, is_cvae=is_cvae) + self.decoder = resnet_18(layer_params, features, reversed=True, labels=6, is_cvae=is_cvae) def call(self, inputs, training):