fix gradio (#444)
This commit is contained in:
parent
b6752c74e3
commit
098d08cd22
|
|
@ -1 +1 @@
|
||||||
version = '2.0.70'
|
version = '2.0.71'
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,11 @@ import torch
|
||||||
|
|
||||||
buffer = []
|
buffer = []
|
||||||
outputs = []
|
outputs = []
|
||||||
|
default_image = None
|
||||||
|
|
||||||
|
|
||||||
def worker():
|
def worker():
|
||||||
global buffer, outputs
|
global buffer, outputs, default_image
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import shared
|
import shared
|
||||||
|
|
@ -45,6 +46,8 @@ def worker():
|
||||||
@torch.no_grad()
|
@torch.no_grad()
|
||||||
@torch.inference_mode()
|
@torch.inference_mode()
|
||||||
def handler(task):
|
def handler(task):
|
||||||
|
global default_image
|
||||||
|
|
||||||
prompt, negative_prompt, style_selections, performance_selction, \
|
prompt, negative_prompt, style_selections, performance_selction, \
|
||||||
aspect_ratios_selction, image_number, image_seed, sharpness, \
|
aspect_ratios_selction, image_number, image_seed, sharpness, \
|
||||||
base_model_name, refiner_model_name, \
|
base_model_name, refiner_model_name, \
|
||||||
|
|
@ -90,6 +93,7 @@ def worker():
|
||||||
progressbar(0, 'Image processing ...')
|
progressbar(0, 'Image processing ...')
|
||||||
if current_tab == 'uov' and uov_method != flags.disabled and uov_input_image is not None:
|
if current_tab == 'uov' and uov_method != flags.disabled and uov_input_image is not None:
|
||||||
uov_input_image = HWC3(uov_input_image)
|
uov_input_image = HWC3(uov_input_image)
|
||||||
|
default_image = uov_input_image
|
||||||
if 'vary' in uov_method:
|
if 'vary' in uov_method:
|
||||||
if not image_is_generated_in_current_ui(uov_input_image, ui_width=width, ui_height=height):
|
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)
|
uov_input_image = resize_image(uov_input_image, width=width, height=height)
|
||||||
|
|
@ -167,6 +171,7 @@ def worker():
|
||||||
if current_tab == 'inpaint' and isinstance(inpaint_input_image, dict):
|
if current_tab == 'inpaint' and isinstance(inpaint_input_image, dict):
|
||||||
inpaint_image = inpaint_input_image['image']
|
inpaint_image = inpaint_input_image['image']
|
||||||
inpaint_mask = inpaint_input_image['mask'][:, :, 0]
|
inpaint_mask = inpaint_input_image['mask'][:, :, 0]
|
||||||
|
default_image = inpaint_image
|
||||||
if isinstance(inpaint_image, np.ndarray) and isinstance(inpaint_mask, np.ndarray) \
|
if isinstance(inpaint_image, np.ndarray) and isinstance(inpaint_mask, np.ndarray) \
|
||||||
and (np.any(inpaint_mask > 127) or len(outpaint_selections) > 0):
|
and (np.any(inpaint_mask > 127) or len(outpaint_selections) > 0):
|
||||||
if len(outpaint_selections) > 0:
|
if len(outpaint_selections) > 0:
|
||||||
|
|
|
||||||
5
webui.py
5
webui.py
|
|
@ -79,8 +79,9 @@ with shared.gradio_root:
|
||||||
_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}")
|
_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)
|
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.Column(scale=0.5, visible=False) as right_col:
|
||||||
with gr.Tab(label='Setting'):
|
with gr.Tab(label='Setting'):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue