From ebbc52d0fd88b1e91e17ffa08d590222ddc1a41a Mon Sep 17 00:00:00 2001 From: Hunor Laczko Date: Fri, 17 Feb 2023 15:31:19 +0000 Subject: [PATCH] fix plotting and error calc --- aaa_helpers.txt | 2 +- configs/config_abl_all_post.py | 6 +++--- cvae.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/aaa_helpers.txt b/aaa_helpers.txt index 50e6430..f5d2261 100644 --- a/aaa_helpers.txt +++ b/aaa_helpers.txt @@ -1,4 +1,4 @@ -nohup python cvae.py --name="lhunor_weights_test_2" > nohup/iccv/weights_test.out 2>&1 & +nohup python cvae.py --name="lhunor_weights_test_6" > nohup/iccv/weights_test_6.out 2>&1 & one final convolutional layer for smoothing, on the final coordinates diff --git a/configs/config_abl_all_post.py b/configs/config_abl_all_post.py index 1be281a..fe0c27e 100644 --- a/configs/config_abl_all_post.py +++ b/configs/config_abl_all_post.py @@ -20,8 +20,8 @@ ablation_count = [config['use_skinning'], config['remove_global_orientation'], c assert ablation_count == 1 or ablation_count == 0 config['gpu'] = '5' -config['name'] = 'iccv_weights_test_5' -config['notes'] = 'smaller weight loss coeff, 1e-6, convolutional weight learning' +config['name'] = 'iccv_weights_test_6' +config['notes'] = 'smaller weight loss coeff, 1e-6, convolutional weight learning, continued from _5' 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']: @@ -53,7 +53,7 @@ if config['is_cape']: config['smpl_res'] = 3638 -config['pretrained_model'] = ''#'checkpoints/post/iccv_weights_test_2' +config['pretrained_model'] = 'checkpoints/post/iccv_weights_test_5' ############### config['lr'] = 0.0001# 0.0001 diff --git a/cvae.py b/cvae.py index 266f6f1..8bf7754 100644 --- a/cvae.py +++ b/cvae.py @@ -136,7 +136,7 @@ def train_step(batch): 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']) + metric = tf.reduce_sum(tf.math.sqrt(tf.reduce_sum(batch['mesh_mask'][:,:,tf.newaxis] * (mesh_orig - mesh_pred_posed) ** 2, axis=-1))) / tf.reduce_sum(batch['mesh_mask']) gradients = tape.gradient(loss, model.trainable_variables) optimizer.apply_gradients(zip(gradients, model.trainable_variables)) return { 'train/loss': loss, 'train/edge_loss': e_loss, 'train/collision_loss': c_loss, 'train/euclid_error': metric, @@ -198,7 +198,7 @@ def valid_step(batch): 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']) + metric = tf.reduce_sum(tf.math.sqrt(tf.reduce_sum(batch['mesh_mask'][:,:,tf.newaxis] * (mesh_orig - mesh_pred_posed) ** 2, axis=-1))) / tf.reduce_sum(batch['mesh_mask']) # c_ratio = tf.reduce_mean(collision_ratio(mesh_pred_posed, batch['mesh_body_posed'], batch['mesh_mask'])) return { 'valid/loss': loss, 'valid/edge_loss': e_loss, 'valid/collision_loss': c_loss, 'valid/euclid_error': metric, @@ -324,8 +324,8 @@ def plot_everything(batch: dict, type: str): collision_gt = [np.concatenate((body[i], gt_posed[i]), axis=0) for i in range(len(garment_posed))] # figs = { type + "/garment_" + str(i): plot_3d(gt[i], garment_unposed[i], faces[i], garment_posed[i], faces[i], collision_color[i], flip_xy=(not config['use_skinning'] and config['remove_global_orientation'])) for i in range(4) } - figs = { type + "/garment_" + str(i): plot_3d(gt[i], garment_unposed[i], faces[i], collision[i], collision_faces[i], collision_color[i], flip_xy=(config['remove_global_orientation'])) for i in range(4) } - figs_coll = { type + "/garment_" + str(i) + '_collision': plot_3d_collision(collision_gt[i], collision[i], collision_fixed[i], collision_faces[i], collision_color[i], flip_xy=(config['remove_global_orientation'])) for i in range(4) } + figs = { type + "/garment_" + str(i): plot_3d(gt[i], garment_unposed[i], faces[i], collision[i], collision_faces[i], collision_color[i],) for i in range(4) } + figs_coll = { type + "/garment_" + str(i) + '_collision': plot_3d_collision(collision_gt[i], collision[i], collision_fixed[i], collision_faces[i], collision_color[i],) for i in range(4) } figs_weights = { type + '/weights_' + str(i): plot_weights(mesh_weigths[0,:,i], body[0], F) for i in range(24) } # figs_weights = { type + '/weights_' + str(i): plot_weights(smpl.weights[0,:,i], body[0], F) for i in range(24) }