Closed GhoulBoii closed 1 month ago
This PR implements mouth masking functionality during face swapping, allowing the original mouth area to be preserved. The implementation includes mask creation, blending algorithms, and UI controls to toggle the feature. The changes primarily affect the face swapping processor and UI components.
journey
title User Journey for Toggling Mouth Masking Feature
section UI Interaction
User -> UI: Open application
User -> UI: Navigate to settings
User -> UI: Toggle 'Mouth Mask' switch
section System Processing
UI -> System: Update mouth_mask variable
System -> UI: Reflect change in UI switches
section Result
UI -> User: Mouth masking feature toggled
System -> User: Mouth area preserved during face swap if enabled
classDiagram
class FaceSwapper {
+pre_check() bool
+pre_start() bool
+get_face_swapper() Any
+create_face_masks(face: Face, frame: Frame) Tuple
+apply_mouth_area(frame: Frame, mouth_cutout: np.ndarray, mouth_box: Tuple, face_mask: np.ndarray, lower_lip_polygon: Optional[np.ndarray]) Frame
+swap_face(source_face: Face, target_face: Face, temp_frame: Frame) Frame
+process_frame(source_face: Face, temp_frame: Frame) Frame
+process_frame_v2(temp_frame: Frame, temp_frame_path: str) Frame
+process_frames(source_path: str, temp_frame_paths: List[str], progress: Any) None
+process_image(source_path: str, target_path: str, output_path: str) None
+process_video(source_path: str, temp_frame_paths: List[str]) None
}
note for FaceSwapper "New methods for mouth masking: create_face_masks, apply_mouth_area"
Change | Details | Files |
---|---|---|
Implement mouth masking functionality in face swapper |
|
modules/processors/frame/face_swapper.py |
Add UI controls for mouth masking feature |
|
modules/ui.py |
Add global state management for mouth masking |
|
modules/globals.py |
@sourcery-ai review
@sourcery-ai review
Hello @GhoulBoii , will review this tomorrow as theres a typhoon in our area. 🥲 Thanks for this push! Will send the bounty as soon as I have checked this.
Hello @GhoulBoii , will review this tomorrow as theres a typhoon in our area. 🥲 Thanks for this push! Will send the bounty as soon as I have checked this.
No problem! Stay safe and thanks for the bounty.
Hi there @GhoulBoii , as per testing mouth mask is not working properly. 😢
Will be closing this until a new working pull request is submitted.
The menu is a bit messed up at the moment. I will try fixing it in the morning.UI has been made uniform with the switches being added with the others. I did limited testing on my workstation and it worked. However, the live preview was coming frame-by-frame so couldn't test in a real world environment.Summary by Sourcery
Implement mouth masking feature to enhance face swapping by preserving the original mouth area. Update the UI to include controls for toggling mouth mask options.
New Features:
Enhancements: