add audio2mesh_ar
This commit is contained in:
1 parent
ded9b27f71
commit
e0f24982d1
46 files changed
+3917
-325
No files matched your search
@@ -6,7 +6,7 @@ from scipy import interpolate
|
||||
|
||||
def convert_fps(y, source_fps = 30, target_fps=25):
|
||||
"""
|
||||
y, N x 136, with 30fps
|
||||
y, nframes x nc_feat (with source_fps)
|
||||
"""
|
||||
|
||||
nsteps = y.shape[0]
|
||||
@@ -27,7 +27,7 @@ def convert_fps(y, source_fps = 30, target_fps=25):
|
||||
if __name__ == "__main__":
|
||||
|
||||
path_data = Path('/yrfs/lsen/DATA/Obama/processing') # '../data/trinity/source'
|
||||
path_save = Path('data/obama-raw-deca-9h-50fps') # processing
|
||||
path_save = Path('data/obama-raw-deca-8h-50fps') # processing
|
||||
path_save.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
v_dir_videos = sorted(path_data.glob("*/audio/feat_DECA_exp_trim.npy"))
|
||||
@@ -38,6 +38,7 @@ if __name__ == "__main__":
|
||||
vid_test = set(vids[:2])
|
||||
vid_valid = set(vids[2:4])
|
||||
vid_train = set(vids) - vid_test - vid_valid
|
||||
|
||||
print("vid_test = ", vid_test)
|
||||
print("vid_valid = ", vid_valid)
|
||||
|
||||
@@ -48,12 +49,15 @@ if __name__ == "__main__":
|
||||
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
|
||||
print(f"\n processing the {i}-th video {vid} ... ")
|
||||
|
||||
ipath_info = ipath_data.joinpath("video/info.json")
|
||||
ipath_exp = ipath_data.joinpath("audio/feat_DECA_exp_trim.npy")
|
||||
ipath_pos = ipath_data.joinpath("audio/feat_DECA_pos_trim.npy")
|
||||
ipath_idn = ipath_data.joinpath("audio/feat_DECA_idn_trim.npy")
|
||||
# ipath_idn = ipath_data.joinpath("audio/feat_DECA_idn_trim.npy")
|
||||
ipath_speech = ipath_data.joinpath("audio/audio_trim.wav")
|
||||
|
||||
if not ipath_speech.exists():
|
||||
@@ -90,7 +94,7 @@ if __name__ == "__main__":
|
||||
# load data
|
||||
feat_exp = np.load(ipath_exp) # (nframe_trim, 50)
|
||||
feat_pos = np.load(ipath_pos) # (nframe_trim, 6)
|
||||
feat_idn = np.load(ipath_idn) # (nframe_trim, 100)
|
||||
# feat_idn = np.load(ipath_idn) # (nframe_trim, 100)
|
||||
|
||||
feat_pos_head = feat_pos[:, :3] # (nframe_trim, 3)
|
||||
feat_pos_lips = feat_pos[:, 3:] # (nframe_trim, 3)
|
||||
@@ -103,10 +107,9 @@ if __name__ == "__main__":
|
||||
# resample to 30fps
|
||||
fps_convert = 50
|
||||
data_motion = convert_fps(data_motion, source_fps=fps, target_fps=fps_convert)
|
||||
data_shape = convert_fps(feat_idn, source_fps=fps, target_fps=fps_convert)
|
||||
# data_shape = convert_fps(feat_idn, source_fps=fps, target_fps=fps_convert)
|
||||
nframe_convert = data_motion.shape[0]
|
||||
assert data_motion.shape[0] == data_shape.shape[0], f"motion = {data_motion.shape[0]} shape = {data_shape.shape[0]}"
|
||||
|
||||
# assert data_motion.shape[0] == data_shape.shape[0], f"motion = {data_motion.shape[0]} shape = {data_shape.shape[0]}"
|
||||
print(f"after convert motion = {data_motion.shape}, duration = {nframe_convert / fps_convert} vs. orignal duration = {nframe_trim / fps}")
|
||||
# print(f"after convert shape = {data_shape.shape}, duration = {nframe_convert / fps_convert} vs. orignal duration = {nframe_trim / fps}")
|
||||
|
||||
@@ -131,38 +134,43 @@ if __name__ == "__main__":
|
||||
"nframe": nframe_convert,
|
||||
"data_motion": data_motion,
|
||||
"data_speech": audio_raw,
|
||||
"data_shape": data_shape,
|
||||
# "data_shape": data_shape,
|
||||
}
|
||||
|
||||
if vid in vid_valid:
|
||||
durations_valid += nframe_trim / fps
|
||||
data_valid[vid] = {
|
||||
"W": width, "H": height,
|
||||
"sr":16000, "FPS": fps_convert,
|
||||
"nframe": nframe_convert,
|
||||
"data_motion": data_motion,
|
||||
"data_speech": audio_raw,
|
||||
"data_shape": data_shape,
|
||||
}
|
||||
if durations_train / 3600 > 8:
|
||||
break
|
||||
|
||||
if vid in vid_test:
|
||||
durations_test += nframe_trim / fps
|
||||
data_test[vid] = {
|
||||
"W": width, "H": height,
|
||||
"sr":16000, "FPS": fps_convert,
|
||||
"nframe": nframe_convert,
|
||||
"data_motion": data_motion,
|
||||
"data_speech": audio_raw,
|
||||
"data_shape": data_shape,
|
||||
}
|
||||
# if vid in vid_valid:
|
||||
# durations_valid += nframe_trim / fps
|
||||
# data_valid[vid] = {
|
||||
# "W": width, "H": height,
|
||||
# "sr":16000, "FPS": fps_convert,
|
||||
# "nframe": nframe_convert,
|
||||
# "data_motion": data_motion,
|
||||
# "data_speech": audio_raw,
|
||||
# # "data_shape": data_shape,
|
||||
# }
|
||||
|
||||
# if vid in vid_test:
|
||||
# durations_test += nframe_trim / fps
|
||||
# data_test[vid] = {
|
||||
# "W": width, "H": height,
|
||||
# "sr":16000, "FPS": fps_convert,
|
||||
# "nframe": nframe_convert,
|
||||
# "data_motion": data_motion,
|
||||
# "data_speech": audio_raw,
|
||||
# # "data_shape": data_shape,
|
||||
# }
|
||||
|
||||
|
||||
|
||||
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)
|
||||
# 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 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) , ids = ({len(data_train)})")
|
||||
|
||||
# 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"--> {path_save}")
|
||||
Reference in new issue
Block a user