Closed KRSHH closed 1 month ago
This PR implements a mouth mask feature for face swapping that preserves the original mouth area of the target face. The implementation includes mask creation, color correction, and visualization capabilities. The changes primarily affect the face swapper module and add new UI controls.
classDiagram
class FaceSwapper {
+get_face_swapper() : Any
+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
+create_lower_mouth_mask(face: Face, frame: Frame) : (np.ndarray, np.ndarray, tuple, np.ndarray)
+draw_mouth_mask_visualization(frame: Frame, face: Face, mouth_mask_data: tuple) : Frame
+apply_mouth_area(frame: np.ndarray, mouth_cutout: np.ndarray, mouth_box: tuple, face_mask: np.ndarray, mouth_polygon: np.ndarray) : np.ndarray
+create_face_mask(face: Face, frame: Frame) : np.ndarray
+apply_color_transfer(source, target)
}
class UI {
+create_root(start: Callable[[], None], destroy: Callable[[], None]) : ctk.CTk
}
class Globals {
+mouth_mask: bool
+show_mouth_mask_box: bool
+mask_feather_ratio: int
+mask_down_size: float
+mask_size: int
}
FaceSwapper --> UI : uses
FaceSwapper --> Globals : uses
UI --> Globals : uses
note for FaceSwapper "New methods for mouth mask feature added"
note for UI "New UI controls for mouth mask feature added"
note for Globals "New global variables for mouth mask feature added"
Change | Details | Files |
---|---|---|
Added mouth mask functionality to preserve original mouth area during face swapping |
|
modules/processors/frame/face_swapper.py |
Added UI controls for mouth mask features |
|
modules/ui.py modules/globals.py |
Added visualization and debugging features for mouth mask |
|
modules/processors/frame/face_swapper.py |
Directly commited to main last time (now reverted)... my mistake
Summary by Sourcery
Implement a mouth mask feature in the face swapping module to enhance realism by separately handling the mouth area. Update the UI to include switches for enabling the mouth mask and visualizing the mouth mask box, giving users more control over the feature.
New Features:
Enhancements: