From 114be9a8b69639622d05593a267d09bd869c88c9 Mon Sep 17 00:00:00 2001 From: henryruhs Date: Wed, 9 Aug 2023 15:13:42 +0200 Subject: [PATCH] Improve ui labels --- roop/uis/__components__/output.py | 10 +++++++-- roop/uis/__components__/preview.py | 32 +++++++++++++--------------- roop/uis/__components__/reference.py | 6 +++--- roop/uis/__components__/settings.py | 16 +++++++------- roop/uis/__components__/source.py | 6 +++--- roop/uis/__components__/target.py | 12 +++++------ roop/uis/typing.py | 2 +- 7 files changed, 44 insertions(+), 40 deletions(-) diff --git a/roop/uis/__components__/output.py b/roop/uis/__components__/output.py index 15e8541f0..33c6bde93 100644 --- a/roop/uis/__components__/output.py +++ b/roop/uis/__components__/output.py @@ -23,8 +23,14 @@ def render() -> None: with gradio.Row(): START_BUTTON = gradio.Button('Start') CLEAR_BUTTON = gradio.Button('Clear') - OUTPUT_IMAGE = gradio.Image(label='output_image', visible=False) - OUTPUT_VIDEO = gradio.Video(label='output_video', visible=False) + OUTPUT_IMAGE = gradio.Image( + label='OUTPUT', + visible=False + ) + OUTPUT_VIDEO = gradio.Video( + label='OUTPUT', + visible=False + ) def listen() -> None: diff --git a/roop/uis/__components__/preview.py b/roop/uis/__components__/preview.py index 84abf3de8..b07c41c33 100644 --- a/roop/uis/__components__/preview.py +++ b/roop/uis/__components__/preview.py @@ -16,20 +16,19 @@ from roop.utilities import is_video, is_image PREVIEW_IMAGE: Optional[gradio.Image] = None -PREVIEW_SLIDER: Optional[gradio.Slider] = None +PREVIEW_FRAME_SLIDER: Optional[gradio.Slider] = None def render() -> None: global PREVIEW_IMAGE - global PREVIEW_SLIDER + global PREVIEW_FRAME_SLIDER with gradio.Box(): preview_image_args: Dict[str, Any] = { - 'label': 'preview_image', - 'visible': False + 'label': 'PREVIEW' } - preview_slider_args: Dict[str, Any] = { - 'label': 'preview_slider', + preview_frame_slider_args: Dict[str, Any] = { + 'label': 'PREVIEW FRAME', 'step': 1, 'visible': False } @@ -37,22 +36,21 @@ def render() -> None: target_frame = cv2.imread(roop.globals.target_path) preview_frame = get_preview_frame(target_frame) preview_image_args['value'] = ui.normalize_frame(preview_frame) - preview_image_args['visible'] = True if is_video(roop.globals.target_path): temp_frame = get_video_frame(roop.globals.target_path, roop.globals.reference_frame_number) preview_frame = get_preview_frame(temp_frame) preview_image_args['value'] = ui.normalize_frame(preview_frame) preview_image_args['visible'] = True - preview_slider_args['value'] = roop.globals.reference_frame_number - preview_slider_args['maximum'] = get_video_frame_total(roop.globals.target_path) - preview_slider_args['visible'] = True + preview_frame_slider_args['value'] = roop.globals.reference_frame_number + preview_frame_slider_args['maximum'] = get_video_frame_total(roop.globals.target_path) + preview_frame_slider_args['visible'] = True PREVIEW_IMAGE = gradio.Image(**preview_image_args) - PREVIEW_SLIDER = gradio.Slider(**preview_slider_args) - ui.register_component('preview_slider', PREVIEW_SLIDER) + PREVIEW_FRAME_SLIDER = gradio.Slider(**preview_frame_slider_args) + ui.register_component('preview_frame_slider', PREVIEW_FRAME_SLIDER) def listen() -> None: - PREVIEW_SLIDER.change(update, inputs=PREVIEW_SLIDER, outputs=[PREVIEW_IMAGE, PREVIEW_SLIDER], show_progress=False) + PREVIEW_FRAME_SLIDER.change(update, inputs=PREVIEW_FRAME_SLIDER, outputs=[PREVIEW_IMAGE, PREVIEW_FRAME_SLIDER]) component_names: List[ComponentName] = [ 'source_file', 'target_file', @@ -64,7 +62,7 @@ def listen() -> None: for component_name in component_names: component = ui.get_component(component_name) if component: - component.change(update, inputs=PREVIEW_SLIDER, outputs=[PREVIEW_IMAGE, PREVIEW_SLIDER]) + component.change(update, inputs=PREVIEW_FRAME_SLIDER, outputs=[PREVIEW_IMAGE, PREVIEW_FRAME_SLIDER]) def update(frame_number: int = 0) -> Tuple[Update, Update]: @@ -72,14 +70,14 @@ def update(frame_number: int = 0) -> Tuple[Update, Update]: if is_image(roop.globals.target_path): target_frame = cv2.imread(roop.globals.target_path) preview_frame = get_preview_frame(target_frame) - return gradio.update(value=ui.normalize_frame(preview_frame), visible=True), gradio.update(value=0, maximum=1, visible=False) + return gradio.update(value=ui.normalize_frame(preview_frame)), gradio.update(value=0, maximum=1, visible=False) if is_video(roop.globals.target_path): roop.globals.reference_frame_number = frame_number video_frame_total = get_video_frame_total(roop.globals.target_path) temp_frame = get_video_frame(roop.globals.target_path, roop.globals.reference_frame_number) preview_frame = get_preview_frame(temp_frame) - return gradio.update(value=ui.normalize_frame(preview_frame), visible=True), gradio.update(maximum=video_frame_total, visible=True) - return gradio.update(value=None, visible=False), gradio.update(value=0, maximum=1, visible=False) + return gradio.update(value=ui.normalize_frame(preview_frame)), gradio.update(maximum=video_frame_total, visible=True) + return gradio.update(value=None), gradio.update(value=0, maximum=1, visible=False) def get_preview_frame(temp_frame: Frame) -> Frame: diff --git a/roop/uis/__components__/reference.py b/roop/uis/__components__/reference.py index 2b5b5fd3b..60d493618 100644 --- a/roop/uis/__components__/reference.py +++ b/roop/uis/__components__/reference.py @@ -22,7 +22,7 @@ def render() -> None: with gradio.Box(): reference_face_position_slider_args = { - 'label': 'reference_face_position', + 'label': 'REFERENCE FACE POSITION', 'value': roop.globals.reference_face_position, 'step': 1, 'maximum': 0 @@ -35,7 +35,7 @@ def render() -> None: reference_face_position_slider_args['maximum'] = get_faces_total(temp_frame) REFERENCE_FACE_POSITION_SLIDER = gradio.Slider(**reference_face_position_slider_args) SIMILAR_FACE_DISTANCE_SLIDER = gradio.Slider( - label='similar_face_distance', + label='SIMILAR FACE DISTANCE', value=roop.globals.similar_face_distance, maximum=2, step=0.05 @@ -48,7 +48,7 @@ def listen() -> None: SIMILAR_FACE_DISTANCE_SLIDER.change(update_similar_face_distance, inputs=SIMILAR_FACE_DISTANCE_SLIDER) component_names: List[ComponentName] = [ 'target_file', - 'preview_slider' + 'preview_frame_slider' ] for component_name in component_names: component = ui.get_component(component_name) diff --git a/roop/uis/__components__/settings.py b/roop/uis/__components__/settings.py index 6ef07e817..665e1ddfa 100644 --- a/roop/uis/__components__/settings.py +++ b/roop/uis/__components__/settings.py @@ -30,26 +30,26 @@ def render() -> None: with gradio.Column(): with gradio.Box(): FRAME_PROCESSORS_CHECKBOX_GROUP = gradio.CheckboxGroup( - label='frame_processors', + label='FRAME PROCESSORS', choices=sort_frame_processors(roop.globals.frame_processors), value=roop.globals.frame_processors ) ui.register_component('frame_processors_checkbox_group', FRAME_PROCESSORS_CHECKBOX_GROUP) with gradio.Box(): EXECUTION_PROVIDERS_CHECKBOX_GROUP = gradio.CheckboxGroup( - label='execution_providers', + label='EXECUTION PROVIDERS', choices=onnxruntime.get_available_providers(), value=roop.globals.execution_providers ) EXECUTION_THREAD_COUNT_SLIDER = gradio.Slider( - label='execution_thread_count', + label='EXECUTION THREAD COUNT', value=roop.globals.execution_thread_count, step=1, minimum=1, maximum=128 ) EXECUTION_QUEUE_COUNT_SLIDER = gradio.Slider( - label='execution_queue_count', + label='EXECUTION QUEUE COUNT', value=roop.globals.execution_queue_count, step=1, minimum=1, @@ -57,19 +57,19 @@ def render() -> None: ) with gradio.Box(): KEEP_FPS_CHECKBOX = gradio.Checkbox( - label='keep_fps', + label='KEEP FPS', value=roop.globals.keep_fps ) KEEP_TEMP_CHECKBOX = gradio.Checkbox( - label='keep_temp', + label='KEEP TEMP', value=roop.globals.keep_fps ) SKIP_AUDIO_CHECKBOX = gradio.Checkbox( - label='skip_audio', + label='SKIP AUDIO', value=roop.globals.skip_audio ) MANY_FACES_CHECKBOX = gradio.Checkbox( - label='many_faces', + label='MANY FACES', value=roop.globals.many_faces ) ui.register_component('many_faces_checkbox', MANY_FACES_CHECKBOX) diff --git a/roop/uis/__components__/source.py b/roop/uis/__components__/source.py index a7a2ab518..652f17bab 100644 --- a/roop/uis/__components__/source.py +++ b/roop/uis/__components__/source.py @@ -19,14 +19,14 @@ def render() -> None: SOURCE_FILE = gradio.File( file_count='single', file_types=['.png', '.jpg', '.jpeg', '.webp'], - label='source_path', + label='SOURCE', value=roop.globals.source_path if is_source_image else None ) ui.register_component('source_file', SOURCE_FILE) SOURCE_IMAGE = gradio.Image( - label='source_image', value=SOURCE_FILE.value['name'] if is_source_image else None, - visible=is_source_image + visible=is_source_image, + show_label=False ) diff --git a/roop/uis/__components__/target.py b/roop/uis/__components__/target.py index 97440d9a8..590c80892 100644 --- a/roop/uis/__components__/target.py +++ b/roop/uis/__components__/target.py @@ -23,20 +23,20 @@ def render() -> None: TARGET_FILE = gradio.File( file_count='single', file_types=['.png', '.jpg', '.jpeg', '.webp', '.mp4'], - label='target_path', + label='TARGET', value=roop.globals.target_path if is_target_image or is_target_video else None ) - ui.register_component('target_file', TARGET_FILE) TARGET_IMAGE = gradio.Image( - label='target_image', value=TARGET_FILE.value['name'] if is_target_image else None, - visible=is_target_image + visible=is_target_image, + show_label=False ) TARGET_VIDEO = gradio.Video( - label='target_video', value=TARGET_FILE.value['name'] if is_target_video else None, - visible=is_target_video + visible=is_target_video, + show_label=False ) + ui.register_component('target_file', TARGET_FILE) def listen() -> None: diff --git a/roop/uis/typing.py b/roop/uis/typing.py index bc8f5e66c..600ec2592 100644 --- a/roop/uis/typing.py +++ b/roop/uis/typing.py @@ -5,7 +5,7 @@ ComponentName = Literal[ 'source_file', 'target_file', - 'preview_slider', + 'preview_frame_slider', 'reference_face_position_slider', 'similar_face_distance_slider', 'frame_processors_checkbox_group',