mirror of
https://github.com/hacksider/Deep-Live-Cam.git
synced 2025-09-26 20:31:28 +08:00
Compare commits
3 Commits
ab8a1c82c1
...
pr/894
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5dd6d1fe64 | ||
![]() |
9af216e819 | ||
![]() |
59d64d4b6a |
@@ -41,3 +41,5 @@ show_mouth_mask_box = False
|
||||
mask_feather_ratio = 8
|
||||
mask_down_size = 0.50
|
||||
mask_size = 1
|
||||
opacity = 1.0
|
||||
face_swapper_enabled = True
|
||||
|
@@ -14,6 +14,7 @@ from modules.utilities import (
|
||||
is_video,
|
||||
)
|
||||
from modules.cluster_analysis import find_closest_centroid
|
||||
from modules.globals import face_swapper_enabled, opacity
|
||||
import os
|
||||
|
||||
FACE_SWAPPER = None
|
||||
@@ -25,7 +26,6 @@ models_dir = os.path.join(
|
||||
os.path.dirname(os.path.dirname(os.path.dirname(abs_dir))), "models"
|
||||
)
|
||||
|
||||
|
||||
def pre_check() -> bool:
|
||||
download_directory_path = abs_dir
|
||||
conditional_download(
|
||||
@@ -93,11 +93,17 @@ def swap_face(source_face: Face, target_face: Face, temp_frame: Frame) -> Frame:
|
||||
swapped_frame = draw_mouth_mask_visualization(
|
||||
swapped_frame, target_face, mouth_mask_data
|
||||
)
|
||||
opacity = getattr(modules.globals, "opacity", 1.0)
|
||||
swapped_frame = cv2.addWeighted(temp_frame, 1 - opacity, swapped_frame, opacity, 0)
|
||||
|
||||
|
||||
return swapped_frame
|
||||
|
||||
|
||||
def process_frame(source_face: Face, temp_frame: Frame) -> Frame:
|
||||
if getattr(modules.globals, "opacity", 1.0) == 0:
|
||||
return temp_frame
|
||||
|
||||
if modules.globals.color_correction:
|
||||
temp_frame = cv2.cvtColor(temp_frame, cv2.COLOR_BGR2RGB)
|
||||
|
||||
@@ -114,6 +120,9 @@ def process_frame(source_face: Face, temp_frame: Frame) -> Frame:
|
||||
|
||||
|
||||
def process_frame_v2(temp_frame: Frame, temp_frame_path: str = "") -> Frame:
|
||||
if getattr(modules.globals, "opacity", 1.0) == 0:
|
||||
return temp_frame
|
||||
|
||||
if is_image(modules.globals.target_path):
|
||||
if modules.globals.many_faces:
|
||||
source_face = default_source_face()
|
||||
|
@@ -27,6 +27,7 @@ from modules.utilities import (
|
||||
)
|
||||
from modules.video_capture import VideoCapturer
|
||||
from modules.gettext import LanguageManager
|
||||
from modules import globals
|
||||
import platform
|
||||
|
||||
if platform.system() == "Windows":
|
||||
@@ -160,12 +161,12 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
||||
select_face_button = ctk.CTkButton(
|
||||
root, text=_("Select a face"), cursor="hand2", command=lambda: select_source_path()
|
||||
)
|
||||
select_face_button.place(relx=0.1, rely=0.4, relwidth=0.3, relheight=0.1)
|
||||
select_face_button.place(relx=0.1, rely=0.375, relwidth=0.3, relheight=0.1)
|
||||
|
||||
swap_faces_button = ctk.CTkButton(
|
||||
root, text="↔", cursor="hand2", command=lambda: swap_faces_paths()
|
||||
)
|
||||
swap_faces_button.place(relx=0.45, rely=0.4, relwidth=0.1, relheight=0.1)
|
||||
swap_faces_button.place(relx=0.45, rely=0.375, relwidth=0.1, relheight=0.1)
|
||||
|
||||
select_target_button = ctk.CTkButton(
|
||||
root,
|
||||
@@ -173,7 +174,35 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
||||
cursor="hand2",
|
||||
command=lambda: select_target_path(),
|
||||
)
|
||||
select_target_button.place(relx=0.6, rely=0.4, relwidth=0.3, relheight=0.1)
|
||||
select_target_button.place(relx=0.6, rely=0.375, relwidth=0.3, relheight=0.1)
|
||||
|
||||
transparency_values = ["0%","25%", "50%", "75%", "100%"]
|
||||
transparency_var = ctk.StringVar(value="100%") # Default to 100%
|
||||
|
||||
def on_transparency_change(value: str):
|
||||
percentage = int(value.strip('%'))
|
||||
modules.globals.opacity = percentage / 100.0
|
||||
|
||||
if percentage == 0:
|
||||
modules.globals.fp_ui["face_enhancer"] = False
|
||||
update_status("Transparency set to 0% - Face swapping disabled.")
|
||||
elif percentage == 100:
|
||||
modules.globals.face_swapper_enabled = True
|
||||
update_status("Transparency set to 100%.")
|
||||
else:
|
||||
modules.globals.face_swapper_enabled = True
|
||||
update_status(f"Transparency set to {value}")
|
||||
|
||||
transparency_label = ctk.CTkLabel(root, text="Transparency:")
|
||||
transparency_label.place(relx=0.1, rely=0.5, relwidth=0.2, relheight=0.05)
|
||||
|
||||
transparency_dropdown = ctk.CTkOptionMenu(
|
||||
root,
|
||||
values=transparency_values,
|
||||
variable=transparency_var,
|
||||
command=on_transparency_change,
|
||||
)
|
||||
transparency_dropdown.place(relx=0.35, rely=0.5, relwidth=0.25, relheight=0.05)
|
||||
|
||||
keep_fps_value = ctk.BooleanVar(value=modules.globals.keep_fps)
|
||||
keep_fps_checkbox = ctk.CTkSwitch(
|
||||
|
Reference in New Issue
Block a user