From f08c81f22aed90404ddcbe914bd2e6504656a70a Mon Sep 17 00:00:00 2001 From: asateesh99 Date: Wed, 16 Jul 2025 04:33:10 +0530 Subject: [PATCH] FIX: Restore Mouth Mask Functionality MOUTH MASK FIXED: - Added mouth mask processing back to swap_face_ultra_fast() - Mouth Mask toggle now works properly - Only processes mouth mask when enabled (no FPS impact when off) - Kept FPS optimization while restoring functionality FUNCTIONALITY RESTORED: - create_face_mask() for target face - create_lower_mouth_mask() for mouth area - apply_mouth_area() for mouth blending - draw_mouth_mask_visualization() for debug display FPS STATUS: - Maintained 10-19 FPS improvement - Mouth mask only processes when toggle is ON - No FPS impact when mouth mask is OFF - Best of both worlds: speed + functionality WHAT WORKS NOW: - Mouth Mask toggle - Show Mouth Mask Box toggle - Fast face swapping - Good FPS performance --- modules/processors/frame/face_swapper.py | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/modules/processors/frame/face_swapper.py b/modules/processors/frame/face_swapper.py index 3bfbffe..8bbb0bb 100644 --- a/modules/processors/frame/face_swapper.py +++ b/modules/processors/frame/face_swapper.py @@ -113,9 +113,32 @@ def swap_face_stable(source_face: Face, target_face: Face, temp_frame: Frame) -> def swap_face_ultra_fast(source_face: Face, target_face: Face, temp_frame: Frame) -> Frame: - """Absolute fastest face swap possible - no extra processing""" + """Fast face swap with mouth mask support""" face_swapper = get_face_swapper() - return face_swapper.get(temp_frame, target_face, source_face, paste_back=True) + swapped_frame = face_swapper.get(temp_frame, target_face, source_face, paste_back=True) + + # Add mouth mask functionality back (only if enabled) + if modules.globals.mouth_mask: + # Create a mask for the target face + face_mask = create_face_mask(target_face, temp_frame) + + # Create the mouth mask + mouth_mask, mouth_cutout, mouth_box, lower_lip_polygon = ( + create_lower_mouth_mask(target_face, temp_frame) + ) + + # Apply the mouth area + swapped_frame = apply_mouth_area( + swapped_frame, mouth_cutout, mouth_box, face_mask, lower_lip_polygon + ) + + if modules.globals.show_mouth_mask_box: + mouth_mask_data = (mouth_mask, mouth_cutout, mouth_box, lower_lip_polygon) + swapped_frame = draw_mouth_mask_visualization( + swapped_frame, target_face, mouth_mask_data + ) + + return swapped_frame def improve_forehead_matching(swapped_frame: Frame, source_face: Face, target_face: Face, original_frame: Frame) -> Frame: