diff --git a/facefusion/predictor.py b/facefusion/predictor.py index 52962f51..4b2b81a0 100644 --- a/facefusion/predictor.py +++ b/facefusion/predictor.py @@ -25,6 +25,7 @@ MODELS : Dict[str, ModelValue] =\ } } MAX_PROBABILITY = 0.80 +MAX_MATCHES = 5 STREAM_COUNTER = 0 @@ -89,9 +90,13 @@ def predict_video(video_path : str, start_frame : int, end_frame : int) -> bool: video_frame_total = count_video_frame_total(video_path) fps = detect_fps(video_path) frame_range = range(start_frame or 0, end_frame or video_frame_total) - for frame_number in tqdm(frame_range, desc = wording.get('analysing')): - if frame_number % int(fps) == 0: - frame = get_video_frame(video_path, frame_number) - if predict_frame(frame): - return True - return False + matches = 0 + with tqdm(total = len(frame_range), desc = wording.get('analysing'), unit = 'frame') as progress: + for frame_number in frame_range: + if frame_number % int(fps) == 0: + frame = get_video_frame(video_path, frame_number) + if predict_frame(frame): + matches += 1 + progress.update() + progress.set_postfix(matches = matches) + return matches > MAX_MATCHES diff --git a/facefusion/processors/frame/core.py b/facefusion/processors/frame/core.py index a0f767b8..230ecc0f 100644 --- a/facefusion/processors/frame/core.py +++ b/facefusion/processors/frame/core.py @@ -63,8 +63,8 @@ def clear_frame_processors_modules() -> None: def multi_process_frames(source_path : str, temp_frame_paths : List[str], process_frames : Process_Frames) -> None: - progress_bar_format = '{l_bar}{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}{postfix}]' - with tqdm(total = len(temp_frame_paths), desc = wording.get('processing'), unit = 'frame', dynamic_ncols = True, bar_format = progress_bar_format) as progress: + bar_format = '{l_bar}{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}{postfix}]' + with tqdm(total = len(temp_frame_paths), desc = wording.get('processing'), unit = 'frame', bar_format = bar_format) as progress: with ThreadPoolExecutor(max_workers = facefusion.globals.execution_thread_count) as executor: futures = [] queue_temp_frame_paths : Queue[str] = create_queue(temp_frame_paths) diff --git a/facefusion/uis/components/webcam.py b/facefusion/uis/components/webcam.py index d2ccd41e..6db3699c 100644 --- a/facefusion/uis/components/webcam.py +++ b/facefusion/uis/components/webcam.py @@ -75,7 +75,7 @@ def start(mode : WebcamMode, resolution : str, fps : float) -> Generator[Frame, def multi_process_capture(source_face : Face, capture : cv2.VideoCapture, fps : float) -> Generator[Frame, None, None]: - progress = tqdm(desc = wording.get('processing'), unit = 'frame', dynamic_ncols = True) + progress = tqdm(desc = wording.get('processing'), unit = 'frame') with ThreadPoolExecutor(max_workers = facefusion.globals.execution_thread_count) as executor: futures = [] deque_capture_frames : Deque[Frame] = deque()