add audio2mesh_ar

This commit is contained in:
Sen Liang committed 2022-03-14 18:13:13 +08:00
1 parent ded9b27f71
commit e0f24982d1
46 files changed
+3917 -325

No files matched your search

@@ -31,12 +31,9 @@ if __name__ == "__main__":
path_data = Path('/yrfs/lsen/DATA/LuoXData/processing2') # '../data/trinity/source'
path_save = Path('data/LuoXData-raw-deca-3min') # processing
path_save = Path('data/LuoXData-raw-16h') # processing
path_save.mkdir(parents=True, exist_ok=True)
v_dir_videos = sorted(path_data.glob("*"), reverse=False)
print(f"Have {len(v_dir_videos)} dir files, \n {v_dir_videos[:3]}")
v_dir_videos = sorted(path_data.glob("*/audio/feat_DECA_exp_trim.npy"))
print(f"Have {len(v_dir_videos)} dir files")
@@ -44,14 +41,14 @@ if __name__ == "__main__":
vids = set([ipath.stem for ipath in v_dir_videos])
# 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
vid_test = set(["2021-P09", "2021-P22"])
vid_valid = set(["2021-P14", "2021-P20"])
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" ])
# 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}")
@@ -63,6 +60,9 @@ if __name__ == "__main__":
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")
@@ -70,6 +70,7 @@ if __name__ == "__main__":
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")
ipath_idx = ipath_data.joinpath("audio/idx_w150_20220228-18H41M46S_175.npy")
# check existing
if not ipath_speech.exists():
@@ -93,6 +94,7 @@ if __name__ == "__main__":
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_idx = np.load(ipath_idx, allow_pickle=True).tolist() # (nframe_for_sampling, ), set
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}"
@@ -115,17 +117,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]
####################################
# ####################################
# # 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
@@ -136,40 +137,49 @@ if __name__ == "__main__":
"data_motion": data_motion,
"data_speech": audio_raw,
"data_shape": data_idn,
"idx_sampling": data_idx,
}
if durations_train / 3600 > 16:
break
if vid in vid_valid:
durations_valid += nframes/fps
# 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,
}
# data_valid[vid] = {
# "fps": info["fps"],
# "sr": 16000,
# "nframe": nframes,
# "data_motion": data_motion,
# "data_speech": audio_raw,
# "data_shape": data_idn,
# "idx_sampling": data_idx,
# }
if vid in vid_test:
durations_test += nframes/fps
# 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,
# "idx_sampling": data_idx,
# }
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)
# 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 / 60 } min) ({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 / 60 } min) ({durations_train / 3600 } h) , data_test ({durations_test / 60 } min) data_valid({durations_valid / 60} min)")
print(f"--> {path_save}")