Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32c3d1103f | ||
|
|
263754d755 | ||
|
|
4f869c864c | ||
|
|
e0825722e3 |
+6
-6
@@ -2,9 +2,9 @@ from utils.convnext_utils import CNBlockConfig
|
|||||||
|
|
||||||
config = dict()
|
config = dict()
|
||||||
|
|
||||||
config['gpu'] = '6'
|
config['gpu'] = '0'
|
||||||
config['name'] = 'direct_7'
|
config['name'] = 'direct_9'
|
||||||
config['notes'] = 'with normals input but only single garment sequence with msssim and l2 mesh loss only and without skinning'
|
config['notes'] = 'with normals input whole dataset with msssim and l2 mesh loss and reg losses and without skinning'
|
||||||
config['tags'] = ['torch', 'direct']
|
config['tags'] = ['torch', 'direct']
|
||||||
config['script'] = 'scripts/direct_train.py'
|
config['script'] = 'scripts/direct_train.py'
|
||||||
|
|
||||||
@@ -20,12 +20,12 @@ config['batch_size'] = 4
|
|||||||
config['train_dir'] = '/data-local/127/train'
|
config['train_dir'] = '/data-local/127/train'
|
||||||
config['valid_dir'] = '/data-local/127/train'
|
config['valid_dir'] = '/data-local/127/train'
|
||||||
config['test_dir'] = '/data-net/dataset/test_ready'
|
config['test_dir'] = '/data-net/dataset/test_ready'
|
||||||
config['train_frames'] = 'frames_00761.txt'
|
config['train_frames'] = None
|
||||||
config['valid_frames'] = 'frames_00761.txt'
|
config['valid_frames'] = None
|
||||||
|
|
||||||
config['resolution'] = 512
|
config['resolution'] = 512
|
||||||
config['is_skirt'] = False
|
config['is_skirt'] = False
|
||||||
config['dataset_in_memory'] = True
|
config['dataset_in_memory'] = False
|
||||||
config['is_cape'] = False
|
config['is_cape'] = False
|
||||||
config['remove_global_orientation'] = True
|
config['remove_global_orientation'] = True
|
||||||
config['device'] = 'cuda'
|
config['device'] = 'cuda'
|
||||||
|
|||||||
@@ -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,:]
|
||||||
|
|
||||||
|
|||||||
+13
-8
@@ -98,8 +98,15 @@ def train_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))
|
||||||
|
|
||||||
|
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 = 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]))
|
||||||
|
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, uv_orig + 1))
|
ms_ssim = torch.mean(_MSSSIM(pred + 1, uv_orig + 1))
|
||||||
loss = l2_mesh_loss + (1 - ms_ssim) * 1e3
|
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()
|
||||||
@@ -112,11 +119,6 @@ def train_step(batch):
|
|||||||
model.eval()
|
model.eval()
|
||||||
with torch.inference_mode():
|
with torch.inference_mode():
|
||||||
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'])
|
||||||
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 = 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]))
|
|
||||||
n_loss = normal_loss(mesh_pred_posed, batch['mesh_posed'], batch['mesh_mask'], is_skirt=config['is_skirt'], is_smpl_orig=config['is_cape'])
|
|
||||||
|
|
||||||
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,
|
||||||
'train/ms_ssim': ms_ssim, 'train/collision_loss': c_loss, 'train/l2_mesh_loss': l2_mesh_loss,
|
'train/ms_ssim': ms_ssim, 'train/collision_loss': c_loss, 'train/l2_mesh_loss': l2_mesh_loss,
|
||||||
@@ -157,7 +159,7 @@ def valid_step(batch):
|
|||||||
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, uv_orig + 1))
|
ms_ssim = torch.mean(_MSSSIM(pred + 1, uv_orig + 1))
|
||||||
loss = l2_mesh_loss + (1 - ms_ssim) * 1e3
|
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'])
|
||||||
|
|
||||||
@@ -219,13 +221,16 @@ def plot_everything(batch: dict, type: str):
|
|||||||
|
|
||||||
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) }
|
||||||
|
|
||||||
|
|||||||
@@ -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