remove lfs
This commit is contained in:
1 parent
6fe3a2c3cd
commit
4a53051fee
196 files changed
-42808
No files matched your search
@@ -1,110 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import librosa
|
||||
import numpy as np
|
||||
from pathlib import Path
|
||||
|
||||
import os, sys
|
||||
sys.path.insert(0, os.getcwd())
|
||||
from common.logger import Logger
|
||||
|
||||
|
||||
def load_mask(j, path_parse):
|
||||
|
||||
parsing_anno = np.load(path_parse) # (512, 512)
|
||||
mask = np.zeros_like(parsing_anno).astype(np.uint8) # (512, 512)
|
||||
|
||||
atts = ['skin', 'l_brow', 'r_brow', 'l_eye', 'r_eye', 'eye_g', 'l_ear', 'r_ear', 'ear_r',
|
||||
'nose', 'mouth', 'u_lip', 'l_lip', 'neck', 'neck_l', 'cloth', 'hair', 'hat']
|
||||
|
||||
# atts_selected = ['skin', 'l_brow', 'r_brow', 'nose', 'u_lip', 'l_lip']
|
||||
# atts_selected = ['skin', 'l_brow', 'r_brow', 'l_eye', 'r_eye', 'eye_g', 'l_ear', 'r_ear', 'ear_r',
|
||||
# 'nose', 'mouth', 'u_lip', 'l_lip', ]
|
||||
atts_selected = ['skin', 'l_brow', 'r_brow', 'l_eye', 'r_eye', 'eye_g', 'nose', 'mouth', 'u_lip', 'l_lip']
|
||||
|
||||
class_contains = np.unique(parsing_anno)
|
||||
|
||||
if j % 1000 == 0:
|
||||
logger.info(f"\t the {j:06d}-th frame, class_contains = {class_contains}")
|
||||
|
||||
for iclass, iatt in enumerate(atts, 1):
|
||||
if (iatt in atts_selected) and (iclass in class_contains):
|
||||
index = np.where(parsing_anno == iclass)
|
||||
mask[index[0], index[1]] = 1
|
||||
|
||||
return mask
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
actor = "Actor5"
|
||||
sub_folder = "processing" # smile, processing, processing2
|
||||
|
||||
|
||||
# logger
|
||||
logger = Logger(f"./data/{actor}", postfix=f"generate-mask-{sub_folder}")
|
||||
|
||||
|
||||
path_data = Path(f"/ssdata1/lsen/DATA/{actor}/{sub_folder}")
|
||||
v_dir_videos = sorted(path_data.glob("*"), reverse=False)
|
||||
logger.info(f"Have {len(v_dir_videos)} dir files")
|
||||
|
||||
# for each video
|
||||
duration_frame, duration_parse = 0, 0
|
||||
for ipath_data in v_dir_videos:
|
||||
ivideo_name = ipath_data.stem
|
||||
|
||||
logger.info(f"\n processing {ivideo_name} ... ")
|
||||
ipath_infors = ipath_data.joinpath("video/info.json")
|
||||
ipath_frame = ipath_data.joinpath("frames")
|
||||
ipath_parse = ipath_data.joinpath("frames_crop_parse_512")
|
||||
ipath_parse_skin = ipath_data.joinpath("frames_crop_parse_skin_512")
|
||||
ipath_parse_skin.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# if ipath_save_parse.exists():
|
||||
# logger.info(f"ipath_save_exp have already save > {ipath_save_parse}")
|
||||
# continue
|
||||
|
||||
if not ipath_infors.exists():
|
||||
continue
|
||||
|
||||
# load video info
|
||||
with open(str(ipath_infors), "r") as f:
|
||||
info = json.load(f)
|
||||
fps = info["fps"]
|
||||
nframes = info["nframes"]
|
||||
logger.info(f"info = {info}, duration ={nframes / fps / 60}")
|
||||
|
||||
# check equal
|
||||
vframe_frame = list(ipath_frame.glob("*.jpg"))
|
||||
vframe_parse = list(ipath_parse.glob("*.npy"))
|
||||
logger.info(f"vframe_frame len = {len(vframe_frame)}, vframe_parse={len(vframe_parse)}")
|
||||
|
||||
duration_frame += len(vframe_frame) / 50 / 60
|
||||
duration_parse += len(vframe_parse) / 50 / 60
|
||||
logger.info(f"add duration_frame = {duration_frame} min, duration_parse={duration_parse} min")
|
||||
|
||||
if len(vframe_frame) != nframes:
|
||||
logger.info(f"\n ERROR: nframe_real ={len(vframe_frame)} / nframe_info ={nframes}")
|
||||
continue
|
||||
|
||||
# check have done
|
||||
# vframe_parse = list(ipath_parse_skin.glob("*.npy"))
|
||||
# if len(vframe_parse) == nframes:
|
||||
# logger.info(f"ipath_parse_skin have already done!")
|
||||
# continue
|
||||
|
||||
# feat_parse = []
|
||||
for j in range(len(vframe_frame)):
|
||||
jpath_parse = ipath_parse.joinpath(f"frame-{j:06d}.npy")
|
||||
jpath_parse_save = ipath_parse_skin.joinpath(f"frame-{j:06d}.npy")
|
||||
|
||||
if not jpath_parse.exists():
|
||||
logger.info(f"\n ERROR: Path NOT FOUND! -> {jpath_parse}")
|
||||
break
|
||||
|
||||
data_mask = load_mask(j, jpath_parse) # (512, 512)
|
||||
np.save(jpath_parse_save, data_mask)
|
||||
|
||||
# feat_parse.append(data_mask)
|
||||
Reference in new issue
Block a user