From 1d1a4a3ebd2ea06fa396be670272ee9659e5f66c Mon Sep 17 00:00:00 2001 From: Manuel Schmid <9307310+mashb1t@users.noreply.github.com> Date: Sun, 26 May 2024 11:40:15 +0200 Subject: [PATCH] feat: add inpaint color picker (#2997) Workaround as tool color-sketch applies changes directly to the image canvas and not the mask canvas. Color picker is not correctly implemented in Gradio 3.41.2 => does always get displayed as separate containers and not merged with other elements --- css/style.css | 6 +++++- webui.py | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/css/style.css b/css/style.css index b5f7a448..b82cf930 100644 --- a/css/style.css +++ b/css/style.css @@ -72,7 +72,7 @@ progress::after { .progress-bar span { text-align: right; - width: 200px; + width: 215px; } .type_row{ @@ -399,4 +399,8 @@ progress::after { text-align: center; border-radius: 5px 5px 0px 0px; display: none; /* remove this to enable tooltip in preview image */ +} + +#inpaint_brush_color input[type=color]{ + background: none; } \ No newline at end of file diff --git a/webui.py b/webui.py index 25e57222..ae0bc89f 100644 --- a/webui.py +++ b/webui.py @@ -524,13 +524,20 @@ with shared.gradio_root: inpaint_mask_upload_checkbox = gr.Checkbox(label='Enable Mask Upload', value=False) invert_mask_checkbox = gr.Checkbox(label='Invert Mask', value=False) + inpaint_mask_color = gr.ColorPicker(label='Inpaint brush color', value='#FFFFFF', elem_id='inpaint_brush_color') + inpaint_ctrls = [debugging_inpaint_preprocessor, inpaint_disable_initial_latent, inpaint_engine, inpaint_strength, inpaint_respective_field, inpaint_mask_upload_checkbox, invert_mask_checkbox, inpaint_erode_or_dilate] inpaint_mask_upload_checkbox.change(lambda x: gr.update(visible=x), - inputs=inpaint_mask_upload_checkbox, - outputs=inpaint_mask_image, queue=False, show_progress=False) + inputs=inpaint_mask_upload_checkbox, + outputs=inpaint_mask_image, queue=False, + show_progress=False) + + inpaint_mask_color.change(lambda x: gr.update(brush_color=x), inputs=inpaint_mask_color, + outputs=inpaint_input_image, + queue=False, show_progress=False) with gr.Tab(label='FreeU'): freeu_enabled = gr.Checkbox(label='Enabled', value=False)