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
+523 -42

No files matched your search

@@ -0,0 +1,30 @@
GPUS: '9'
isTrain: False
DEBUG: False
OUTPUT_DIR: 'experiments/audio2mesh'
MODEL:
# name: 'audio2mesh'
name: 'audio2mesh_specific'
name_netG: "audio2mesh"
dim_motion: 53 # 68*2
dim_speech: 1024
num_vertices: 5023
pretrain: True
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_CN_20220314/20220315-18H24M47S"
load_epoch: 10
DATASET:
fps: 50
sr: 16000
name: "motion_live"
path_mean_dict: './data/Actor1/DECA_Actor1_mean.npy'
TRAIN:
apply_testing: True
apply_validation: True
@@ -0,0 +1,83 @@
GPUS: '4'
WORKERS: 4
OUTPUT_DIR: 'experiments/audio2mesh'
DEBUG: False
verbose: False
VISUAL:
use_HTML: False
use_visdom: True
vsdm_port: 9940
vsdm_ncol: 4
vsdm_env: "audio2mesh-ar-actor1-3h-1100"
FREQ:
epoch_save: 5
epoch_valid: 1
batch_print: 20
epoch_test: 5
MODEL:
name: 'audio2mesh_ar'
name_netG: "audio2mesh_ar"
dim_motion: 53 # 68*2
dim_speech: 1024
num_vertices: 5023
pretrain: False
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_CN_20220220/20220225-19H08M53S"
load_epoch: 0
DATASET:
fps: 50
sr: 16000
name: "motion_live"
flip: False
shifting_speed: True
root: './data/Actor1/Actor1-raw-3h' # obama-deca-3-5-08-mini
root_raw: '/yrfs/lsen/DATA/Actor1/processing'
path_mean_dict: './data/Actor1/DECA_Actor1_mean.npy'
filter: 'savgol'
speech_extractor: 'wav2vec'
nwind_second_train: 3
nwind_second_valid: 3
nwind_second_test: 15
TEST:
batch_size: 2
TRAIN:
lr: 0.0001
batch_size: 128
shuffle: True
apply_testing: True
apply_validation: True
optimizer: 'Adam'
momentum: 0.9
beta1: 0.5
beta2: 0.999
weight_decay: 0.0001
nesterov: True
grad_clip_norm: False
# lr_policy: 'multistep'
# lr_milestones: [50, 100]
lr_policy: 'plateau'
resume: False
reset_lr: False
resume_suffix: "20220128-10H10M10S"
epoch_begin: 0 # 5000 # 2300 # 2600
epoch_end: 200
LOSS:
names: ["all", "rec_geo", "rec_geo_w", "vel_geo", "vel_geo_w"]
lambda_rec_geo: 1
lambda_vel_geo: 100
@@ -1,4 +1,4 @@
GPUS: '0'
GPUS: '2'
WORKERS: 4
OUTPUT_DIR: 'experiments/audio2mesh'
@@ -9,15 +9,15 @@ verbose: False
VISUAL:
use_HTML: False
use_visdom: True
vsdm_port: 9930
vsdm_port: 9940
vsdm_ncol: 4
vsdm_env: "audio2mesh-ar-actor2-no-veloctiy"
vsdm_env: "audio2mesh-ar-actor2-5h-110"
FREQ:
epoch_save: 5
epoch_valid: 1
batch_print: 20
epoch_test: 5
epoch_test: 1
MODEL:
name: 'audio2mesh_ar'
@@ -27,9 +27,9 @@ MODEL:
dim_speech: 1024
num_vertices: 5023
pretrain: False
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_CN_20220220/20220225-19H08M53S"
load_epoch: 0
pretrain: True
path_checkpoint: "experiments/audio2mesh/train_audio2meshAR_CN_20220314/20220315-18H15M43S"
load_epoch: 95
DATASET:
@@ -53,7 +53,7 @@ TEST:
batch_size: 2
TRAIN:
lr: 0.0001
lr: 0.00001
batch_size: 128
shuffle: True
@@ -67,9 +67,9 @@ TRAIN:
weight_decay: 0.0001
nesterov: True
grad_clip_norm: False
# lr_policy: 'multistep'
# lr_milestones: [50, 100]
lr_policy: 'plateau'
lr_policy: 'multistep'
lr_milestones: [20, 50]
# lr_policy: 'plateau'
resume: False
reset_lr: False
@@ -81,4 +81,4 @@ TRAIN:
LOSS:
names: ["all", "rec_geo", "rec_geo_w", "vel_geo", "vel_geo_w"]
lambda_rec_geo: 1
lambda_vel_geo: 0
lambda_vel_geo: 10
@@ -5,7 +5,6 @@ OUTPUT_DIR: 'experiments/audio2mesh'
DEBUG: False
verbose: False
VISUAL:
use_HTML: False
use_visdom: True
@@ -0,0 +1,86 @@
GPUS: '6'
WORKERS: 4
OUTPUT_DIR: 'experiments/audio2mesh'
DEBUG: False
verbose: False
VISUAL:
use_HTML: False
use_visdom: True
vsdm_port: 9940
vsdm_ncol: 4
vsdm_env: "audio2mesh-actor1-3h-150-speed"
FREQ:
epoch_save: 5
epoch_valid: 1
batch_print: 20
epoch_test: 5
MODEL:
name: 'audio2mesh'
name_netG: "audio2mesh"
dim_motion: 53 # 68*2
dim_speech: 1024
num_vertices: 5023
pretrain: False
path_checkpoint: "experiments/audio2mesh/train_audio2mesh_CN_20220314/20220315-18H24M47S"
load_epoch: 0
DATASET:
fps: 50
sr: 16000
name: "motion_live"
flip: False
shifting_speed: True
root: './data/Actor1/Actor1-raw-3h' # obama-deca-3-5-08-mini
root_raw: '/yrfs/lsen/DATA/Actor1/processing'
path_mean_dict: './data/Actor1/DECA_Actor1_mean.npy'
filter: 'savgol'
speech_extractor: 'wav2vec'
nwind_second_train: 3
nwind_second_valid: 3
nwind_second_test: 15
TEST:
batch_size: 2
TRAIN:
lr: 0.0001
batch_size: 128
shuffle: True
apply_testing: True
apply_validation: True
optimizer: 'Adam'
momentum: 0.9
beta1: 0.5
beta2: 0.999
weight_decay: 0.0001
nesterov: True
grad_clip_norm: False
# lr_policy: 'multistep'
# lr_milestones: [10, 50]
lr_policy: 'plateau'
resume: False
reset_lr: False
resume_suffix: "20220128-10H10M10S"
epoch_begin: 0 # 5000 # 2300 # 2600
epoch_end: 100
LOSS:
names: ["all", "rec_geo", "rec_geo_w", "vel_geo", "vel_geo_w"]
lambda_rec_geo: 1
lambda_vel_geo: 100
+3 -1
View File
@@ -46,7 +46,9 @@ if __name__ == "__main__":
# path_audio = Path("/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/audio/audio_trim_60_120s.wav")
path_audio = Path("/yrfs/lsen/DATA/Actor2/processing/AA7A9568/audio/audio_trim_120s.wav")
# path_audio = Path("/yrfs/lsen/DATA/Actor2/processing/AA7A9568/audio/audio_trim_120s.wav")
path_audio = Path("/yrfs/lsen/DATA/Actor1/processing/2-23min/audio/audio_trim_120_120s.wav")
# path_audio = Path("./data/test/cut_NVP.wav")
# path_audio = Path("./data/test/cut_LSP.wav")
View File
Whitespace-only changes.
+80
View File
@@ -0,0 +1,80 @@
import numpy as np
from pathlib import Path
if __name__ == "__main__":
# fid = "Bringing-Our-Workplace-Policies-into-the-21st-Century"
fid = "2-23min"
path_root = Path("/yrfs/lsen/DATA/Actor1/processing")
path_data = path_root.joinpath(fid)
path_coeff = path_data.joinpath("DECA_coeff")
vpath_coeff = sorted(path_coeff.glob("*.npy"), reverse=False)
print(f"Have {len(vpath_coeff)} frames")
feat_shape = []
feat_tex = []
feat_cam = []
feat_exp = []
feat_pos = []
feat_light = []
feat_detail = []
for ipath_coeff in vpath_coeff:
data_coeff = np.load(ipath_coeff, allow_pickle=True).item()
# print(data_coeff.keys())
feat_exp.append(data_coeff["exp"])
feat_pos.append(data_coeff["pose"])
feat_tex.append(data_coeff["tex"])
feat_cam.append(data_coeff["cam"])
feat_light.append(data_coeff["light"])
feat_detail.append(data_coeff["detail"])
feat_shape.append(data_coeff["shape"])
# save
feat_exp = np.array(feat_exp) # (nframe_trim, 50)
feat_pos = np.array(feat_pos) # (nframe_trim, 6)
feat_tex = np.array(feat_tex) # (nframe_trim, 50)
feat_cam = np.array(feat_cam) # (nframe_trim, 6)
feat_light = np.array(feat_light) # (nframe_trim, 50)
feat_detail = np.array(feat_detail) # (nframe_trim, 6)
feat_shape = np.array(feat_shape) # (nframe_trim, 50)
mean_exp = feat_exp.mean(axis=0)
mean_pos = feat_pos.mean(axis=0)
mean_tex = feat_tex.mean(axis=0)
mean_cam = feat_cam.mean(axis=0)
mean_light = feat_light.mean(axis=0)
mean_detail = feat_detail.mean(axis=0)
mean_shape = feat_shape.mean(axis=0)
print(f"feat_exp shape = {feat_exp.shape}, mean = {mean_exp.shape}, \n{mean_exp}")
print(f"mean_pos shape = {feat_pos.shape}, mean = {mean_pos.shape}, \n{mean_pos}")
print(f"mean_tex shape = {feat_tex.shape}, mean = {mean_tex.shape}, \n{mean_tex}")
print(f"mean_cam shape = {feat_cam.shape}, mean = {mean_cam.shape}, \n{mean_cam}")
print(f"mean_light shape = {feat_light.shape}, mean = {mean_light.shape}, \n{mean_light}")
print(f"mean_detail shape = {feat_detail.shape}, mean = {mean_detail.shape}, \n{mean_detail}")
print(f"mean_shape shape = {feat_shape.shape}, mean = {mean_shape.shape}, \n{mean_shape}")
# save
mean_DECA = {
"exp": mean_exp, # (50, )
"pose": mean_pos, # (6, )
"tex": mean_tex, # (50, )
"cam": mean_cam, # (3, )
"light": mean_light, # (9, 3)
"detail": mean_detail,# (128, )
"shape": mean_shape, # (100, )
}
path_save = "./data/Actor1/DECA_Actor1_mean.npy"
np.save(path_save, mean_DECA)
print("save to --> ", path_save)
print(f"mean deca = \n {mean_DECA}")
@@ -99,3 +99,4 @@ if __name__ == "__main__":
+15 -9
View File
@@ -5,7 +5,7 @@ import torch
from pathlib import Path
# common
sys.path.insert(0, "/ssdata1/lsen/CODE/Audio2Motion")
sys.path.insert(0, "/ssdata1/lsen/CODE/audio-to-motion")
from common.animation import save_images_with_audio
sys.path.insert(0, "/ssdata1/lsen/CODE/DECA_old")
@@ -25,7 +25,9 @@ def tensor2image(tensor):
if __name__ == "__main__":
# load data
pid = "2022-P01" # "2021-P22", actor-2HD
pid = "2-23min" # "2021-P22", actor-2HD
device = torch.device("cuda:9")
# path_root = Path("/yrfs/lsen/DATA/TestData/processing/")
path_root = Path("/yrfs/lsen/DATA/Actor1/processing")
@@ -34,22 +36,26 @@ if __name__ == "__main__":
path_pos = path_data.joinpath("audio/feat_DECA_pos_trim.npy")
path_idn = path_data.joinpath("audio/feat_DECA_idn_trim.npy")
path_exp = path_data.joinpath("audio/feat_DECA_exp_trim.npy")
path_audio = path_data.joinpath("audio/audio_trim.wav")
# path_audio = path_data.joinpath("audio/audio_trim_60_120s.wav")
# path_audio = path_data.joinpath("audio/audio_trim.wav")
path_audio = path_data.joinpath("audio/audio_trim_120_120s.wav")
data_pos = np.load(path_pos) # N x 6
data_idn = np.load(path_idn) # N x 100
data_exp = np.load(path_exp) # N x 50
# data_pos = np.load(path_pos) # N x 6
# data_idn = np.load(path_idn) # N x 100
# data_exp = np.load(path_exp) # N x 50
data_pos = np.load(path_pos)[6000:6000+6000] # N x 6
data_idn = np.load(path_idn)[6000:6000+6000] # N x 100
data_exp = np.load(path_exp)[6000:6000+6000] # N x 50
N = data_exp.shape[0]
# load mean
path_deca_mean = Path("./data/DECA_LuoXData_mean.npy")
path_deca_mean = Path("./data/Actor1/DECA_Actor1_mean.npy")
mean_dict = np.load(path_deca_mean, allow_pickle=True).item()
print(mean_dict.keys())
# load deca model
device = torch.device("cuda:0")
deca_cfg.model.use_tex = False
deca_cfg.dataset.image_size = 512
netR = DECA(config = deca_cfg, device=device)
@@ -0,0 +1,178 @@
import os
import sys
import json
import librosa
import numpy as np
from pathlib2 import Path
from scipy import interpolate
import torchaudio
def landmark_resample_fps(y, source_fps = 30, target_fps=25):
""" y, N x 136, with 30fps
"""
nsteps = y.shape[0]
x = np.arange(0, nsteps, 1)
# print("x:", x[::30], x[-10:])
func = interpolate.interp1d(x, y=y, axis=0)
x_new = np.arange(0, nsteps-1, 1.0*source_fps/target_fps)
# print("x_new", x_new[::30], x_new[-10:])
y_new = func(x_new)
if source_fps < target_fps:
y_new = np.concatenate([y_new, y[-1:]])
return y_new
if __name__ == "__main__":
path_data = Path("/yrfs/lsen/DATA/Actor1/processing")
path_save = Path('data/Actor1/Actor1-raw-5h') # processing
path_save.mkdir(parents=True, exist_ok=True)
v_dir_videos = sorted(path_data.glob("*/audio/feat_DECA_exp_trim.npy"))
print(f"Have {len(v_dir_videos)} dir files")
v_dir_videos = [ipath.parent.parent for ipath in v_dir_videos]
vids = set([ipath.stem for ipath in v_dir_videos])
# print(f"vids total= {vids}")
vid_test = set(["2-23min"])
vid_valid = set(["2-23min"])
vid_train = vids - vid_test - vid_valid
# vids = set(["2021-P09", "2021-P14", "2021-P22"])
# vid_test = set(["2021-P09" ])
# vid_valid = set(["2021-P14" ])
# vid_train = set(["2021-P22" ])
print(f"vid test= {vid_test} \nvalid= {vid_valid}")
print(f"vid train= {vid_train}")
# for each video
data_train, data_valid, data_test = {}, {}, {}
durations_train, durations_valid, durations_test = 0, 0, 0
for i, ipath_data in enumerate(v_dir_videos):
vid = ipath_data.stem
# if vid not in vids: continue
# if vid in vid_test: continue
# if vid in vid_valid:continue
if durations_train / 3600 > 5: break
print(f"\n processing the {i}-th video {vid} ... ")
ipath_info = ipath_data.joinpath("video/info.json")
ipath_feat_exp = ipath_data.joinpath("audio/feat_DECA_exp_trim.npy")
ipath_feat_pos = ipath_data.joinpath("audio/feat_DECA_pos_trim.npy")
ipath_feat_idn = ipath_data.joinpath("audio/feat_DECA_idn_trim.npy")
ipath_speech = ipath_data.joinpath("audio/audio_trim.wav")
# check existing
if not ipath_speech.exists():
print(f"NOT existing {ipath_speech}")
continue
if not ipath_feat_exp.exists():
print(f"NOT existing {ipath_feat_exp}")
continue
# load video info
with open(str(ipath_info), "r") as f:
info = json.load(f)
fps = info["fps"]
nframes = info['nframes']
print(f"info={info}, duration = {nframes/fps}")
assert fps == 50, "fps should be 50"
# laod motion
data_exp = np.load(ipath_feat_exp) # (nframe, 50)
data_pos = np.load(ipath_feat_pos) # (nframe, 6)
data_idn = np.load(ipath_feat_idn) # (nframe, 100)
assert data_exp.shape[0] == data_pos.shape[0], f"data_exp shape={data_exp.shape}, data_pos shape={data_pos.shape}"
assert data_exp.shape[0] == data_idn.shape[0], f"data_exp shape={data_exp.shape}, data_idn shape={data_idn.shape}"
data_pos_head = data_pos[:, :3] # (nframe, 3)
data_pos_lips = data_pos[:, 3:] # (nframe, 3)
data_motion = np.concatenate([data_exp, data_pos_lips], axis=1) # (nframe, 53) --> fps=30
print(f"motion = {data_motion.shape}")
# load raw audio
audio_raw, sample_rate = torchaudio.load(ipath_speech)
print(f"audio_raw shape = {audio_raw.shape}, sr = {sample_rate}, duration = {(len(audio_raw[0])/sample_rate)}")
if len(audio_raw.shape) == 2:
audio_raw = audio_raw[0]
if sample_rate != 16000:
resampler = torchaudio.transforms.Resample(sample_rate, 16_000)
audio_raw = resampler(audio_raw).squeeze().numpy()
print(f"audio_raw shape = {audio_raw.shape}, sr = {16000}, duration = {(len(audio_raw)/16000)}")
# ####################################
# # clips 4min
# nclip = 4
# nframes = nclip * 60 * 50 # min * 60s * fps
# nsegmts = nclip * 60 * 16000 # min * 60s * sr
# data_motion = data_motion[:nframes]
# audio_raw = audio_raw[:nsegmts]
# data_idn = data_idn[:nframes]
# ####################################
if vid in vid_train:
durations_train += nframes/fps
data_train[vid] = {
"fps": info["fps"],
"sr": 16000,
"nframe": nframes,
"data_motion": data_motion,
"data_speech": audio_raw,
"data_shape": data_idn,
}
if vid in vid_valid:
durations_valid += nframes/fps
data_valid[vid] = {
"fps": info["fps"],
"sr": 16000,
"nframe": nframes,
"data_motion": data_motion,
"data_speech": audio_raw,
"data_shape": data_idn,
}
if vid in vid_test:
durations_test += nframes/fps
data_test[vid] = {
"fps": info["fps"],
"sr": 16000,
"nframe": nframes,
"data_motion": data_motion,
"data_speech": audio_raw,
"data_shape": data_idn,
}
np.savez(path_save.joinpath("data_train.npz"), data=data_train)
np.savez(path_save.joinpath("data_valid.npz"), data=data_valid)
np.savez(path_save.joinpath("data_test.npz"), data=data_test)
print(f"Total frames: data_train ({durations_train / 60 } min) ({durations_train / 3600 } h) , ids = ({len(data_train)})")
print(f"Total frames: data_valid ({durations_valid / 60 } min) ({durations_valid / 3600 } h) , ids = ({len(data_valid)})")
print(f"Total frames: data_test ({durations_test / 60 } min) ({durations_test / 3600 } h) , ids = ({len(data_test)})")
# print(f"Total ids: data_train ({len(data_train)}), data_test ({len(data_test)}) data_valid({len(data_valid)})")
# print(f"Total frames: data_train ({durations_train / 60 } min) ({durations_train / 3600 } h) , data_test ({durations_test / 60 } min) data_valid({durations_valid / 60} min)")
print(f"--> {path_save}")
+12 -8
View File
@@ -9,28 +9,29 @@ if __name__ == "__main__":
fps_save = 50
path_save = "/yrfs/lsen/DATA/TestData/processing/1645666605877506/video/predict_compare_3.mp4"
path_save = "/yrfs/lsen/DATA/Actor1/processing/2-23min/video/predict_compare_2.mp4"
path_clipA = "/yrfs/lsen/DATA/TestData/processing/1645666605877506/video/deca_render.mp4"
path_clipB = "/yrfs/lsen/DATA/TestData/processing/1645666605877506/video/deca_render_no_pos.mp4"
path_clipC = "/yrfs/lsen/DATA/TestData/processing/1645666605877506/video/deca_render_no_pos_no_idn.mp4"
path_clipA = "experiments/audio2mesh/infer_audio2mesh_CN_20220314/20220315-17H39M14S/audio_trim_120_120s_infer_20220315-02H14M18S_epoch_040_002.mp4"
path_clipB = '/yrfs/lsen/DATA/Actor1/processing/2-23min/video/deca_render_no_pos2.mp4'
# path_clipC = "/yrfs/lsen/DATA/TestData/processing/1645666605877506/video/deca_render_no_pos_no_idn.mp4"
# path_clipAA = "experiments/audio2mesh/infer_audio2mesh_EN_20220208/20220223-21H45M05S/audio_trim_60_120s_infer_20220215-15H12M28S_epoch_120_00.mp4"
# path_clipBB = "experiments/audio2mesh/infer_audio2mesh_CN_20220208/20220223-20H51M40S/audio_trim_60_120s_infer_20220222-10H37M51S_epoch_235_00.mp4"
# path_clipCC = "/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/video/deca_render_no_pos_60_120s.mp4"
path_audio = "/yrfs/lsen/DATA/TestData/processing/1645666605877506/audio/audio_trim.wav"
path_audio = "/yrfs/lsen/DATA/Actor1/processing/2-23min/audio/audio_trim_120_120s.wav"
clip_A = mpy.VideoFileClip(path_clipA)
clip_B = mpy.VideoFileClip(path_clipB)
clip_C = mpy.VideoFileClip(path_clipC)
# clip_C = mpy.VideoFileClip(path_clipC)
print(f"clip_A duration = {clip_A.duration}, clip_B duration = {clip_B.duration}")
# clip_AA = mpy.VideoFileClip(path_clipAA)
# clip_BB = mpy.VideoFileClip(path_clipBB)
# clip_CC = mpy.VideoFileClip(path_clipCC)
audio = mpy.AudioFileClip(path_audio)
print(f"audio duration = {audio.duration}")
# txtClip = mpy.TextClip('orignal',color='white', kerning = 5, fontsize=18)
# clip_A = mpy.CompositeVideoClip( [clip_A, txtClip.set_pos('top')], size=(512,512))
@@ -49,9 +50,12 @@ if __name__ == "__main__":
# clip_C = clip_C.set_duration(duration)
audio = audio.set_duration(duration)
# stack
# video = mpy.clips_array([[clip_A, clip_B, clip_C], [clip_AA, clip_BB, clip_CC]]) # clip_C
video = mpy.clips_array([[clip_A, clip_B, clip_C]]) # clip_C
video = mpy.clips_array([[clip_A, clip_B]]) # clip_C
video = video.set_audio(audio) # audd audio
# save
@@ -18,7 +18,7 @@ def main(args):
# device = args.device
device = "cuda:0"
device = "cuda:2"
# run DECA
deca_cfg.model.use_tex = args.useTex
@@ -39,7 +39,7 @@ def main(args):
print(f"\n processing {i}/{len(v_dir_videos)} ...", ivideo_name)
# if ivideo_name not in IDs: continue
if i > 18: break
# if i > 25: break
ipath_infor = ipath_data.joinpath("video/info.json")
ipath_frame = ipath_data.joinpath("frames")
+11 -3
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)
@@ -189,7 +192,6 @@ 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
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
+9 -5
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,9 +227,9 @@ 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.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):
@@ -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