update actor5 & actor6 data processing code
This commit is contained in:
1 parent
2095b48c56
commit
922a98e36b
29 files changed
+3694
-94
No files matched your search
@@ -5,30 +5,39 @@ import librosa
|
||||
import numpy as np
|
||||
from pathlib import Path
|
||||
|
||||
import os, sys
|
||||
sys.path.insert(0, os.getcwd())
|
||||
from common.logger import Logger
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
path_data = Path("/ssdata1/lsen/DATA/Actor5/processing")
|
||||
|
||||
actor = "Actor5"
|
||||
sub_folder = "processing" # smile, processing, processing2
|
||||
|
||||
# logger
|
||||
logger = Logger(f"./data/{actor}", postfix=f"feature-3dmm-{sub_folder}")
|
||||
|
||||
# path data
|
||||
path_data = Path(f"/ssdata1/lsen/DATA/{actor}/{sub_folder}")
|
||||
v_dir_videos = sorted(path_data.glob("*"), reverse=False)
|
||||
print(f"Have {len(v_dir_videos)} dir files")
|
||||
logger.info(f"Have {len(v_dir_videos)} dir files")
|
||||
|
||||
# for each video
|
||||
duration_frame, duration_coeff = 0, 0
|
||||
for ipath_data in v_dir_videos:
|
||||
ivideo_name = ipath_data.stem
|
||||
|
||||
print(f"\n processing {ivideo_name} ... ")
|
||||
logger.info(f"\n processing {ivideo_name} ... ")
|
||||
ipath_infors = ipath_data.joinpath("video/info.json")
|
||||
ipath_coeff = ipath_data.joinpath("DECA_coeff")
|
||||
# ipath_coeff = ipath_data.joinpath("DECA_coeff")
|
||||
ipath_coeff = ipath_data.joinpath("deca_coeff_512")
|
||||
ipath_frame = ipath_data.joinpath("frames")
|
||||
ipath_save_exp = ipath_data.joinpath("audio/feat_DECA_exp_trim.npy")
|
||||
ipath_save_pos = ipath_data.joinpath("audio/feat_DECA_pos_trim.npy")
|
||||
ipath_save_idn = ipath_data.joinpath("audio/feat_DECA_idn_trim.npy")
|
||||
|
||||
if ipath_save_exp.exists() and ipath_save_pos.exists():
|
||||
print(f"ipath_save_exp have already save > {ipath_save_exp}")
|
||||
continue
|
||||
|
||||
if not ipath_infors.exists():
|
||||
continue
|
||||
|
||||
@@ -38,28 +47,28 @@ if __name__ == "__main__":
|
||||
fps = info["fps"]
|
||||
nframes = info["nframes"]
|
||||
|
||||
print(f"info = {info}, duration ={nframes / fps / 60}")
|
||||
logger.info(f"info = {info}, duration ={nframes / fps / 60}")
|
||||
|
||||
# check
|
||||
vframe_frame = list(ipath_frame.glob("*.jpg"))
|
||||
vframe_coeff = list(ipath_coeff.glob("*.npy"))
|
||||
print(f"vframe_frame len = {len(vframe_frame)}, vframe_coeff={len(vframe_coeff)}")
|
||||
logger.info(f"vframe_frame len = {len(vframe_frame)}, vframe_coeff={len(vframe_coeff)}")
|
||||
|
||||
duration_frame += len(vframe_frame) / 50 / 60
|
||||
duration_coeff += len(vframe_coeff) / 50 / 60
|
||||
print(f"add duration_frame = {duration_frame} min, duration_coeff={duration_coeff} min")
|
||||
logger.info(f"add duration_frame = {duration_frame} min, duration_coeff={duration_coeff} min")
|
||||
|
||||
if len(vframe_frame) != nframes:
|
||||
print(f"\n ERROR: nframe_real ={len(vframe_frame)} / nframe_info ={nframes}")
|
||||
logger.info(f"\n ERROR: nframe_real ={len(vframe_frame)} / nframe_info ={nframes}")
|
||||
continue
|
||||
|
||||
if len(vframe_coeff)+1 < nframes:
|
||||
print(f"\n ERROR: nframe_coeff ={len(vframe_coeff)} / nframe_info ={nframes}")
|
||||
logger.info(f"\n ERROR: nframe_coeff ={len(vframe_coeff)} / nframe_info ={nframes}")
|
||||
continue
|
||||
|
||||
if ipath_save_exp.exists() and ipath_save_pos.exists():
|
||||
print(f"ipath_save_exp have already save > {ipath_save_exp}")
|
||||
continue
|
||||
# if ipath_save_exp.exists() and ipath_save_pos.exists():
|
||||
# logger.info(f"ipath_save_exp have already save > {ipath_save_exp}")
|
||||
# continue
|
||||
|
||||
feat_exp = []
|
||||
feat_pos = []
|
||||
@@ -69,7 +78,7 @@ if __name__ == "__main__":
|
||||
jpath_coeff = ipath_coeff.joinpath(f"frame-{j:06d}.json.npy")
|
||||
|
||||
if not jpath_coeff.exists():
|
||||
print(f"\n ERROR: Path NOT FOUND! -> {jpath_coeff}")
|
||||
logger.info(f"\n ERROR: Path NOT FOUND! -> {jpath_coeff}")
|
||||
break
|
||||
|
||||
data_coeff = np.load(jpath_coeff, allow_pickle=True).item()
|
||||
@@ -91,10 +100,10 @@ if __name__ == "__main__":
|
||||
np.save(ipath_save_exp, feat_exp)
|
||||
np.save(ipath_save_pos, feat_pos)
|
||||
np.save(ipath_save_idn, feat_idn)
|
||||
print(f"SAVE OK! exp shape = {feat_exp.shape},pos = {feat_pos.shape}, idn={feat_idn.shape} nframe={nframes}\n save to -> {ipath_save_exp}") # (nframe, 68, 2)
|
||||
logger.info(f"SAVE OK! exp shape = {feat_exp.shape},pos = {feat_pos.shape}, idn={feat_idn.shape} nframe={nframes}\n save to -> {ipath_save_exp}") # (nframe, 68, 2)
|
||||
|
||||
else:
|
||||
print("ERROR, skip! ")
|
||||
logger.info("ERROR, skip! ")
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user