Opacity Update

- Added 0 value, if it is set to 0, the face swapping will be disabled
pull/894/head
Makaru 2025-01-14 22:45:16 +08:00
parent 59d64d4b6a
commit 9af216e819
3 changed files with 17 additions and 4 deletions

View File

@ -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

View File

@ -103,6 +103,9 @@ def process_frame(source_face: Face, temp_frame: Frame) -> Frame:
if modules.globals.color_correction:
temp_frame = cv2.cvtColor(temp_frame, cv2.COLOR_BGR2RGB)
if modules.globals.opacity or modules.globals.face_swapper_enabled == 0:
return temp_frame
if modules.globals.many_faces:
many_faces = get_many_faces(temp_frame)
if many_faces:

View File

@ -175,13 +175,21 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
)
select_target_button.place(relx=0.6, rely=0.375, relwidth=0.3, relheight=0.1)
transparency_values = ["25%", "50%", "75%", "100%"]
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('%'))
opacity = percentage / 100.0
modules.globals.opacity = opacity # Save opacity globally for real-time updates
modules.globals.opacity = percentage / 100.0
if percentage == 0:
modules.globals.face_swapper_enabled = 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:")