initial commit
This commit is contained in:
commit
c7175dd7ff
127 files changed
+13949
No files matched your search
@@ -0,0 +1,82 @@
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
import numpy as np
|
||||
from pathlib2 import Path
|
||||
|
||||
import sys
|
||||
sys.path.insert(0, "/ssdata1/lsen/CODE/Audio2Expression")
|
||||
from common.landmark import landmark_normalize
|
||||
# from common.animation import save_animation, save_animation_with_gt
|
||||
|
||||
total_pid = ["s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10" ]
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
path_data = Path('/yrfs/lsen/DATA/GRID/processing')
|
||||
|
||||
v_ids = sorted(path_data.glob("*"), reverse=True)
|
||||
print(f"Have {len(v_ids)} dir files, \n {v_ids[:3]}")
|
||||
|
||||
# for each speaker
|
||||
for i, ipath_id in enumerate(v_ids):
|
||||
id_name = ipath_id.stem
|
||||
|
||||
if id_name not in total_pid: continue
|
||||
|
||||
dir_video = path_data.joinpath(id_name)
|
||||
v_dir_videos = sorted(dir_video.glob("*/video/video_orignal.mp4"))
|
||||
|
||||
print(f"\nid= {id_name}, Have {len(v_dir_videos)} video files, \n {v_dir_videos[:10]}")
|
||||
|
||||
|
||||
# for each video
|
||||
for iv, ipath_video in enumerate(v_dir_videos):
|
||||
|
||||
ipath_data = ipath_video.parent.parent
|
||||
|
||||
ipath_ldmk = ipath_data.joinpath("landmk-PFLD")
|
||||
ipath_save_feat = ipath_data.joinpath("audio/feat_ldmk_trim_norm.npy")
|
||||
|
||||
if ipath_save_feat.exists():
|
||||
continue
|
||||
|
||||
# load landmark
|
||||
feat_ldmk = []
|
||||
prev_ldmk = None
|
||||
nContinue = 0
|
||||
for j in range(75):
|
||||
jpath_ldmk = ipath_ldmk.joinpath(f"frame-{j:04d}.txt")
|
||||
|
||||
if not jpath_ldmk.exists():
|
||||
print("ERROR: Missing the landmark of frame --> ", jpath_ldmk)
|
||||
if nContinue <= 2:
|
||||
data_ldmk = prev_ldmk
|
||||
nContinue += 1
|
||||
else:
|
||||
nContinue += 1
|
||||
break
|
||||
|
||||
else:
|
||||
data_ldmk = np.loadtxt(jpath_ldmk).astype(np.float)
|
||||
data_ldmk, _, _ = landmark_normalize(data_ldmk) # normalize
|
||||
|
||||
prev_ldmk = data_ldmk
|
||||
nContinue = 0
|
||||
|
||||
feat_ldmk.append(data_ldmk)
|
||||
|
||||
# save
|
||||
feat_ldmk = np.array(feat_ldmk) # (N, 68, 2)
|
||||
|
||||
if nContinue <= 2 and feat_ldmk.shape[0] == 75:
|
||||
np.save(ipath_save_feat, feat_ldmk)
|
||||
print(f"feat shape = {feat_ldmk.shape}, save to -> {ipath_save_feat}") # (nframe, 68, 2)
|
||||
# save to animation
|
||||
else:
|
||||
print(f"ERROR: some landmark missing or length not same, length = {feat_ldmk.shape}")
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user