From 88605c91f34974e3945efb8667f81736badc0dad Mon Sep 17 00:00:00 2001 From: harisreedhar Date: Wed, 10 Jun 2026 16:25:28 +0530 Subject: [PATCH] single-thread --- facefusion/face_stabilizer.py | 17 +++++++++++------ .../processors/modules/face_debugger/core.py | 2 +- facefusion/streamer.py | 6 +++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/facefusion/face_stabilizer.py b/facefusion/face_stabilizer.py index 0d5251fe..e7a156a1 100644 --- a/facefusion/face_stabilizer.py +++ b/facefusion/face_stabilizer.py @@ -32,18 +32,23 @@ def stabilize_faces(faces : List[Face], resolution : Resolution, smoothness : fl global FACE_STABILIZER_TIMESTAMP stabilized_faces = [] + timestamp = monotonic() + + if timestamp - FACE_STABILIZER_TIMESTAMP > FACE_STABILIZER_GAP: + clear_face_stabilizer() + FACE_STABILIZER_TIMESTAMP = timestamp if smoothness > 0: - timestamp = monotonic() - - if timestamp - FACE_STABILIZER_TIMESTAMP > FACE_STABILIZER_GAP: - clear_face_stabilizer() - FACE_STABILIZER_TIMESTAMP = timestamp - for index, face in enumerate(faces): stabilized_faces.append(stabilize_face(face, str(index), timestamp, resolution, smoothness)) return stabilized_faces + width, height = resolution + landmark_scale = numpy.array([ width, height ]) + + for index, face in enumerate(faces): + landmark_5 = face.landmark_set.get('5') / landmark_scale + append_face_stabilizer_trail(str(index), landmark_5[2], landmark_5[2]) return faces diff --git a/facefusion/processors/modules/face_debugger/core.py b/facefusion/processors/modules/face_debugger/core.py index ab0e84cb..b000ca6d 100755 --- a/facefusion/processors/modules/face_debugger/core.py +++ b/facefusion/processors/modules/face_debugger/core.py @@ -122,7 +122,7 @@ def draw_face_stabilizer(face_key : str, temp_vision_frame : VisionFrame) -> Vis temp_vision_frame = numpy.ascontiguousarray(temp_vision_frame) face_stabilizer_trail = get_face_stabilizer_trail(face_key) frame_height, frame_width = temp_vision_frame.shape[:2] - line_scale = 1 + line_scale = 3 raw_color = 0, 0, 255 smoothed_color = 0, 255, 0 diff --git a/facefusion/streamer.py b/facefusion/streamer.py index 80c5b583..c6a9ceb3 100644 --- a/facefusion/streamer.py +++ b/facefusion/streamer.py @@ -21,9 +21,13 @@ from facefusion.vision import extract_vision_mask, read_static_images def multi_process_capture(camera_capture : cv2.VideoCapture, camera_fps : Fps) -> Iterator[VisionFrame]: capture_deque : Deque[VisionFrame] = deque() source_vision_frames = read_static_images(state_manager.get_item('source_paths')) + execution_thread_count = state_manager.get_item('execution_thread_count') + + if state_manager.get_item('face_stabilizer_smoothness'): + execution_thread_count = 1 with tqdm(desc = translator.get('streaming'), unit = 'frame', disable = state_manager.get_item('log_level') in [ 'warn', 'error' ]) as progress: - with ThreadPoolExecutor(max_workers = state_manager.get_item('execution_thread_count')) as executor: + with ThreadPoolExecutor(max_workers = execution_thread_count) as executor: futures = [] while camera_capture and camera_capture.isOpened():