From aa60da7e9ab3385595533934448fe9b266ec4981 Mon Sep 17 00:00:00 2001 From: henryruhs Date: Sun, 22 Dec 2024 19:18:30 +0100 Subject: [PATCH] Stop webcam on source image change --- facefusion/uis/components/webcam.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/facefusion/uis/components/webcam.py b/facefusion/uis/components/webcam.py index 444e0dc8..a9b63d27 100644 --- a/facefusion/uis/components/webcam.py +++ b/facefusion/uis/components/webcam.py @@ -71,10 +71,14 @@ def listen() -> None: webcam_mode_radio = get_ui_component('webcam_mode_radio') webcam_resolution_dropdown = get_ui_component('webcam_resolution_dropdown') webcam_fps_slider = get_ui_component('webcam_fps_slider') + source_image = get_ui_component('source_image') if webcam_mode_radio and webcam_resolution_dropdown and webcam_fps_slider: start_event = WEBCAM_START_BUTTON.click(start, inputs = [ webcam_mode_radio, webcam_resolution_dropdown, webcam_fps_slider ], outputs = WEBCAM_IMAGE) - WEBCAM_STOP_BUTTON.click(stop, cancels = start_event) + WEBCAM_STOP_BUTTON.click(stop, cancels = start_event, outputs = WEBCAM_IMAGE) + + if source_image: + source_image.change(stop, cancels = start_event, outputs = WEBCAM_IMAGE) def start(webcam_mode : WebcamMode, webcam_resolution : str, webcam_fps : Fps) -> Generator[VisionFrame, None, None]: