Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32c3d1103f | ||
|
|
263754d755 | ||
|
|
4f869c864c | ||
|
|
e0825722e3 | ||
|
|
e23d097398 | ||
|
|
f3c1e3308e |
@@ -0,0 +1,82 @@
|
|||||||
|
from utils.convnext_utils import CNBlockConfig
|
||||||
|
|
||||||
|
config = dict()
|
||||||
|
|
||||||
|
config['gpu'] = '0'
|
||||||
|
config['name'] = 'direct_3'
|
||||||
|
config['notes'] = 'with normals input'
|
||||||
|
config['tags'] = ['torch', 'direct']
|
||||||
|
config['script'] = 'scripts/direct_train.py'
|
||||||
|
|
||||||
|
config['pretrained_model'] = ''
|
||||||
|
config['use_curvature'] = False
|
||||||
|
config['use_normals'] = True
|
||||||
|
|
||||||
|
# assert that only use curvature or normals
|
||||||
|
assert not (config['use_curvature'] and config['use_normals'])
|
||||||
|
|
||||||
|
config['batch_size'] = 4
|
||||||
|
config['train_dir'] = '/data-local/127/train'
|
||||||
|
config['valid_dir'] = '/data-local/127/valid'
|
||||||
|
config['test_dir'] = '/data-net/dataset/test_ready'
|
||||||
|
config['train_frames'] = None
|
||||||
|
config['valid_frames'] = None
|
||||||
|
|
||||||
|
config['resolution'] = 512
|
||||||
|
config['is_skirt'] = False
|
||||||
|
config['dataset_in_memory'] = False
|
||||||
|
config['is_cape'] = False
|
||||||
|
config['remove_global_orientation'] = True
|
||||||
|
config['device'] = 'cuda'
|
||||||
|
config['input_features'] = 9
|
||||||
|
|
||||||
|
config['smpl_res'] = 14475
|
||||||
|
if config['is_cape']:
|
||||||
|
config['smpl_res'] = 3638
|
||||||
|
|
||||||
|
config['latent_dim'] = 128
|
||||||
|
|
||||||
|
config['bottleneck_scale'] = 2
|
||||||
|
|
||||||
|
config['is_label'] = False
|
||||||
|
config['kernel_size'] = 7
|
||||||
|
config['bottleneck_size'] = 64 * config['bottleneck_scale']
|
||||||
|
|
||||||
|
block_setting = [
|
||||||
|
CNBlockConfig(16, 32, 3),
|
||||||
|
CNBlockConfig(32, 128, 3),
|
||||||
|
CNBlockConfig(128, 256, 9),
|
||||||
|
CNBlockConfig(256, config['bottleneck_size'], 9),
|
||||||
|
CNBlockConfig(config['bottleneck_size'], None, 3),
|
||||||
|
]
|
||||||
|
|
||||||
|
block_setting_reverse = [
|
||||||
|
CNBlockConfig(config['bottleneck_size'], 256, 3),
|
||||||
|
CNBlockConfig(256, 128, 9),
|
||||||
|
CNBlockConfig(128, 32, 9),
|
||||||
|
CNBlockConfig(32, 16, 3),
|
||||||
|
CNBlockConfig(16, 3, 3),
|
||||||
|
# CNBlockConfig(3, 3, 3),
|
||||||
|
]
|
||||||
|
|
||||||
|
config['encoder_block_settings'] = block_setting
|
||||||
|
config['decoder_block_settings'] = block_setting_reverse
|
||||||
|
config['activation'] = 'tanh'
|
||||||
|
|
||||||
|
|
||||||
|
config['lr'] = 0.0001
|
||||||
|
config['reg_loss_coeff'] = 0.1
|
||||||
|
|
||||||
|
config['signature'] = { 'id',
|
||||||
|
'frame_nr',
|
||||||
|
'pose_shape',
|
||||||
|
'uv_normals',
|
||||||
|
'mesh_mask',
|
||||||
|
'mesh_body_posed',
|
||||||
|
'mesh_posed',
|
||||||
|
'uv_unposed',
|
||||||
|
'mesh_unposed',
|
||||||
|
'uv_static',
|
||||||
|
'uv_mask',
|
||||||
|
'uv_body_posed',
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
from utils.convnext_utils import CNBlockConfig
|
||||||
|
|
||||||
|
config = dict()
|
||||||
|
|
||||||
|
config['gpu'] = '5'
|
||||||
|
config['name'] = 'direct_5'
|
||||||
|
config['notes'] = 'with normals input but only single garment sequence'
|
||||||
|
config['tags'] = ['torch', 'direct']
|
||||||
|
config['script'] = 'scripts/direct_train.py'
|
||||||
|
|
||||||
|
config['pretrained_model'] = ''
|
||||||
|
config['use_curvature'] = False
|
||||||
|
config['use_normals'] = True
|
||||||
|
|
||||||
|
# assert that only use curvature or normals
|
||||||
|
assert not (config['use_curvature'] and config['use_normals'])
|
||||||
|
|
||||||
|
config['batch_size'] = 4
|
||||||
|
config['train_dir'] = '/data-local/127/train'
|
||||||
|
config['valid_dir'] = '/data-local/127/train'
|
||||||
|
config['test_dir'] = '/data-net/dataset/test_ready'
|
||||||
|
config['train_frames'] = 'frames_00761.txt'
|
||||||
|
config['valid_frames'] = 'frames_00761.txt'
|
||||||
|
|
||||||
|
config['resolution'] = 512
|
||||||
|
config['is_skirt'] = False
|
||||||
|
config['dataset_in_memory'] = True
|
||||||
|
config['is_cape'] = False
|
||||||
|
config['remove_global_orientation'] = True
|
||||||
|
config['device'] = 'cuda'
|
||||||
|
config['input_features'] = 9
|
||||||
|
|
||||||
|
config['smpl_res'] = 14475
|
||||||
|
if config['is_cape']:
|
||||||
|
config['smpl_res'] = 3638
|
||||||
|
|
||||||
|
config['latent_dim'] = 128
|
||||||
|
|
||||||
|
config['bottleneck_scale'] = 2
|
||||||
|
|
||||||
|
config['is_label'] = False
|
||||||
|
config['kernel_size'] = 7
|
||||||
|
config['bottleneck_size'] = 64 * config['bottleneck_scale']
|
||||||
|
|
||||||
|
block_setting = [
|
||||||
|
CNBlockConfig(16, 32, 3),
|
||||||
|
CNBlockConfig(32, 128, 3),
|
||||||
|
CNBlockConfig(128, 256, 9),
|
||||||
|
CNBlockConfig(256, config['bottleneck_size'], 9),
|
||||||
|
CNBlockConfig(config['bottleneck_size'], None, 3),
|
||||||
|
]
|
||||||
|
|
||||||
|
block_setting_reverse = [
|
||||||
|
CNBlockConfig(config['bottleneck_size'], 256, 3),
|
||||||
|
CNBlockConfig(256, 128, 9),
|
||||||
|
CNBlockConfig(128, 32, 9),
|
||||||
|
CNBlockConfig(32, 16, 3),
|
||||||
|
CNBlockConfig(16, 3, 3),
|
||||||
|
# CNBlockConfig(3, 3, 3),
|
||||||
|
]
|
||||||
|
|
||||||
|
config['encoder_block_settings'] = block_setting
|
||||||
|
config['decoder_block_settings'] = block_setting_reverse
|
||||||
|
config['activation'] = 'tanh'
|
||||||
|
|
||||||
|
|
||||||
|
config['lr'] = 0.0001
|
||||||
|
config['reg_loss_coeff'] = 0.1
|
||||||
|
|
||||||
|
config['signature'] = { 'id',
|
||||||
|
'frame_nr',
|
||||||
|
'pose_shape',
|
||||||
|
'uv_normals',
|
||||||
|
'mesh_mask',
|
||||||
|
'mesh_body_posed',
|
||||||
|
'mesh_posed',
|
||||||
|
'uv_unposed',
|
||||||
|
'mesh_unposed',
|
||||||
|
'uv_static',
|
||||||
|
'uv_mask',
|
||||||
|
'uv_body_posed',
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
from utils.convnext_utils import CNBlockConfig
|
||||||
|
|
||||||
|
config = dict()
|
||||||
|
|
||||||
|
config['gpu'] = '4'
|
||||||
|
config['name'] = 'direct_6'
|
||||||
|
config['notes'] = 'with normals input but only single garment sequence with msssim and l2 mesh loss only'
|
||||||
|
config['tags'] = ['torch', 'direct']
|
||||||
|
config['script'] = 'scripts/direct_train.py'
|
||||||
|
|
||||||
|
config['pretrained_model'] = ''
|
||||||
|
config['use_curvature'] = False
|
||||||
|
config['use_normals'] = True
|
||||||
|
config['use_skinning'] = True
|
||||||
|
|
||||||
|
# assert that only use curvature or normals
|
||||||
|
assert not (config['use_curvature'] and config['use_normals'])
|
||||||
|
|
||||||
|
config['batch_size'] = 4
|
||||||
|
config['train_dir'] = '/data-local/127/train'
|
||||||
|
config['valid_dir'] = '/data-local/127/train'
|
||||||
|
config['test_dir'] = '/data-net/dataset/test_ready'
|
||||||
|
config['train_frames'] = 'frames_00761.txt'
|
||||||
|
config['valid_frames'] = 'frames_00761.txt'
|
||||||
|
|
||||||
|
config['resolution'] = 512
|
||||||
|
config['is_skirt'] = False
|
||||||
|
config['dataset_in_memory'] = True
|
||||||
|
config['is_cape'] = False
|
||||||
|
config['remove_global_orientation'] = True
|
||||||
|
config['device'] = 'cuda'
|
||||||
|
config['input_features'] = 9
|
||||||
|
|
||||||
|
config['smpl_res'] = 14475
|
||||||
|
if config['is_cape']:
|
||||||
|
config['smpl_res'] = 3638
|
||||||
|
|
||||||
|
config['latent_dim'] = 128
|
||||||
|
|
||||||
|
config['bottleneck_scale'] = 2
|
||||||
|
|
||||||
|
config['is_label'] = False
|
||||||
|
config['kernel_size'] = 7
|
||||||
|
config['bottleneck_size'] = 64 * config['bottleneck_scale']
|
||||||
|
|
||||||
|
block_setting = [
|
||||||
|
CNBlockConfig(16, 32, 3),
|
||||||
|
CNBlockConfig(32, 128, 3),
|
||||||
|
CNBlockConfig(128, 256, 9),
|
||||||
|
CNBlockConfig(256, config['bottleneck_size'], 9),
|
||||||
|
CNBlockConfig(config['bottleneck_size'], None, 3),
|
||||||
|
]
|
||||||
|
|
||||||
|
block_setting_reverse = [
|
||||||
|
CNBlockConfig(config['bottleneck_size'], 256, 3),
|
||||||
|
CNBlockConfig(256, 128, 9),
|
||||||
|
CNBlockConfig(128, 32, 9),
|
||||||
|
CNBlockConfig(32, 16, 3),
|
||||||
|
CNBlockConfig(16, 3, 3),
|
||||||
|
# CNBlockConfig(3, 3, 3),
|
||||||
|
]
|
||||||
|
|
||||||
|
config['encoder_block_settings'] = block_setting
|
||||||
|
config['decoder_block_settings'] = block_setting_reverse
|
||||||
|
config['activation'] = 'tanh'
|
||||||
|
|
||||||
|
|
||||||
|
config['lr'] = 0.0001
|
||||||
|
config['reg_loss_coeff'] = 0.1
|
||||||
|
|
||||||
|
config['signature'] = { 'id',
|
||||||
|
'frame_nr',
|
||||||
|
'pose_shape',
|
||||||
|
'uv_normals',
|
||||||
|
'mesh_mask',
|
||||||
|
'mesh_body_posed',
|
||||||
|
'mesh_posed',
|
||||||
|
'uv_unposed',
|
||||||
|
'mesh_unposed',
|
||||||
|
'uv_static',
|
||||||
|
'uv_mask',
|
||||||
|
'uv_body_posed',
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
from utils.convnext_utils import CNBlockConfig
|
||||||
|
|
||||||
|
config = dict()
|
||||||
|
|
||||||
|
config['gpu'] = '0'
|
||||||
|
config['name'] = 'direct_9'
|
||||||
|
config['notes'] = 'with normals input whole dataset with msssim and l2 mesh loss and reg losses and without skinning'
|
||||||
|
config['tags'] = ['torch', 'direct']
|
||||||
|
config['script'] = 'scripts/direct_train.py'
|
||||||
|
|
||||||
|
config['pretrained_model'] = ''
|
||||||
|
config['use_curvature'] = False
|
||||||
|
config['use_normals'] = True
|
||||||
|
config['use_skinning'] = False
|
||||||
|
|
||||||
|
# assert that only use curvature or normals
|
||||||
|
assert not (config['use_curvature'] and config['use_normals'])
|
||||||
|
|
||||||
|
config['batch_size'] = 4
|
||||||
|
config['train_dir'] = '/data-local/127/train'
|
||||||
|
config['valid_dir'] = '/data-local/127/train'
|
||||||
|
config['test_dir'] = '/data-net/dataset/test_ready'
|
||||||
|
config['train_frames'] = None
|
||||||
|
config['valid_frames'] = None
|
||||||
|
|
||||||
|
config['resolution'] = 512
|
||||||
|
config['is_skirt'] = False
|
||||||
|
config['dataset_in_memory'] = False
|
||||||
|
config['is_cape'] = False
|
||||||
|
config['remove_global_orientation'] = True
|
||||||
|
config['device'] = 'cuda'
|
||||||
|
config['input_features'] = 9
|
||||||
|
|
||||||
|
config['smpl_res'] = 14475
|
||||||
|
if config['is_cape']:
|
||||||
|
config['smpl_res'] = 3638
|
||||||
|
|
||||||
|
config['latent_dim'] = 128
|
||||||
|
|
||||||
|
config['bottleneck_scale'] = 2
|
||||||
|
|
||||||
|
config['is_label'] = False
|
||||||
|
config['kernel_size'] = 7
|
||||||
|
config['bottleneck_size'] = 64 * config['bottleneck_scale']
|
||||||
|
|
||||||
|
block_setting = [
|
||||||
|
CNBlockConfig(16, 32, 3),
|
||||||
|
CNBlockConfig(32, 128, 3),
|
||||||
|
CNBlockConfig(128, 256, 9),
|
||||||
|
CNBlockConfig(256, config['bottleneck_size'], 9),
|
||||||
|
CNBlockConfig(config['bottleneck_size'], None, 3),
|
||||||
|
]
|
||||||
|
|
||||||
|
block_setting_reverse = [
|
||||||
|
CNBlockConfig(config['bottleneck_size'], 256, 3),
|
||||||
|
CNBlockConfig(256, 128, 9),
|
||||||
|
CNBlockConfig(128, 32, 9),
|
||||||
|
CNBlockConfig(32, 16, 3),
|
||||||
|
CNBlockConfig(16, 3, 3),
|
||||||
|
# CNBlockConfig(3, 3, 3),
|
||||||
|
]
|
||||||
|
|
||||||
|
config['encoder_block_settings'] = block_setting
|
||||||
|
config['decoder_block_settings'] = block_setting_reverse
|
||||||
|
config['activation'] = 'tanh'
|
||||||
|
|
||||||
|
|
||||||
|
config['lr'] = 0.0001
|
||||||
|
config['reg_loss_coeff'] = 0.1
|
||||||
|
|
||||||
|
config['signature'] = { 'id',
|
||||||
|
'frame_nr',
|
||||||
|
'pose_shape',
|
||||||
|
'uv_normals',
|
||||||
|
'mesh_mask',
|
||||||
|
'mesh_body_posed',
|
||||||
|
'mesh_posed',
|
||||||
|
'uv_static',
|
||||||
|
'uv_mask',
|
||||||
|
'uv_body_posed',
|
||||||
|
}
|
||||||
|
|
||||||
|
if config['use_skinning']:
|
||||||
|
config['signature'].add('uv_unposed')
|
||||||
|
config['signature'].add('mesh_unposed')
|
||||||
|
else:
|
||||||
|
config['signature'].add('uv_posed')
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
from utils.convnext_utils import CNBlockConfig
|
||||||
|
|
||||||
|
config = dict()
|
||||||
|
|
||||||
|
config['gpu'] = '6'
|
||||||
|
config['name'] = 'direct_8'
|
||||||
|
config['notes'] = 'with normals input but only single garment sequence with msssim and l2 mesh loss only and without skinning and remasked'
|
||||||
|
config['tags'] = ['torch', 'direct']
|
||||||
|
config['script'] = 'scripts/direct_train.py'
|
||||||
|
|
||||||
|
config['pretrained_model'] = ''
|
||||||
|
config['use_curvature'] = False
|
||||||
|
config['use_normals'] = True
|
||||||
|
config['use_skinning'] = False
|
||||||
|
|
||||||
|
# assert that only use curvature or normals
|
||||||
|
assert not (config['use_curvature'] and config['use_normals'])
|
||||||
|
|
||||||
|
config['batch_size'] = 4
|
||||||
|
config['train_dir'] = '/data-net/dataset/00761'
|
||||||
|
config['valid_dir'] = '/data-net/dataset/00761'
|
||||||
|
config['test_dir'] = '/data-net/dataset/test_ready'
|
||||||
|
config['train_frames'] = None
|
||||||
|
config['valid_frames'] = None
|
||||||
|
|
||||||
|
config['resolution'] = 512
|
||||||
|
config['is_skirt'] = False
|
||||||
|
config['dataset_in_memory'] = True
|
||||||
|
config['is_cape'] = False
|
||||||
|
config['remove_global_orientation'] = True
|
||||||
|
config['device'] = 'cuda'
|
||||||
|
config['input_features'] = 9
|
||||||
|
|
||||||
|
config['smpl_res'] = 14475
|
||||||
|
if config['is_cape']:
|
||||||
|
config['smpl_res'] = 3638
|
||||||
|
|
||||||
|
config['latent_dim'] = 128
|
||||||
|
|
||||||
|
config['bottleneck_scale'] = 2
|
||||||
|
|
||||||
|
config['is_label'] = False
|
||||||
|
config['kernel_size'] = 7
|
||||||
|
config['bottleneck_size'] = 64 * config['bottleneck_scale']
|
||||||
|
|
||||||
|
block_setting = [
|
||||||
|
CNBlockConfig(16, 32, 3),
|
||||||
|
CNBlockConfig(32, 128, 3),
|
||||||
|
CNBlockConfig(128, 256, 9),
|
||||||
|
CNBlockConfig(256, config['bottleneck_size'], 9),
|
||||||
|
CNBlockConfig(config['bottleneck_size'], None, 3),
|
||||||
|
]
|
||||||
|
|
||||||
|
block_setting_reverse = [
|
||||||
|
CNBlockConfig(config['bottleneck_size'], 256, 3),
|
||||||
|
CNBlockConfig(256, 128, 9),
|
||||||
|
CNBlockConfig(128, 32, 9),
|
||||||
|
CNBlockConfig(32, 16, 3),
|
||||||
|
CNBlockConfig(16, 3, 3),
|
||||||
|
# CNBlockConfig(3, 3, 3),
|
||||||
|
]
|
||||||
|
|
||||||
|
config['encoder_block_settings'] = block_setting
|
||||||
|
config['decoder_block_settings'] = block_setting_reverse
|
||||||
|
config['activation'] = 'tanh'
|
||||||
|
|
||||||
|
|
||||||
|
config['lr'] = 0.0001
|
||||||
|
config['reg_loss_coeff'] = 0.1
|
||||||
|
|
||||||
|
config['signature'] = { 'id',
|
||||||
|
'frame_nr',
|
||||||
|
'pose_shape',
|
||||||
|
'uv_normals',
|
||||||
|
'mesh_mask',
|
||||||
|
'mesh_body_posed',
|
||||||
|
'mesh_posed',
|
||||||
|
'uv_static',
|
||||||
|
'uv_mask',
|
||||||
|
'uv_body_posed',
|
||||||
|
}
|
||||||
|
|
||||||
|
if config['use_skinning']:
|
||||||
|
config['signature'].add('uv_unposed')
|
||||||
|
config['signature'].add('mesh_unposed')
|
||||||
|
else:
|
||||||
|
config['signature'].add('uv_posed')
|
||||||
+5
-5
@@ -18,12 +18,12 @@ from torch_cluster import knn
|
|||||||
smpl_to_keep_orig = sio.loadmat('smpl/keep_remove.mat')['keep'].reshape(-1)
|
smpl_to_keep_orig = sio.loadmat('smpl/keep_remove.mat')['keep'].reshape(-1)
|
||||||
smpl_to_keep_orig = smpl_to_keep_orig[smpl_to_keep_orig < 6890]
|
smpl_to_keep_orig = smpl_to_keep_orig[smpl_to_keep_orig < 6890]
|
||||||
|
|
||||||
to_keep = sio.loadmat('smpl/keep_remove.mat')['keep'].reshape(-1)
|
# to_keep = sio.loadmat('smpl/keep_remove.mat')['keep'].reshape(-1)
|
||||||
F_coll = torch.tensor(np.load("smpl/smpl_faces.npy")[to_keep,:], device='cuda')
|
F_coll = torch.tensor(np.load("smpl/smpl_faces.npy"), device='cuda')
|
||||||
F_coll_skirt = torch.tensor(np.load("smpl/smpl_faces_skirt.npy")[to_keep,:], device='cuda')
|
F_coll_skirt = torch.tensor(np.load("smpl/smpl_faces_skirt.npy"), device='cuda')
|
||||||
F_coll_orig = torch.tensor(np.load("smpl/smpl_faces_orig.npy")[:6890,:], device='cuda')
|
F_coll_orig = torch.tensor(np.load("smpl/smpl_faces_orig.npy")[:6890,:], device='cuda')
|
||||||
F_norm = torch.tensor(np.tile(np.load("smpl/smpl_faces.npy")[to_keep,:][None,:,:], [4,1,1]), device='cuda')
|
F_norm = torch.tensor(np.tile(np.load("smpl/smpl_faces.npy")[None,:,:], [4,1,1]), device='cuda')
|
||||||
F_norm_skirt = torch.tensor(np.tile(np.load("smpl/smpl_faces_skirt.npy")[to_keep,:][None,:,:], [4,1,1]), device='cuda')
|
F_norm_skirt = torch.tensor(np.tile(np.load("smpl/smpl_faces_skirt.npy")[None,:,:], [4,1,1]), device='cuda')
|
||||||
F_norm_orig = torch.tensor(np.tile(np.load("smpl/smpl_faces_orig.npy")[:6890,:][None,:,:], [4,1,1]), device='cuda')
|
F_norm_orig = torch.tensor(np.tile(np.load("smpl/smpl_faces_orig.npy")[:6890,:][None,:,:], [4,1,1]), device='cuda')
|
||||||
F_norm_orig = F_norm_orig[:,smpl_to_keep_orig,:]
|
F_norm_orig = F_norm_orig[:,smpl_to_keep_orig,:]
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from configs.direct_1 import config
|
from configs.direct_6 import config
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
# parser = argparse.ArgumentParser(description='')
|
# parser = argparse.ArgumentParser(description='')
|
||||||
|
|||||||
+68
-34
@@ -13,7 +13,7 @@ args = vars(parser.parse_args())
|
|||||||
config_module = importlib.import_module(args['config'])
|
config_module = importlib.import_module(args['config'])
|
||||||
config = config_module.config
|
config = config_module.config
|
||||||
if args['debug']:
|
if args['debug']:
|
||||||
from configs.direct_1 import config
|
from configs.direct_7 import config
|
||||||
# from configs.ae_static_orig_2 import config
|
# from configs.ae_static_orig_2 import config
|
||||||
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
|
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
|
||||||
os.environ["CUDA_VISIBLE_DEVICES"] = config['gpu']
|
os.environ["CUDA_VISIBLE_DEVICES"] = config['gpu']
|
||||||
@@ -52,7 +52,7 @@ from pytorch_msssim import MS_SSIM
|
|||||||
|
|
||||||
|
|
||||||
def init_wandb():
|
def init_wandb():
|
||||||
run = wandb.init(project='iccv', name=config['name'], notes=config['notes'], dir='/data-local/127/temp', tags=config['tags'])
|
run = wandb.init(project='iccv', name=config['name'], notes=config['notes'], dir='/data-local/127_2/temp', tags=config['tags'])
|
||||||
artifact = wandb.Artifact('code', type='code')
|
artifact = wandb.Artifact('code', type='code')
|
||||||
artifact.add_file('scripts/direct_train.py')
|
artifact.add_file('scripts/direct_train.py')
|
||||||
artifact.add_file('losses/losses.py')
|
artifact.add_file('losses/losses.py')
|
||||||
@@ -76,26 +76,37 @@ def train_step(batch):
|
|||||||
# with torch.autocast(device_type='cuda', dtype=torch.float16, enabled=use_amp):
|
# with torch.autocast(device_type='cuda', dtype=torch.float16, enabled=use_amp):
|
||||||
if config['use_curvature']:
|
if config['use_curvature']:
|
||||||
input = torch.cat([batch['uv_curvature'], batch['uv_static']], axis=1)
|
input = torch.cat([batch['uv_curvature'], batch['uv_static']], axis=1)
|
||||||
|
elif config['use_normals']:
|
||||||
|
input = torch.cat([batch['uv_normals'], batch['uv_body_posed'], batch['uv_static']], axis=1)
|
||||||
else:
|
else:
|
||||||
input = torch.cat([batch['uv_body_posed'], batch['uv_static']], axis=1)
|
input = torch.cat([batch['uv_body_posed'], batch['uv_static']], axis=1)
|
||||||
pred = model([input, batch['uv_mask']])
|
pred = model([input, batch['uv_mask']])
|
||||||
|
|
||||||
mesh_pred = uv2mesh(pred)
|
mesh_pred = uv2mesh(pred)
|
||||||
mesh_orig = batch['mesh_unposed']
|
if config['use_skinning']:
|
||||||
shape = batch['pose_shape'][:, 72:]
|
mesh_orig = batch['mesh_unposed']
|
||||||
gender = torch.greater_equal(shape[:, 10] , 0.5).to(torch.long)
|
uv_orig = batch['uv_unposed']
|
||||||
shape_offsets = torch.stack([torch.tensordot(shape[i,:10][None, :], smpl.shapedirs[gender[i]], dims=[[1], [2]])[0,smpl.to_keep,:] for i in range(shape.shape[0])])
|
shape = batch['pose_shape'][:, 72:]
|
||||||
mesh_pred_shaped = mesh_pred + shape_offsets * batch['mesh_mask'][:,:,None]
|
gender = torch.greater_equal(shape[:, 10] , 0.5).to(torch.long)
|
||||||
mesh_pred_posed = smpl(batch['pose_shape'][:, :72], batch['pose_shape'][:, 72:], mesh_pred_shaped)[0]
|
shape_offsets = torch.stack([torch.tensordot(shape[i,:10][None, :], smpl.shapedirs[gender[i]], dims=[[1], [2]])[0,smpl.to_keep,:] for i in range(shape.shape[0])])
|
||||||
|
mesh_pred_shaped = mesh_pred + shape_offsets * batch['mesh_mask'][:,:,None]
|
||||||
|
mesh_pred_posed = smpl(batch['pose_shape'][:, :72], batch['pose_shape'][:, 72:], mesh_pred_shaped)[0]
|
||||||
|
else:
|
||||||
|
mesh_orig = batch['mesh_posed']
|
||||||
|
uv_orig = batch['uv_posed']
|
||||||
|
mesh_pred_posed = mesh_pred
|
||||||
|
|
||||||
|
l2_mesh_loss = torch.mean(1e3 * torch.mean(torch.sum(batch['mesh_mask'][:,:,None] * (batch['mesh_posed'] - mesh_pred_posed) ** 2, axis=-1), axis=-1))
|
||||||
|
|
||||||
e_loss = torch.mean(edge_loss(mesh_pred, mesh_orig, batch['mesh_mask']))
|
e_loss = torch.mean(edge_loss(mesh_pred, mesh_orig, batch['mesh_mask']))
|
||||||
c_loss, c_ratio = collision_loss(mesh_pred_posed, batch['mesh_body_posed'], batch['mesh_mask'])
|
c_loss, c_ratio = collision_loss(mesh_pred_posed, batch['mesh_body_posed'], batch['mesh_mask'])
|
||||||
c_loss, c_ratio = torch.mean(c_loss), torch.mean(c_ratio)
|
c_loss, c_ratio = torch.mean(c_loss), torch.mean(c_ratio)
|
||||||
# l2_loss = torch.mean(1e3 * torch.mean(torch.sum(((batch['uv_unposed'] - pred) ** 2), axis=-1), axis=[1, 2]))
|
# l2_loss = torch.mean(1e3 * torch.mean(torch.sum(((batch['uv_unposed'] - pred) ** 2), axis=-1), axis=[1, 2]))
|
||||||
l2_mesh_loss = torch.mean(1e3 * torch.mean(torch.sum(batch['mesh_mask'][:,:,None] * (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'])
|
||||||
|
|
||||||
loss = l2_mesh_loss + (e_loss + c_loss + n_loss) * config['reg_loss_coeff']
|
|
||||||
|
ms_ssim = torch.mean(_MSSSIM(pred + 1, uv_orig + 1))
|
||||||
|
loss = l2_mesh_loss + (1 - ms_ssim) * 1e3 + (e_loss + c_loss + n_loss) * config['reg_loss_coeff']
|
||||||
|
|
||||||
optimizer.zero_grad()
|
optimizer.zero_grad()
|
||||||
loss.backward()
|
loss.backward()
|
||||||
@@ -107,7 +118,6 @@ def train_step(batch):
|
|||||||
|
|
||||||
model.eval()
|
model.eval()
|
||||||
with torch.inference_mode():
|
with torch.inference_mode():
|
||||||
ms_ssim = torch.mean(_MSSSIM(pred + 1, batch['uv_unposed'] + 1))
|
|
||||||
metric = torch.sum(torch.sqrt(torch.sum(batch['mesh_mask'][:,:,None] * (mesh_orig - mesh_pred.detach()) ** 2, axis=-1))) / torch.sum(batch['mesh_mask'])
|
metric = torch.sum(torch.sqrt(torch.sum(batch['mesh_mask'][:,:,None] * (mesh_orig - mesh_pred.detach()) ** 2, axis=-1))) / torch.sum(batch['mesh_mask'])
|
||||||
|
|
||||||
return { 'train/loss': loss, 'train/edge_loss': e_loss, 'train/euclid_error': metric, 'train/collision_ratio': c_ratio,
|
return { 'train/loss': loss, 'train/edge_loss': e_loss, 'train/euclid_error': metric, 'train/collision_ratio': c_ratio,
|
||||||
@@ -121,16 +131,25 @@ def valid_step(batch):
|
|||||||
with torch.inference_mode():
|
with torch.inference_mode():
|
||||||
if config['use_curvature']:
|
if config['use_curvature']:
|
||||||
input = torch.cat([batch['uv_curvature'], batch['uv_static']], axis=1)
|
input = torch.cat([batch['uv_curvature'], batch['uv_static']], axis=1)
|
||||||
|
elif config['use_normals']:
|
||||||
|
input = torch.cat([batch['uv_normals'], batch['uv_body_posed'], batch['uv_static']], axis=1)
|
||||||
else:
|
else:
|
||||||
input = torch.cat([batch['uv_body_posed'], batch['uv_static']], axis=1)
|
input = torch.cat([batch['uv_body_posed'], batch['uv_static']], axis=1)
|
||||||
|
|
||||||
pred = model([input, batch['uv_mask']])
|
pred = model([input, batch['uv_mask']])
|
||||||
mesh_pred = uv2mesh(pred)
|
mesh_pred = uv2mesh(pred)
|
||||||
mesh_orig = batch['mesh_unposed']
|
if config['use_skinning']:
|
||||||
shape = batch['pose_shape'][:, 72:]
|
mesh_orig = batch['mesh_unposed']
|
||||||
gender = torch.greater_equal(shape[:, 10] , 0.5).to(torch.long)
|
uv_orig = batch['uv_unposed']
|
||||||
shape_offsets = torch.stack([torch.tensordot(shape[i,:10][None, :], smpl.shapedirs[gender[i]], dims=[[1], [2]])[0,smpl.to_keep,:] for i in range(shape.shape[0])])
|
shape = batch['pose_shape'][:, 72:]
|
||||||
mesh_pred_shaped = mesh_pred + shape_offsets * batch['mesh_mask'][:,:,None]
|
gender = torch.greater_equal(shape[:, 10] , 0.5).to(torch.long)
|
||||||
mesh_pred_posed = smpl(batch['pose_shape'][:, :72], batch['pose_shape'][:, 72:], mesh_pred_shaped)[0]
|
shape_offsets = torch.stack([torch.tensordot(shape[i,:10][None, :], smpl.shapedirs[gender[i]], dims=[[1], [2]])[0,smpl.to_keep,:] for i in range(shape.shape[0])])
|
||||||
|
mesh_pred_shaped = mesh_pred + shape_offsets * batch['mesh_mask'][:,:,None]
|
||||||
|
mesh_pred_posed = smpl(batch['pose_shape'][:, :72], batch['pose_shape'][:, 72:], mesh_pred_shaped)[0]
|
||||||
|
else:
|
||||||
|
mesh_orig = batch['mesh_posed']
|
||||||
|
uv_orig = batch['uv_posed']
|
||||||
|
mesh_pred_posed = mesh_pred
|
||||||
|
|
||||||
e_loss = torch.mean(edge_loss(mesh_pred, mesh_orig, batch['mesh_mask']))
|
e_loss = torch.mean(edge_loss(mesh_pred, mesh_orig, batch['mesh_mask']))
|
||||||
c_loss, c_ratio = collision_loss(mesh_pred_posed, batch['mesh_body_posed'], batch['mesh_mask'])
|
c_loss, c_ratio = collision_loss(mesh_pred_posed, batch['mesh_body_posed'], batch['mesh_mask'])
|
||||||
@@ -139,8 +158,8 @@ def valid_step(batch):
|
|||||||
l2_mesh_loss = torch.mean(1e3 * torch.mean(torch.sum(batch['mesh_mask'][:,:,None] * (batch['mesh_posed'] - mesh_pred_posed) ** 2, axis=-1), axis=-1))
|
l2_mesh_loss = torch.mean(1e3 * torch.mean(torch.sum(batch['mesh_mask'][:,:,None] * (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'])
|
||||||
|
|
||||||
ms_ssim = torch.mean(_MSSSIM(pred + 1, batch['uv_unposed'] + 1))
|
ms_ssim = torch.mean(_MSSSIM(pred + 1, uv_orig + 1))
|
||||||
loss = l2_mesh_loss + (e_loss + c_loss + n_loss) * config['reg_loss_coeff']
|
loss = l2_mesh_loss + (1 - ms_ssim) * 1e3 + (e_loss + c_loss + n_loss) * config['reg_loss_coeff']
|
||||||
|
|
||||||
metric = torch.sum(torch.sqrt(torch.sum(batch['mesh_mask'][:,:,None] * (mesh_orig - mesh_pred) ** 2, axis=-1))) / torch.sum(batch['mesh_mask'])
|
metric = torch.sum(torch.sqrt(torch.sum(batch['mesh_mask'][:,:,None] * (mesh_orig - mesh_pred) ** 2, axis=-1))) / torch.sum(batch['mesh_mask'])
|
||||||
|
|
||||||
@@ -154,49 +173,64 @@ def plot_everything(batch: dict, type: str):
|
|||||||
with torch.inference_mode():
|
with torch.inference_mode():
|
||||||
if config['use_curvature']:
|
if config['use_curvature']:
|
||||||
input = torch.cat([batch['uv_curvature'], batch['uv_static']], axis=1)
|
input = torch.cat([batch['uv_curvature'], batch['uv_static']], axis=1)
|
||||||
|
elif config['use_normals']:
|
||||||
|
input = torch.cat([batch['uv_normals'], batch['uv_body_posed'], batch['uv_static']], axis=1)
|
||||||
else:
|
else:
|
||||||
input = torch.cat([batch['uv_body_posed'], batch['uv_static']], axis=1)
|
input = torch.cat([batch['uv_body_posed'], batch['uv_static']], axis=1)
|
||||||
pred = model([input, batch['uv_mask']]).detach()
|
pred = model([input, batch['uv_mask']]).detach()
|
||||||
|
|
||||||
mesh_pred = uv2mesh(pred).cpu().numpy()
|
mesh_pred = uv2mesh(pred).cpu().numpy()
|
||||||
mesh_orig = batch['mesh_unposed'].cpu().numpy()
|
if config['use_skinning']:
|
||||||
|
mesh_orig = batch['mesh_unposed'].cpu().numpy()
|
||||||
|
uv_orig = batch['uv_unposed']
|
||||||
|
else:
|
||||||
|
mesh_orig = batch['mesh_posed'].cpu().numpy()
|
||||||
|
uv_orig = batch['uv_posed']
|
||||||
|
|
||||||
orig_img = torch.permute(batch['uv_unposed'], [0,2,3,1])
|
orig_img = torch.permute(uv_orig, [0,2,3,1])
|
||||||
uv_static_img = torch.permute(batch['uv_static'], [0,2,3,1])
|
uv_static_img = torch.permute(batch['uv_static'], [0,2,3,1])
|
||||||
uv_body_posed_img = torch.permute(batch['uv_body_posed'], [0,2,3,1])
|
uv_body_posed_img = torch.permute(batch['uv_body_posed'], [0,2,3,1])
|
||||||
|
uv_normals_img = (torch.permute(batch['uv_normals'], [0,2,3,1]) + 1.1) / 2.2
|
||||||
pred_img = torch.permute(pred, [0,2,3,1])
|
pred_img = torch.permute(pred, [0,2,3,1])
|
||||||
img = torch.concat((uv_static_img, uv_body_posed_img, orig_img, pred_img), axis=2)
|
img = torch.concat((uv_static_img, uv_body_posed_img, uv_normals_img, orig_img, pred_img), axis=2)
|
||||||
imgs = [wandb.Image((img[i].cpu().numpy() + 1) / 2.0) for i in range(4)]
|
imgs = [wandb.Image((img[i].cpu().numpy() + 1) / 2.0) for i in range(4)]
|
||||||
|
|
||||||
F = np.load("smpl/smpl_faces" + skirt_modifier + ("_orig" if config['is_cape'] else "") + ".npy")
|
F = np.load("smpl/smpl_faces" + skirt_modifier + ("_orig" if config['is_cape'] else "") + ".npy")
|
||||||
mask = batch['mesh_mask'].cpu().numpy().astype(bool)
|
mask = batch['mesh_mask'].cpu().numpy().astype(bool)
|
||||||
|
|
||||||
shape = batch['pose_shape'][:, 72:]
|
if config['use_skinning']:
|
||||||
gender = torch.greater_equal(shape[:, 10] , 0.5).to(torch.long)
|
shape = batch['pose_shape'][:, 72:]
|
||||||
shape_offsets = torch.stack([torch.tensordot(shape[i,:10][None, :], smpl.shapedirs[gender[i]], dims=[[1], [2]])[0,smpl.to_keep,:] for i in range(shape.shape[0])]).cpu().numpy()
|
gender = torch.greater_equal(shape[:, 10] , 0.5).to(torch.long)
|
||||||
|
shape_offsets = torch.stack([torch.tensordot(shape[i,:10][None, :], smpl.shapedirs[gender[i]], dims=[[1], [2]])[0,smpl.to_keep,:] for i in range(shape.shape[0])]).cpu().numpy()
|
||||||
|
|
||||||
garment_unposed, faces = maskFacesBatch(mesh_pred, F, mask)
|
garment_unposed, faces = maskFacesBatch(mesh_pred, F, mask)
|
||||||
garment_unposed = [garment_unposed[i] + shape_offsets[i, mask[i], :] for i in range(mask.shape[0])]
|
garment_unposed = [garment_unposed[i] + shape_offsets[i, mask[i], :] for i in range(mask.shape[0])]
|
||||||
gt = [mesh_orig[i][mask[i], :] + shape_offsets[i, mask[i], :] for i in range(pred.shape[0])]
|
gt = [mesh_orig[i][mask[i], :] + shape_offsets[i, mask[i], :] for i in range(pred.shape[0])]
|
||||||
|
|
||||||
for i in range(mesh_orig.shape[0]):
|
for i in range(mesh_orig.shape[0]):
|
||||||
mesh_pred[i, mask[i], :] += shape_offsets[i, mask[i], :]
|
mesh_pred[i, mask[i], :] += shape_offsets[i, mask[i], :]
|
||||||
mesh_posed = smpl(batch['pose_shape'][:, :72], batch['pose_shape'][:, 72:], torch.tensor(mesh_pred, device=config['device']))[0].cpu().numpy()
|
mesh_posed = smpl(batch['pose_shape'][:, :72], batch['pose_shape'][:, 72:], torch.tensor(mesh_pred, device=config['device']))[0].cpu().numpy()
|
||||||
|
else:
|
||||||
|
garment_unposed, faces = maskFacesBatch(mesh_pred, F, mask)
|
||||||
|
mesh_posed = mesh_pred
|
||||||
|
gt = [mesh_orig[i][mask[i], :] for i in range(pred.shape[0])]
|
||||||
|
|
||||||
gt_posed = [batch['mesh_posed'].cpu().numpy()[i, mask[i], :] for i in range(mask.shape[0])]
|
gt_posed = [batch['mesh_posed'].cpu().numpy()[i, mask[i], :] for i in range(mask.shape[0])]
|
||||||
|
|
||||||
mesh_posed_fixed = fix_collision(torch.tensor(mesh_posed, device=config['device']), batch['mesh_body_posed'], torch.tensor(mask, device=config['device'])).cpu().numpy()
|
mesh_posed_fixed = fix_collision(torch.tensor(mesh_posed, device=config['device']), batch['mesh_body_posed'], torch.tensor(mask, device=config['device'])).cpu().numpy()
|
||||||
body = batch['mesh_body_posed'].cpu().numpy()
|
body = batch['mesh_body_posed'].cpu().numpy()
|
||||||
|
|
||||||
garment_posed = [mesh_posed[i, mask[i], :] for i in range(body.shape[0])]
|
garment_posed = [mesh_posed[i, mask[i], :] for i in range(body.shape[0])]
|
||||||
collision = [np.concatenate((body[i], garment_posed[i]), axis=0) for i in range(len(garment_posed))]
|
collision = [np.concatenate((body[i], garment_posed[i]), axis=0) for i in range(len(garment_posed))]
|
||||||
collision_faces = [np.concatenate((F, faces[i] + config['smpl_res']), axis=0) for i in range(len(garment_posed))]
|
|
||||||
collision_color = [np.concatenate((np.ones_like(body[i], dtype=np.int32)*100, np.ones_like(garment_posed[i], dtype=np.int32)*230), axis=0) for i in range(len(garment_posed))]
|
collision_color = [np.concatenate((np.ones_like(body[i], dtype=np.int32)*100, np.ones_like(garment_posed[i], dtype=np.int32)*230), axis=0) for i in range(len(garment_posed))]
|
||||||
|
|
||||||
garment_posed_fixed = [mesh_posed_fixed[i, mask[i], :] for i in range(body.shape[0])]
|
garment_posed_fixed = [mesh_posed_fixed[i, mask[i], :] for i in range(body.shape[0])]
|
||||||
collision_fixed = [np.concatenate((body[i], garment_posed_fixed[i]), axis=0) for i in range(len(garment_posed))]
|
collision_fixed = [np.concatenate((body[i], garment_posed_fixed[i]), axis=0) for i in range(len(garment_posed))]
|
||||||
collision_gt = [np.concatenate((body[i], gt_posed[i]), axis=0) for i in range(len(garment_posed))]
|
collision_gt = [np.concatenate((body[i], gt_posed[i]), axis=0) for i in range(len(garment_posed))]
|
||||||
|
|
||||||
|
# faces_ = np.load('/data-net/dataset/00761/faces/00761.npy')
|
||||||
|
# faces = [faces_ for i in range(len(garment_posed))]
|
||||||
|
collision_faces = [np.concatenate((F, faces[i] + config['smpl_res']), axis=0) for i in range(len(garment_posed))]
|
||||||
|
|
||||||
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 = { 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_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) }
|
||||||
|
|
||||||
@@ -273,7 +307,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
if not args['debug']:
|
if not args['debug']:
|
||||||
# model = torch.compile(model)
|
# model = torch.compile(model)
|
||||||
wandb.watch(model, log='all', log_freq=1000, log_graph=True)
|
wandb.watch(model, log='all', log_freq=10000, log_graph=True)
|
||||||
|
|
||||||
train()
|
train()
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from losses.losses import _nearest_neighbour
|
|||||||
""" COLLISION FUNCTIONS START """
|
""" COLLISION FUNCTIONS START """
|
||||||
# F = np.load("smpl/smpl_faces.npy")
|
# F = np.load("smpl/smpl_faces.npy")
|
||||||
to_keep = sio.loadmat('smpl/keep_remove.mat')['keep'].reshape(-1)
|
to_keep = sio.loadmat('smpl/keep_remove.mat')['keep'].reshape(-1)
|
||||||
F_fix_coll = torch.tensor(np.tile(np.load("smpl/smpl_faces.npy")[to_keep,:][None,:,:], [4,1,1]), device='cuda')
|
F_fix_coll = torch.tensor(np.tile(np.load("smpl/smpl_faces.npy")[None,:,:], [4,1,1]), device='cuda')
|
||||||
smpl_to_keep_orig_post = sio.loadmat('smpl/keep_remove.mat')['keep'].reshape(-1)
|
smpl_to_keep_orig_post = sio.loadmat('smpl/keep_remove.mat')['keep'].reshape(-1)
|
||||||
smpl_to_keep_orig_post = smpl_to_keep_orig_post[smpl_to_keep_orig_post < 6890]
|
smpl_to_keep_orig_post = smpl_to_keep_orig_post[smpl_to_keep_orig_post < 6890]
|
||||||
F_fix_coll_orig = torch.tensor(np.tile(np.load("smpl/smpl_faces_orig.npy")[:6890,:][None,:,:], [4,1,1]), device='cuda')[:,smpl_to_keep_orig_post,:]
|
F_fix_coll_orig = torch.tensor(np.tile(np.load("smpl/smpl_faces_orig.npy")[:6890,:][None,:,:], [4,1,1]), device='cuda')[:,smpl_to_keep_orig_post,:]
|
||||||
|
|||||||
Reference in New Issue
Block a user