81 lines
2.8 KiB
Python
81 lines
2.8 KiB
Python
import numpy as np
|
|
from pathlib import Path
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
# fid = "Bringing-Our-Workplace-Policies-into-the-21st-Century"
|
|
fid = "Equipping-Workers-with-Skills-Employers-Need-Now-and-for-the-Future"
|
|
path_root = Path("/yrfs/lsen/DATA/Obama/processing/")
|
|
path_data = path_root.joinpath(fid)
|
|
|
|
path_coeff = path_data.joinpath("DECA_coeff")
|
|
vpath_coeff = sorted(path_coeff.glob("*.npy"), reverse=False)
|
|
print(f"Have {len(vpath_coeff)} frames")
|
|
|
|
|
|
feat_shape = []
|
|
feat_tex = []
|
|
feat_cam = []
|
|
feat_exp = []
|
|
feat_pos = []
|
|
feat_light = []
|
|
feat_detail = []
|
|
|
|
for ipath_coeff in vpath_coeff:
|
|
|
|
data_coeff = np.load(ipath_coeff, allow_pickle=True).item()
|
|
|
|
# print(data_coeff.keys())
|
|
|
|
feat_exp.append(data_coeff["exp"])
|
|
feat_pos.append(data_coeff["pose"])
|
|
feat_tex.append(data_coeff["tex"])
|
|
feat_cam.append(data_coeff["cam"])
|
|
feat_light.append(data_coeff["light"])
|
|
feat_detail.append(data_coeff["detail"])
|
|
feat_shape.append(data_coeff["shape"])
|
|
|
|
# save
|
|
feat_exp = np.array(feat_exp) # (nframe_trim, 50)
|
|
feat_pos = np.array(feat_pos) # (nframe_trim, 6)
|
|
feat_tex = np.array(feat_tex) # (nframe_trim, 50)
|
|
feat_cam = np.array(feat_cam) # (nframe_trim, 6)
|
|
feat_light = np.array(feat_light) # (nframe_trim, 50)
|
|
feat_detail = np.array(feat_detail) # (nframe_trim, 6)
|
|
feat_shape = np.array(feat_shape) # (nframe_trim, 50)
|
|
|
|
mean_exp = feat_exp.mean(axis=0)
|
|
mean_pos = feat_pos.mean(axis=0)
|
|
mean_tex = feat_tex.mean(axis=0)
|
|
mean_cam = feat_cam.mean(axis=0)
|
|
mean_light = feat_light.mean(axis=0)
|
|
mean_detail = feat_detail.mean(axis=0)
|
|
mean_shape = feat_shape.mean(axis=0)
|
|
|
|
print(f"feat_exp shape = {feat_exp.shape}, mean = {mean_exp.shape}, \n{mean_exp}")
|
|
print(f"mean_pos shape = {feat_pos.shape}, mean = {mean_pos.shape}, \n{mean_pos}")
|
|
print(f"mean_tex shape = {feat_tex.shape}, mean = {mean_tex.shape}, \n{mean_tex}")
|
|
print(f"mean_cam shape = {feat_cam.shape}, mean = {mean_cam.shape}, \n{mean_cam}")
|
|
print(f"mean_light shape = {feat_light.shape}, mean = {mean_light.shape}, \n{mean_light}")
|
|
print(f"mean_detail shape = {feat_detail.shape}, mean = {mean_detail.shape}, \n{mean_detail}")
|
|
print(f"mean_shape shape = {feat_shape.shape}, mean = {mean_shape.shape}, \n{mean_shape}")
|
|
|
|
# save
|
|
mean_DECA = {
|
|
"exp": mean_exp, # (50, )
|
|
"pose": mean_pos, # (6, )
|
|
"tex": mean_tex, # (50, )
|
|
"cam": mean_cam, # (3, )
|
|
"light": mean_light, # (9, 3)
|
|
"detail": mean_detail,# (128, )
|
|
"shape": mean_shape, # (100, )
|
|
}
|
|
|
|
path_save = "./data/DECA_obama_mean.npy"
|
|
# np.save(path_save, mean_DECA)
|
|
print("save to --> ", path_save)
|
|
|
|
|
|
|