add audio2mesh model support
This commit is contained in:
1 parent
5eb304186a
commit
386df9a4ab
83 files changed
+9318
-1307
No files matched your search
@@ -0,0 +1,166 @@
|
||||
import numpy as np
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# fid = "Bringing-Our-Workplace-Policies-into-the-21st-Century"
|
||||
fid = "2021-P09"
|
||||
path_root = Path("/yrfs/lsen/DATA/LuoXData/processing2/")
|
||||
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/DECA_LuoXData_mean.npy"
|
||||
np.save(path_save, mean_DECA)
|
||||
print("save to --> ", path_save)
|
||||
|
||||
# Have 21499 frames
|
||||
# feat_exp shape = (21499, 50), mean = (50,),
|
||||
# [ 0.44338268 0.4472932 0.3063721 0.7504411 -0.4381568 -0.17690322
|
||||
# -0.05219001 -0.57315934 0.18184426 0.9165148 -0.59275323 0.56516534
|
||||
# -0.07709685 0.329883 0.3242076 -0.3435903 -0.6763506 -0.4351912
|
||||
# -0.04082069 0.8187175 0.03223863 -0.5716034 0.54998404 0.0491897
|
||||
# -0.1993383 0.09097239 -0.00910581 0.22115254 -0.16818044 -0.29952174
|
||||
# 0.09535432 -0.33055896 0.28673303 -0.25529468 0.19485517 -0.00993109
|
||||
# 0.07266268 -0.13707523 0.1642315 -0.05313531 -0.22445893 -0.09244996
|
||||
# -0.01606068 -0.01136032 -0.18826558 0.17590263 -0.04148029 0.15630233
|
||||
# -0.04461758 0.03858361]
|
||||
# mean_pos shape = (21499, 6), mean = (6,),
|
||||
# [ 0.25185004 0.06190158 -0.04912106 0.0478017 0.00894242 0.03168569]
|
||||
# mean_tex shape = (21499, 50), mean = (50,),
|
||||
# [-0.3978834 -0.42889112 -0.16672912 -0.0809032 -0.0311112 0.10049947
|
||||
# 0.33035028 -0.41055256 -0.11721741 -0.07116426 -0.04352681 0.308682
|
||||
# 0.25109372 -0.21540923 -0.03529367 0.1724729 0.23672035 0.24651733
|
||||
# 0.09847663 0.00665621 0.0794858 -0.06461164 0.01242481 0.052638
|
||||
# -0.03111307 -0.00460155 0.14652304 0.01369311 -0.1782642 0.10161535
|
||||
# -0.00404513 -0.08375361 0.12226686 0.08011193 -0.14495994 0.05208473
|
||||
# -0.13073783 0.14158903 -0.00310591 -0.13385871 -0.12640713 0.04086212
|
||||
# 0.12389808 -0.00319803 0.08630313 0.02669481 -0.04975258 0.06850675
|
||||
# 0.0145871 -0.03593108]
|
||||
# mean_cam shape = (21499, 3), mean = (3,),
|
||||
# [ 9.70313 -0.00973762 0.05297631]
|
||||
# mean_light shape = (21499, 9, 3), mean = (9, 3),
|
||||
# [[ 3.668586 3.6666408 3.6884367 ]
|
||||
# [-0.02417332 -0.01953881 -0.02340931]
|
||||
# [ 0.13705754 0.14098997 0.1339419 ]
|
||||
# [-0.3177393 -0.33407646 -0.27969545]
|
||||
# [ 0.03982113 0.03903044 0.03949506]
|
||||
# [ 0.00550121 0.0090305 0.00659682]
|
||||
# [-0.0473443 -0.0428174 -0.04730038]
|
||||
# [ 0.2589516 0.25872716 0.2667857 ]
|
||||
# [ 0.3665497 0.3590046 0.37101206]]
|
||||
# mean_detail shape = (21499, 128), mean = (128,),
|
||||
# [ 3.61521721e-01 6.14889897e-02 -9.27711353e-02 -4.99111451e-02
|
||||
# 9.35071558e-02 -4.14181035e-03 8.36418290e-03 1.42222671e-02
|
||||
# -6.43310547e-02 6.34927675e-02 -4.77789193e-02 -6.49932697e-02
|
||||
# -1.25051411e-02 -1.42840430e-01 -2.68053383e-01 -4.33399342e-02
|
||||
# 5.79991080e-02 -6.73886761e-02 -1.68433964e-01 3.68494689e-02
|
||||
# -1.16020657e-01 1.02660023e-01 5.25341071e-02 -8.19350109e-02
|
||||
# -1.01520777e-01 1.95464730e-01 -3.04076709e-02 -4.90539931e-02
|
||||
# -3.66580971e-02 -6.70471564e-02 3.78390849e-01 -5.20394333e-02
|
||||
# -4.54101205e-01 4.37255716e-03 5.44623472e-02 8.57212916e-02
|
||||
# 1.58119053e-01 -1.92813739e-01 9.49373189e-03 1.81852393e-02
|
||||
# 5.11284471e-02 1.03188865e-02 -7.73664191e-02 -2.01583542e-02
|
||||
# 5.95133752e-02 -7.51507431e-02 -9.99203101e-02 7.36503676e-02
|
||||
# 1.58722445e-01 6.02622665e-02 -3.20148505e-02 -4.51608598e-02
|
||||
# -8.57862309e-02 -7.13788047e-02 1.60456672e-02 1.00568458e-01
|
||||
# -2.49848496e-02 -9.89784896e-02 -3.26840989e-02 -3.01793907e-02
|
||||
# -6.15731366e-02 4.05075662e-02 6.88920915e-02 -1.12864830e-01
|
||||
# 2.88244411e-02 -9.44222510e-02 1.49918213e-01 -5.53867444e-02
|
||||
# -4.31086451e-01 3.11203804e-02 4.79492359e-02 -5.20009361e-02
|
||||
# 3.43780033e-02 2.66235732e-02 3.38539705e-02 -3.00715804e-01
|
||||
# -1.81968529e-02 -3.17425169e-02 1.62658636e-02 1.21782655e-02
|
||||
# -2.83036269e-02 1.15976281e-01 7.14496151e-02 4.37062651e-01
|
||||
# 4.90688123e-02 2.40370128e-02 -5.72391078e-02 -6.25709668e-02
|
||||
# 7.10044131e-02 -1.65119901e-01 -2.34024543e-02 -2.69950107e-02
|
||||
# 6.52964264e-02 2.17279568e-01 -8.76158103e-02 -9.41120610e-02
|
||||
# 2.69935168e-02 -7.41094574e-02 1.83443710e-01 -7.56433010e-02
|
||||
# 1.50024280e-01 3.49961817e-01 1.26819417e-01 2.67323870e-02
|
||||
# -2.79632300e-01 -4.44744639e-02 1.91484280e-02 -2.59159375e-02
|
||||
# 5.70407100e-02 -2.09884532e-02 -2.51313988e-02 -3.76658551e-02
|
||||
# 1.85259376e-02 -9.42206103e-03 7.46866986e-02 2.46279147e-02
|
||||
# -9.56854001e-02 6.84051365e-02 4.84354645e-01 4.01193229e-03
|
||||
# -2.31952056e-01 4.11941558e-02 -4.09149914e-04 5.58872700e-01
|
||||
# 3.48035753e-01 2.20942989e-01 -1.54582923e-02 5.18014990e-02]
|
||||
# mean_shape shape = (21499, 100), mean = (100,),
|
||||
# [-0.32458988 0.17692271 -0.59014773 -0.0735845 0.16357006 -0.35708523
|
||||
# 0.06076029 0.07674006 -0.21280588 -0.28636473 0.05864865 0.04630899
|
||||
# -0.00805237 -0.07572373 -0.01006004 -0.02728044 -0.03204667 0.05797856
|
||||
# -0.0428825 -0.3848283 0.39713535 0.0483583 0.19617037 0.14579436
|
||||
# 0.09192853 -0.09590823 -0.05430005 -0.15612626 0.13853826 -0.09018957
|
||||
# 0.03631187 0.05067807 -0.05036244 -0.00284541 -0.1159773 -0.08631504
|
||||
# -0.1413492 -0.01819041 -0.08816721 0.03550155 -0.11542681 0.15759806
|
||||
# 0.00542928 0.01032758 0.11571501 -0.1593183 0.05542826 -0.05267807
|
||||
# -0.35371011 -0.0929389 0.17742656 -0.38268778 0.0423925 -0.22057873
|
||||
# 0.05460614 -0.08430341 0.08110942 0.00884286 0.12435686 -0.00792618
|
||||
# -0.02667568 -0.18690723 -0.06518848 0.06365784 -0.03344199 -0.07648047
|
||||
# 0.01697154 -0.13141611 -0.01001224 0.00656717 -0.04314337 -0.181731
|
||||
# 0.0684299 -0.08775398 -0.06183273 -0.04920578 -0.10702839 0.01475282
|
||||
# 0.1069483 -0.01643799 0.00402089 -0.01572194 0.16098669 0.07922536
|
||||
# -0.01868843 0.02041192 -0.09030195 -0.03367294 0.01796311 -0.02930326
|
||||
# 0.10064717 -0.01723173 0.01651016 0.01912417 -0.00323546 -0.00704829
|
||||
# 0.0334241 -0.02697726 0.01572118 0.04431901]
|
||||
# save to --> ./data/DECA_LuoXData_mean.npy
|
||||
|
||||
@@ -11,13 +11,14 @@ if __name__ == '__main__':
|
||||
vpath_videos = sorted(path_root.glob("raw/*.mp4"), reverse=False)
|
||||
print(f"Have {len(vpath_videos)} dir files")
|
||||
|
||||
IDs = ["2021-P29"]
|
||||
# for each video
|
||||
for i, ipath_item in enumerate(vpath_videos):
|
||||
iname = ipath_item.stem
|
||||
print(f"processing {i}/{len(vpath_videos)} -> {ipath_item} ... ")
|
||||
|
||||
# if i < 40: continue
|
||||
# if iname not in IDs: continue
|
||||
if iname not in IDs: continue
|
||||
|
||||
# data path
|
||||
ipath_data = path_root.joinpath("processing2", ipath_item.stem)
|
||||
@@ -55,10 +56,10 @@ if __name__ == '__main__':
|
||||
nframes = int(video_sub.duration * video_sub.fps)
|
||||
|
||||
# check frames
|
||||
nframe_real = len(list(ipath_frame.glob("*.jpg")))
|
||||
if nframe_real == nframes:
|
||||
print(f"\n Skip: have already done!")
|
||||
continue
|
||||
# nframe_real = len(list(ipath_frame.glob("*.jpg")))
|
||||
# if nframe_real == nframes:
|
||||
# print(f"\n Skip: have already done!")
|
||||
# continue
|
||||
|
||||
# check fps
|
||||
if int(video_sub.fps) != 50:
|
||||
@@ -94,7 +95,7 @@ if __name__ == '__main__':
|
||||
audio_sub.write_audiofile(str(ipath_audio_sub), fps=audio_sub.fps)
|
||||
print(f"save audio > {ipath_audio_sub}")
|
||||
|
||||
# save trim video
|
||||
print(f"write_images_sequence...")
|
||||
ipath_format = str(ipath_frame) + "/frame-%06d.jpg"
|
||||
video_sub.write_images_sequence(ipath_format, fps=50)
|
||||
# # save trim video
|
||||
# print(f"write_images_sequence...")
|
||||
# ipath_format = str(ipath_frame) + "/frame-%06d.jpg"
|
||||
# video_sub.write_images_sequence(ipath_format, fps=50)
|
||||
@@ -26,7 +26,7 @@ def main(args):
|
||||
print(f"Have {len(v_dir_videos)} dir files")
|
||||
|
||||
# for each video
|
||||
for ipath_data in v_dir_videos[17:]:
|
||||
for ipath_data in v_dir_videos[18:]:
|
||||
ivideo_name = ipath_data.stem
|
||||
print("\nprocessing ...", ivideo_name)
|
||||
|
||||
@@ -58,7 +58,6 @@ def main(args):
|
||||
print(f"\n ERROR: nframe_real ={nframe_real} / nframe_info ={nframes}")
|
||||
continue
|
||||
|
||||
|
||||
# check if finish
|
||||
nkpt2d = len(list(ipath_kpt2d.glob("*.txt")))
|
||||
if nkpt2d + 10 > nframes:
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
import torch
|
||||
from pathlib import Path
|
||||
|
||||
# common
|
||||
sys.path.insert(0, "/ssdata1/lsen/CODE/Audio2Motion")
|
||||
from common.animation import save_images_with_audio
|
||||
|
||||
sys.path.insert(0, "/ssdata1/lsen/CODE/DECA_old")
|
||||
from decalib.deca import DECA
|
||||
from decalib.utils import util
|
||||
from decalib.utils.config import cfg as deca_cfg
|
||||
|
||||
def tensor2image(tensor):
|
||||
image = tensor.detach().cpu().numpy()
|
||||
image = image*255.
|
||||
image = np.maximum(np.minimum(image, 255), 0)
|
||||
image = image.transpose(1,2,0)[:,:,[2,1,0]]
|
||||
return image.astype(np.uint8).copy()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# load data
|
||||
pid = "2021-P09" # "2021-P22"
|
||||
path_root = Path("/yrfs/lsen/DATA/LuoXData/processing2/")
|
||||
path_data = path_root.joinpath(pid)
|
||||
|
||||
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")
|
||||
|
||||
data_pos = np.load(path_pos)[3000:6000] # N x 6
|
||||
data_idn = np.load(path_idn)[3000:6000] # N x 100
|
||||
data_exp = np.load(path_exp)[3000:6000] # N x 50
|
||||
N = data_exp.shape[0]
|
||||
|
||||
|
||||
# load mean
|
||||
path_deca_mean = Path("./data/DECA_LuoXData_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)
|
||||
|
||||
# render
|
||||
path_save = path_data.joinpath("video/deca_render_no_pos_60_120s.mp4")
|
||||
v_render_pt = []
|
||||
nbatch_render = 10
|
||||
for k in range(0, N, nbatch_render):
|
||||
codedict = {}
|
||||
|
||||
codedict["exp"] = data_exp[k:k+nbatch_render, :50] # (nbatch_render, 50)
|
||||
|
||||
nbatch_real = codedict["exp"].shape[0]
|
||||
|
||||
codedict["pose"] = np.zeros((nbatch_real, 6)) # (nbatch_render, 6)
|
||||
codedict["pose"][:, 3:6] = data_pos[k:k+nbatch_render, 3:6]
|
||||
# codedict["pose"] = data_pos[k:k+nbatch_render, :] # (nbatch_render, 6)
|
||||
|
||||
# codedict["shape"] = np.zeros((nbatch_real, 100)) # (nabtch_render, 100)
|
||||
codedict["shape"] = data_idn[k:k+nbatch_render, :] # (nabatch_render, 100)
|
||||
|
||||
# others ==> to mean
|
||||
mean_cam = [[5,0,0]] # or [self.mean_dict["cam"]]
|
||||
codedict["cam"] = np.repeat(mean_cam, nbatch_real, axis=0) # (nbatch_render, 3)
|
||||
codedict["light"] = np.repeat([mean_dict["light"]], nbatch_real, axis=0) # (nbatch_render, 9, 3)
|
||||
# codedict["shape"] = np.repeat([mean_dict["shape"]], nbatch_real, axis=0) # (nbatch_render, 100)
|
||||
codedict["detail"] = np.repeat([mean_dict["detail"]], nbatch_real, axis=0) # (nbatch_render, 128)
|
||||
|
||||
|
||||
_, visdict_pt = netR.decode_one(codedict, nbatch_real, device)
|
||||
render_pt = visdict_pt["shape_images"] # (nbatch_render, 3, 224, 224)
|
||||
# print(f"render pt shape = {render_pt.shape}")
|
||||
|
||||
for m in range(nbatch_real):
|
||||
# cv2.imwrite(str(kpath_image), util.tensor2image(render_image[m, ...]))
|
||||
v_render_pt.append(tensor2image(render_pt[m, ...]))
|
||||
|
||||
|
||||
|
||||
save_images_with_audio(v_render_pt, path_audio, path_save)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+41
-19
@@ -9,7 +9,7 @@ from scipy import interpolate
|
||||
import torchaudio
|
||||
|
||||
def landmark_resample_fps(y, source_fps = 30, target_fps=25):
|
||||
"""y, N x 136, with 30fps
|
||||
""" y, N x 136, with 30fps
|
||||
"""
|
||||
|
||||
nsteps = y.shape[0]
|
||||
@@ -27,12 +27,11 @@ def landmark_resample_fps(y, source_fps = 30, target_fps=25):
|
||||
return y_new
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
path_data = Path('/yrfs/lsen/DATA/LuoXData/processing2') # '../data/trinity/source'
|
||||
|
||||
path_save = Path('data/LuoXData-raw-deca-8h') # processing
|
||||
path_save = Path('data/LuoXData-raw-deca-3min') # processing
|
||||
path_save.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
v_dir_videos = sorted(path_data.glob("*"), reverse=False)
|
||||
@@ -43,26 +42,33 @@ if __name__ == "__main__":
|
||||
|
||||
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}")
|
||||
# print(f"vids total= {vids}")
|
||||
|
||||
# vid_test = set(["2021-P09", "2021-P22"])
|
||||
# vid_valid = set(["2021-P14", "2021-P20"])
|
||||
# vid_train = vids - vid_test - vid_test
|
||||
|
||||
vids = set(["2021-P09", "2021-P14", "2021-P22"])
|
||||
vid_test = set(["2021-P09" ])
|
||||
vid_valid = set(["2021-P14" ])
|
||||
vid_train = set(["2021-P22" ])
|
||||
|
||||
vid_test = set(["2021-P09"])
|
||||
vid_valid = set(["2021-P14"]) #set(["2021-P14"])
|
||||
# vid_train = set(['2021-P01', '2021-P02', '2021-P'])
|
||||
vid_train = vids - vid_test - vid_test
|
||||
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
|
||||
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
|
||||
@@ -84,12 +90,16 @@ if __name__ == "__main__":
|
||||
|
||||
|
||||
# laod motion
|
||||
data_exp = np.load(ipath_feat_exp) # (nframe, 50)
|
||||
data_pos = np.load(ipath_feat_pos) # (nframe, 6)
|
||||
pos_head = data_pos[:, :3] # (nframe, 3)
|
||||
pos_lips = data_pos[:, 3:] # (nframe, 3)
|
||||
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)
|
||||
|
||||
data_motion = np.concatenate([data_exp, pos_lips], axis=1) # (nframe, 53) --> fps=30
|
||||
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}")
|
||||
|
||||
|
||||
@@ -105,6 +115,16 @@ if __name__ == "__main__":
|
||||
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
|
||||
@@ -114,7 +134,8 @@ if __name__ == "__main__":
|
||||
"sr": 16000,
|
||||
"nframe": nframes,
|
||||
"data_motion": data_motion,
|
||||
"data_speech": audio_raw
|
||||
"data_speech": audio_raw,
|
||||
"data_shape": data_idn,
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +147,8 @@ if __name__ == "__main__":
|
||||
"sr": 16000,
|
||||
"nframe": nframes,
|
||||
"data_motion": data_motion,
|
||||
"data_speech": audio_raw
|
||||
"data_speech": audio_raw,
|
||||
"data_shape": data_idn,
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +160,8 @@ if __name__ == "__main__":
|
||||
"sr": 16000,
|
||||
"nframe": nframes,
|
||||
"data_motion": data_motion,
|
||||
"data_speech": audio_raw
|
||||
"data_speech": audio_raw,
|
||||
"data_shape": data_idn,
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +170,6 @@ if __name__ == "__main__":
|
||||
np.savez(path_save.joinpath("data_test.npz"), data=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 / 3600} h), data_test ({durations_test / 60 } min) data_valid({durations_valid / 60} min)")
|
||||
|
||||
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}")
|
||||
Reference in new issue
Block a user