initial commit
This commit is contained in:
commit
c7175dd7ff
127 files changed
+13949
No files matched your search
@@ -0,0 +1,89 @@
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import joblib as jl
|
||||
import numpy as np
|
||||
from pathlib2 import Path
|
||||
from sklearn.preprocessing import StandardScaler
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
path_data = Path('/mnt/data2/DATA/Obama/processing') # '../data/trinity/source'
|
||||
path_save = Path('data/obama-landmark-split-6') # processing
|
||||
path_save.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
v_dir_videos = sorted(path_data.glob("*/audio/feat_ldmk_trim_norm.npy"))
|
||||
print(f"Have {len(v_dir_videos)} dir files")
|
||||
|
||||
v_dir_videos = [ipath.parent.parent for ipath in v_dir_videos]
|
||||
vids = [ipath.stem for ipath in v_dir_videos]
|
||||
|
||||
nv_total = len(v_dir_videos)
|
||||
nv_valid, nv_test = 2, 2
|
||||
nv_train = nv_total - (nv_valid + nv_test)
|
||||
|
||||
vid_test = vids[:nv_test]
|
||||
vid_valid = vids[nv_test:nv_test+nv_valid]
|
||||
vid_train = vids[nv_test+nv_valid:]
|
||||
print("vid_test = ", vid_test)
|
||||
|
||||
# for each video
|
||||
motion_train, motion_valid, motion_test = [], [], []
|
||||
speech_train, speech_valid, speech_test = [], [], []
|
||||
|
||||
for i, ipath_data in enumerate(v_dir_videos):
|
||||
vid = ipath_data.stem
|
||||
|
||||
if vid not in vid_test: continue
|
||||
|
||||
|
||||
if i % 50 == 0:
|
||||
print(f"\n processing the {i}-th video {vid} ... ")
|
||||
|
||||
|
||||
ipath_feat_motion = ipath_data.joinpath("audio/feat_ldmk_trim_norm_split_6s.npy") # feat_ldmk_trim_norm_split
|
||||
ipath_feat_speech = ipath_data.joinpath("audio/feat_mel_trim_split_6s.npy") # feat_ldmk_trim_norm_split
|
||||
|
||||
data_motion = np.load(ipath_feat_motion) # (nsplit, 173, 80)
|
||||
data_speech = np.load(ipath_feat_speech) # (nsplit, 60, 136)
|
||||
print(f"motion data = {data_motion.shape}, speech data = {data_speech.shape}")
|
||||
assert data_motion.shape[0] == data_speech.shape[0]
|
||||
|
||||
|
||||
if vid in vid_train:
|
||||
motion_train.append(data_motion)
|
||||
speech_train.append(data_speech)
|
||||
|
||||
elif vid in vid_valid:
|
||||
motion_valid.append(data_motion)
|
||||
speech_valid.append(data_speech)
|
||||
|
||||
else:
|
||||
motion_test.append(data_motion)
|
||||
speech_test.append(data_speech)
|
||||
|
||||
|
||||
# # save
|
||||
# motion_train = np.concatenate(motion_train, axis=0) # (10612, 60, 136)
|
||||
# speech_train = np.concatenate(speech_train, axis=0) # (10612, 173, 80)
|
||||
# np.savez(path_save.joinpath("motion_train.npz"), data=motion_train)
|
||||
# np.savez(path_save.joinpath("speech_train.npz"), data=speech_train)
|
||||
|
||||
# print(f"save train data motion({motion_train.shape}), speech ({speech_train.shape}) -> {path_save}")
|
||||
|
||||
|
||||
# motion_valid = np.concatenate(motion_valid, axis=0) # (350, 60, 136)
|
||||
# speech_valid = np.concatenate(speech_valid, axis=0) # (350, 173, 80)
|
||||
# np.savez(path_save.joinpath("motion_valid.npz"), data=motion_valid)
|
||||
# np.savez(path_save.joinpath("speech_valid.npz"), data=speech_valid)
|
||||
|
||||
# print(f"save valid data motion({motion_valid.shape}), speech({speech_valid.shape}) -> {path_save}")
|
||||
|
||||
|
||||
motion_test = np.concatenate(motion_test, axis=0) # (41, 60, 136)
|
||||
speech_test = np.concatenate(speech_test, axis=0) # (41, 173, 80)
|
||||
np.savez(path_save.joinpath("motion_test.npz"), data=motion_test)
|
||||
np.savez(path_save.joinpath("speech_test.npz"), data=speech_test)
|
||||
|
||||
print(f"save test data motion({motion_test.shape}), speech({speech_test.shape}) -> {path_save}")
|
||||
Reference in new issue
Block a user