From 99214c7ab1b2335db0ff3fe71cfea8813e95418e Mon Sep 17 00:00:00 2001 From: Gianfranco Palumbo Date: Wed, 14 Aug 2024 17:52:42 +0200 Subject: [PATCH 1/2] Stop live mode the preview window is closed --- modules/core.py | 3 +-- modules/ui.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/core.py b/modules/core.py index 3ec1617..db64f37 100644 --- a/modules/core.py +++ b/modules/core.py @@ -74,7 +74,7 @@ def parse_args() -> None: modules.globals.fp_ui['face_enhancer'] = True else: modules.globals.fp_ui['face_enhancer'] = False - + modules.globals.nsfw = False # translate deprecated args @@ -165,7 +165,6 @@ def update_status(message: str, scope: str = 'DLC.CORE') -> None: if not modules.globals.headless: ui.update_status(message) - def start() -> None: for frame_processor in get_frame_processors_modules(modules.globals.frame_processors): if not frame_processor.pre_start(): diff --git a/modules/ui.py b/modules/ui.py index 1d0bb69..ab18e95 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -61,11 +61,11 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C target_label = ctk.CTkLabel(root, text=None) target_label.place(relx=0.6, rely=0.1, relwidth=0.3, relheight=0.25) - source_button = ctk.CTkButton(root, text='Select a face', cursor='hand2', command=lambda: select_source_path()) - source_button.place(relx=0.1, rely=0.4, relwidth=0.3, relheight=0.1) + 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) - target_button = ctk.CTkButton(root, text='Select a target', cursor='hand2', command=lambda: select_target_path()) - target_button.place(relx=0.6, rely=0.4, relwidth=0.3, relheight=0.1) + select_target_button = ctk.CTkButton(root, text='Select a target', cursor='hand2', command=lambda: select_target_path()) + select_target_button.place(relx=0.6, rely=0.4, relwidth=0.3, relheight=0.1) keep_fps_value = ctk.BooleanVar(value=modules.globals.keep_fps) keep_fps_checkbox = ctk.CTkSwitch(root, text='Keep fps', variable=keep_fps_value, cursor='hand2', command=lambda: setattr(modules.globals, 'keep_fps', not modules.globals.keep_fps)) @@ -253,7 +253,7 @@ def webcam_preview(): if modules.globals.source_path is None: # No image selected return - + global preview_label, PREVIEW cap = cv2.VideoCapture(0) # Use index for the webcam (adjust the index accordingly if necessary) @@ -292,5 +292,8 @@ def webcam_preview(): preview_label.configure(image=image) ROOT.update() + if PREVIEW.state() == 'withdrawn': + break + cap.release() - PREVIEW.withdraw() # Close preview window when loop is finished \ No newline at end of file + PREVIEW.withdraw() # Close preview window when loop is finished From 4324b41b9e7857423e87411289e49f9a8b276ca1 Mon Sep 17 00:00:00 2001 From: Kenneth Estanislao Date: Thu, 15 Aug 2024 03:03:57 +0800 Subject: [PATCH 2/2] Update ui.py hides NSFW button --- modules/ui.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ui.py b/modules/ui.py index ab18e95..2759a9e 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -88,9 +88,9 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C many_faces_switch = ctk.CTkSwitch(root, text='Many faces', variable=many_faces_value, cursor='hand2', command=lambda: setattr(modules.globals, 'many_faces', many_faces_value.get())) many_faces_switch.place(relx=0.6, rely=0.65) - nsfw_value = ctk.BooleanVar(value=modules.globals.nsfw) - nsfw_switch = ctk.CTkSwitch(root, text='NSFW', variable=nsfw_value, cursor='hand2', command=lambda: setattr(modules.globals, 'nsfw', nsfw_value.get())) - nsfw_switch.place(relx=0.6, rely=0.7) +# nsfw_value = ctk.BooleanVar(value=modules.globals.nsfw) +# nsfw_switch = ctk.CTkSwitch(root, text='NSFW', variable=nsfw_value, cursor='hand2', command=lambda: setattr(modules.globals, 'nsfw', nsfw_value.get())) +# nsfw_switch.place(relx=0.6, rely=0.7) start_button = ctk.CTkButton(root, text='Start', cursor='hand2', command=lambda: select_output_path(start)) start_button.place(relx=0.15, rely=0.80, relwidth=0.2, relheight=0.05)