From 96878917b5cea97e16722652ce00ba83dff91db4 Mon Sep 17 00:00:00 2001 From: henryruhs Date: Mon, 10 Feb 2025 09:53:02 +0100 Subject: [PATCH] Prevent false calculation for rate --- facefusion/content_analyser.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/facefusion/content_analyser.py b/facefusion/content_analyser.py index b539dd2..9f9ec7b 100644 --- a/facefusion/content_analyser.py +++ b/facefusion/content_analyser.py @@ -90,6 +90,7 @@ def analyse_video(video_path : str, trim_frame_start : int, trim_frame_end : int video_fps = detect_video_fps(video_path) frame_range = range(trim_frame_start, trim_frame_end) rate = 0.0 + total = 0 counter = 0 with tqdm(total = len(frame_range), desc = wording.get('analysing'), unit = 'frame', ascii = ' =', disable = state_manager.get_item('log_level') in [ 'warn', 'error' ]) as progress: @@ -97,9 +98,11 @@ def analyse_video(video_path : str, trim_frame_start : int, trim_frame_end : int for frame_number in frame_range: if frame_number % int(video_fps) == 0: vision_frame = read_video_frame(video_path, frame_number) + total += 1 if analyse_frame(vision_frame): counter += 1 - rate = counter * int(video_fps) / len(frame_range) * 100 + if counter > 0 and total > 0: + rate = counter / total * 100 progress.set_postfix(rate = rate) progress.update()