single-thread

This commit is contained in:
harisreedhar
2026-06-10 16:25:28 +05:30
parent 0da13a919c
commit 88605c91f3
3 changed files with 17 additions and 8 deletions
+11 -6
View File
@@ -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
@@ -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
+5 -1
View File
@@ -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():