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
@@ -7,14 +7,13 @@ from moviepy.editor import VideoFileClip, AudioFileClip
|
||||
if __name__ == '__main__':
|
||||
|
||||
# path_root = Path("/yrfs/lsen/DATA/Actor1")
|
||||
path_root = Path("/yrfs/lsen/DATA/Actor1")
|
||||
|
||||
path_root = Path("/mfs/lsen/DATA/Actor1")
|
||||
|
||||
vpath_videos = sorted(path_root.glob("raw/*.MP4"), reverse=False)
|
||||
print(f"Have {len(vpath_videos)} dir files")
|
||||
|
||||
# IDs = ["1-29min", "2-23min", "3-27min"]
|
||||
# IDs = ["1-29min", "2-23min", "3-27min"]
|
||||
IDs = ["1-29min", "2-23min", "3-27min"]
|
||||
durations = 0
|
||||
# for each video
|
||||
for i, ipath_item in enumerate(vpath_videos):
|
||||
@@ -22,7 +21,7 @@ if __name__ == '__main__':
|
||||
print(f"processing {i}/{len(vpath_videos)} -> {ipath_item} ... ")
|
||||
|
||||
# if i < 40: continue
|
||||
# if iname in IDs: continue
|
||||
if iname in IDs: continue
|
||||
|
||||
# data path
|
||||
ipath_data = path_root.joinpath("processing", ipath_item.stem)
|
||||
@@ -35,12 +34,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():
|
||||
# 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)}")
|
||||
@@ -53,10 +59,12 @@ if __name__ == '__main__':
|
||||
print("\nERROR: audio info is None")
|
||||
continue
|
||||
|
||||
durations += video.duration
|
||||
print(f"\n\t -> Total durations = ({durations / 60 } min) ({durations / 3600 } h))")
|
||||
# cont
|
||||
|
||||
# Trim
|
||||
# video = video.subclip(t_start=5.0, t_end=int(video.duration)-5.0)
|
||||
|
||||
video = video.subclip(t_start=15.0, t_end=int(video.duration)-15.0)
|
||||
|
||||
# video = video.subclip(t_start=5.0, t_end=60.0)
|
||||
@@ -84,11 +92,6 @@ if __name__ == '__main__':
|
||||
print(f"video reload duration = {video.duration}, fps = {video.fps}, (start, end)=({video.start},{video.end}), nframes={int(video.duration * video.fps)}")
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user