fix some path

This commit is contained in:
sen.liang committed 2022-03-17 15:20:13 +08:00
1 parent e0f24982d1
commit 51c96565e7
16 files changed
+525 -44

No files matched your search

+12 -4
View File
@@ -32,7 +32,7 @@ class Audio2MeshModel(Base):
init_net(self.netG, init_type='kaiming', gpu_ids=opt.GPUS)
# init last layer
init_exp_weight = np.load("/ssdata1/lsen/CODE/voca/training_data/init_expression_basis.npy")
init_exp_weight = np.load("./data/init_expression_basis.npy")
init_exp_weight = torch.from_numpy(init_exp_weight).float().to(self.device)
init_exp_weight = init_exp_weight[:, :50]
self.netG.module.decoder_mesh.weight.data = init_exp_weight
@@ -46,8 +46,11 @@ class Audio2MeshModel(Base):
self.netR, self.flame = define_netR(device=self.device)
# self.netG.init_reconstruct_model(self.netR)
path_deca_mean = Path("./data/DECA_obama_mean.npy")
# path_deca_mean = Path("./data/DECA_obama_mean.npy")
path_deca_mean = self.opt.DATASET.path_mean_dict
self.mean_dict = np.load(path_deca_mean, allow_pickle=True).item()
print(f"load mean from {path_deca_mean}, \nmean_dict keys = {self.mean_dict.keys()}")
self.template_verts = self.get_template_vertices()
debug(opt, f"template_verts shape = {self.template_verts.shape}")
debug(opt, f"mean_dict keys = {self.mean_dict.keys()}", verbose=True)
@@ -188,8 +191,7 @@ class Audio2MeshModel(Base):
with torch.no_grad():
samples_pt = self.netG(cond) # B x N x 16 x nc_condit
samples_pt += self.template_verts # B x N x 5023 x 3
samples_pt += self.template_verts # B x N x 5023 x 3
loss = self.eval_losses_for_infer_loss(samples_pt, data)
return loss
@@ -245,7 +247,13 @@ class Audio2MeshModel(Base):
batch_pos = torch.zeros(1, 6).to(self.device)
verts, _, _ = self.netR.get_vertices(batch_shape, batch_exp, batch_pos) # 1 x 5023 x 3
# np.save("./data/template.npy", verts.squeeze().cpu().numpy())
# print(f"save template.npy = {verts.squeeze().shape}")
# assert False
verts = verts.unsqueeze(dim=0) # 1 x 1 x 5023 x 3
print(f"template verts reshape = {verts.shape}")
return verts
+10 -6
View File
@@ -32,7 +32,7 @@ class Audio2MeshARModel(Base):
init_net(self.netG, init_type='kaiming', gpu_ids=opt.GPUS)
# init last layer
init_exp_weight = np.load("/ssdata1/lsen/CODE/voca/training_data/init_expression_basis.npy")
init_exp_weight = np.load("./data/init_expression_basis.npy")
init_exp_weight = torch.from_numpy(init_exp_weight).float().to(self.device)
init_exp_weight = init_exp_weight[:, :50]
self.netG.module.decoder_mesh.weight.data = init_exp_weight
@@ -227,10 +227,10 @@ class Audio2MeshARModel(Base):
with torch.no_grad():
batch_y_pdf = torch.zeros_like(self.y_tgt) # B x nsteps x 5023 x 3
# batch_y_pdf[:, 0] = self.y_tgt[:, 0] # init first GT as PT
batch_y_pdf[:, 0] = self.template_verts.expand(B, -1, -1, -1) # init first GT as PT
batch_y_pdf[:, 0] = self.template_verts[0] # init first GT as PT, (5023 x 3)
# ibatch_y_pre = self.y_tgt[:, 0] # B x 1 x 5023 x 3
ibatch_y_pre = self.template_verts.expand(B, -1, -1, -1) # B x 1 x 5023 x 3
# ibatch_y_pre = self.y_tgt[:, 0:1] # B x 1 x 5023 x 3
ibatch_y_pre = self.template_verts.expand(B, -1, -1, -1) # B x 1 x 5023 x 3
for istep in range(1, self.nsteps_align):
ibatch_x = self.x[:, istep:istep+1] # B x 1 x nwind x nc_condit
@@ -511,8 +511,12 @@ class Audio2MeshARModel(Base):
# save animation
# print(f"testing v_render_pt = {len(v_render_pt)}, gt shape = {len(v_render_gt)}")
save_animation_with_gt2(v_render_pt, v_render_gt, ipath_save, fps=self.opt.DATASET.fps,\
path_audio=jpath_audio, start_time=jstart_time, end_time=jend_time)
# save_animation_with_gt2(v_render_pt, v_render_gt, ipath_save, fps=self.opt.DATASET.fps, path_audio=jpath_audio, start_time=jstart_time, end_time=jend_time)
# save animation
print(f"testing v_render_pt = {len(v_render_pt)}, gt shape = {len(v_render_gt)}, fps={self.opt.DATASET.fps}")
save_animation_with_gt2(v_render_pt, v_render_gt, ipath_save, fps=self.opt.DATASET.fps, path_audio=jpath_audio, start_time=jstart_time, end_time=jend_time)
#########################################
def tensor2image(tensor):
+1 -1
View File
@@ -32,7 +32,7 @@ class Audio2MeshSpecificModel(Base):
init_net(self.netG, init_type='kaiming', gpu_ids=opt.GPUS)
# init last layer
init_exp_weight = np.load("/ssdata1/lsen/CODE/voca/training_data/init_expression_basis.npy")
init_exp_weight = np.load("./data/init_expression_basis.npy")
init_exp_weight = torch.from_numpy(init_exp_weight).float().to(self.device)
init_exp_weight = init_exp_weight[:, :50]
self.netG.module.decoder_mesh.weight.data = init_exp_weight