add eval.py with metrics
This commit is contained in:
1 parent
11277e478f
commit
baed1fffe3
53 files changed
+5844
-378
No files matched your search
@@ -8,7 +8,7 @@ if __name__ == '__main__':
|
||||
|
||||
# path_root = Path("/yrfs/lsen/DATA/Actor1")
|
||||
|
||||
path_raw = Path("/ssdata1/cf/data/raw/20220311")
|
||||
path_raw = Path("/ssdata1/cf/data/raw/20220319")
|
||||
path_root = Path("/yrfs/lsen/DATA/Actor2")
|
||||
|
||||
vpath_videos = sorted(path_raw.glob("*.MP4"), reverse=False)
|
||||
@@ -23,7 +23,7 @@ if __name__ == '__main__':
|
||||
|
||||
# if i < 40: continue
|
||||
# if iname not in IDs: continue
|
||||
|
||||
|
||||
# data path
|
||||
ipath_data = path_root.joinpath("processing", ipath_item.stem)
|
||||
|
||||
@@ -36,13 +36,19 @@ if __name__ == '__main__':
|
||||
ipath_video.mkdir(parents=True, exist_ok=True)
|
||||
ipath_audio.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# # # load video info
|
||||
# if ipath_infor.exists():
|
||||
# continue
|
||||
# # with open(str(ipath_infor), "r") as f:
|
||||
# # info = json.load(f)
|
||||
# # nframe_info = info['nframes']
|
||||
# # load video info & check
|
||||
if ipath_infor.exists():
|
||||
# continue
|
||||
with open(str(ipath_infor), "r") as f:
|
||||
info = json.load(f)
|
||||
nframe_info = info['nframes']
|
||||
|
||||
# check frames
|
||||
nframe_real = len(list(ipath_frame.glob("*.jpg")))
|
||||
if nframe_real == nframe_info:
|
||||
print(f"\n Skip: have already done!")
|
||||
continue
|
||||
|
||||
# load video
|
||||
video = VideoFileClip(str(ipath_item))
|
||||
print(f"video duration = {video.duration}, fps = {video.fps}, (start, end)=({video.start},{video.end}), nframes={int(video.duration * video.fps)}")
|
||||
@@ -52,8 +58,8 @@ if __name__ == '__main__':
|
||||
continue
|
||||
|
||||
durations += video.duration
|
||||
print(f"\t -> Total durations = ({durations / 60 } min) ({durations / 3600 } h))")
|
||||
continue
|
||||
print(f"\n\t -> Total durations = ({durations / 60 } min) ({durations / 3600 } h))")
|
||||
# continue
|
||||
|
||||
# Trim
|
||||
# video = video.subclip(t_start=5.0, t_end=int(video.duration)-5.0) before 03.14
|
||||
@@ -65,7 +71,6 @@ if __name__ == '__main__':
|
||||
# nframes = len(list(video.iter_frames()))
|
||||
# print(f"after cut video duration = {video.duration}, fps = {video.fps}, (start, end)=({video.start},{video.end}), nframes={int(video.duration * video.fps)}")
|
||||
|
||||
|
||||
# if fps != 50
|
||||
if video.fps != 50:
|
||||
print("FPS NOT = 50!! ")
|
||||
@@ -86,11 +91,6 @@ if __name__ == '__main__':
|
||||
nframes = len(list(video.iter_frames()))
|
||||
|
||||
|
||||
# check frames
|
||||
# nframe_real = len(list(ipath_frame.glob("*.jpg")))
|
||||
# if nframe_real == nframes:
|
||||
# print(f"\n Skip: have already done!")
|
||||
# continue
|
||||
|
||||
# get audio
|
||||
audio_sub = video.audio
|
||||
|
||||
@@ -7,7 +7,6 @@ from pathlib import Path
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# path_data = Path('/yrfs/lsen/DATA/TestData/processing') # '../data/trinity/source'
|
||||
path_data = Path("/yrfs/lsen/DATA/Actor2/processing")
|
||||
v_dir_videos = sorted(path_data.glob("*"))
|
||||
print(f"Have {len(v_dir_videos)} dir files")
|
||||
@@ -33,7 +32,6 @@ if __name__ == "__main__":
|
||||
if not ipath_infors.exists():
|
||||
continue
|
||||
|
||||
|
||||
# load video info
|
||||
with open(str(ipath_infors), "r") as f:
|
||||
info = json.load(f)
|
||||
|
||||
@@ -29,10 +29,8 @@ def landmark_resample_fps(y, source_fps = 30, target_fps=25):
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
||||
path_data = Path("/yrfs/lsen/DATA/Actor2/processing")
|
||||
|
||||
path_save = Path('data/Actor2/Actor2-raw-6h') # processing
|
||||
path_save = Path('data/Actor2/Actor2-raw-7h') # processing
|
||||
path_save.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
v_dir_videos = sorted(path_data.glob("*/audio/feat_DECA_exp_trim.npy"))
|
||||
@@ -43,8 +41,16 @@ if __name__ == "__main__":
|
||||
# print(f"vids total= {vids}")
|
||||
|
||||
vid_test = set(["AA7A9568", "AA7A9577"])
|
||||
vid_valid = set(["AA7A9569", "AA7A9578"])
|
||||
vid_train = vids - vid_test - vid_valid
|
||||
# vid_valid = set(["AA7A9569", "AA7A9578"])
|
||||
vid_train = set(['AA7A9570', 'AA7A9571', 'AA7A9572', 'AA7A9573', 'AA7A9574', 'AA7A9575', 'AA7A9576', 'AA7A9579',
|
||||
'AA7A9580', 'AA7A9582', 'AA7A9583', 'AA7A9584', 'AA7A9585', 'AA7A9600', 'AA7A9601', 'AA7A9602',
|
||||
'AA7A9603', 'AA7A9604', 'AA7A9605', 'AA7A9606', 'AA7A9607', 'AA7A9608', 'AA7A9609', 'AA7A9610',
|
||||
'AA7A9611', 'AA7A9612', 'AA7A9613', 'AA7A9614', 'AA7A9615', 'AA7A9616', 'AA7A9617', 'AA7A9618',
|
||||
'AA7A9619', 'AA7A9620', 'AA7A9621', 'AA7A9622', 'AA7A9623', 'AA7A9625', 'AA7A9626', 'AA7A9627',
|
||||
'AA7A9628'])
|
||||
|
||||
# vid_train = vids - vid_test - vid_valid
|
||||
vid_valid = vids - vid_test - vid_train
|
||||
|
||||
# vids = set(["2021-P09", "2021-P14", "2021-P22"])
|
||||
# vid_test = set(["2021-P09" ])
|
||||
@@ -63,7 +69,7 @@ if __name__ == "__main__":
|
||||
# if vid not in vids: continue
|
||||
# if vid in vid_test: continue
|
||||
# if vid in vid_valid:continue
|
||||
if durations_train / 3600 > 6: break
|
||||
# if durations_train / 3600 > 6: break
|
||||
|
||||
print(f"\n processing the {i}-th video {vid} ... ")
|
||||
|
||||
@@ -104,7 +110,6 @@ if __name__ == "__main__":
|
||||
data_motion = np.concatenate([data_exp, data_pos_lips], axis=1) # (nframe, 53) --> fps=30
|
||||
print(f"motion = {data_motion.shape}")
|
||||
|
||||
|
||||
# load raw audio
|
||||
audio_raw, sample_rate = torchaudio.load(ipath_speech)
|
||||
print(f"audio_raw shape = {audio_raw.shape}, sr = {sample_rate}, duration = {(len(audio_raw[0])/sample_rate)}")
|
||||
@@ -139,6 +144,7 @@ if __name__ == "__main__":
|
||||
"data_shape": data_idn,
|
||||
}
|
||||
|
||||
|
||||
if vid in vid_valid:
|
||||
durations_valid += nframes/fps
|
||||
|
||||
@@ -166,15 +172,15 @@ if __name__ == "__main__":
|
||||
|
||||
|
||||
|
||||
|
||||
print(f"Total frames: data_train ({durations_train / 60 } min) ({durations_train / 3600 } h) , ids = ({len(data_train)})")
|
||||
print(f"Total frames: data_valid ({durations_valid / 60 } min) ({durations_valid / 3600 } h) , ids = ({len(data_valid)})")
|
||||
print(f"Total frames: data_test ({durations_test / 60 } min) ({durations_test / 3600 } h) , ids = ({len(data_test)})")
|
||||
|
||||
|
||||
np.savez(path_save.joinpath("data_train.npz"), data=data_train)
|
||||
np.savez(path_save.joinpath("data_valid.npz"), data=data_valid)
|
||||
np.savez(path_save.joinpath("data_test.npz"), data=data_test)
|
||||
|
||||
print(f"Total frames: data_train ({durations_train / 60 } min) ({durations_train / 3600 } h) , ids = ({len(data_train)})")
|
||||
print(f"Total frames: data_valid ({durations_valid / 60 } min) ({durations_valid / 3600 } h) , ids = ({len(data_valid)})")
|
||||
print(f"Total frames: data_test ({durations_test / 60 } min) ({durations_test / 3600 } h) , ids = ({len(data_test)})")
|
||||
|
||||
# print(f"Total ids: data_train ({len(data_train)}), data_test ({len(data_test)}) data_valid({len(data_valid)})")
|
||||
# print(f"Total frames: data_train ({durations_train / 60 } min) ({durations_train / 3600 } h) , data_test ({durations_test / 60 } min) data_valid({durations_valid / 60} min)")
|
||||
|
||||
Whitespace-only changes.
Reference in new issue
Block a user