[go: up one dir, main page]

Skip to content

Commit

Permalink
fix gradio (lllyasviel#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
lllyasviel authored Sep 20, 2023
1 parent b6752c7 commit 098d08c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fooocus_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '2.0.70'
version = '2.0.71'
7 changes: 6 additions & 1 deletion modules/async_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

buffer = []
outputs = []
default_image = None


def worker():
global buffer, outputs
global buffer, outputs, default_image

import time
import shared
Expand Down Expand Up @@ -45,6 +46,8 @@ def progressbar(number, text):
@torch.no_grad()
@torch.inference_mode()
def handler(task):
global default_image

prompt, negative_prompt, style_selections, performance_selction, \
aspect_ratios_selction, image_number, image_seed, sharpness, \
base_model_name, refiner_model_name, \
Expand Down Expand Up @@ -90,6 +93,7 @@ def handler(task):
progressbar(0, 'Image processing ...')
if current_tab == 'uov' and uov_method != flags.disabled and uov_input_image is not None:
uov_input_image = HWC3(uov_input_image)
default_image = uov_input_image
if 'vary' in uov_method:
if not image_is_generated_in_current_ui(uov_input_image, ui_width=width, ui_height=height):
uov_input_image = resize_image(uov_input_image, width=width, height=height)
Expand Down Expand Up @@ -167,6 +171,7 @@ def handler(task):
if current_tab == 'inpaint' and isinstance(inpaint_input_image, dict):
inpaint_image = inpaint_input_image['image']
inpaint_mask = inpaint_input_image['mask'][:, :, 0]
default_image = inpaint_image
if isinstance(inpaint_image, np.ndarray) and isinstance(inpaint_mask, np.ndarray) \
and (np.any(inpaint_mask > 127) or len(outpaint_selections) > 0):
if len(outpaint_selections) > 0:
Expand Down
5 changes: 3 additions & 2 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ def stop_clicked():
_js="(x) => {if(x){setTimeout(() => window.scrollTo({ top: window.scrollY + 500, behavior: 'smooth' }), 50);}else{setTimeout(() => window.scrollTo({ top: 0, behavior: 'smooth' }), 50);} return x}")

current_tab = gr.Textbox(value='uov', visible=False)
uov_tab.select(lambda: 'uov', outputs=current_tab, queue=False)
inpaint_tab.select(lambda: 'inpaint', outputs=current_tab, queue=False)

uov_tab.select(lambda: ['uov', worker.default_image], outputs=[current_tab, uov_input_image], queue=False)
inpaint_tab.select(lambda: ['inpaint', worker.default_image], outputs=[current_tab, inpaint_input_image], queue=False)

with gr.Column(scale=0.5, visible=False) as right_col:
with gr.Tab(label='Setting'):
Expand Down

0 comments on commit 098d08c

Please sign in to comment.