altered progressbar to not rely on first progress request coming after the job has started; may help with broken progressbar some people say they have
This commit is contained in:
parent
b273458d2d
commit
3f29aa791b
@ -24,15 +24,23 @@ onUiUpdate(function(){
|
|||||||
img2img_preview.style.height = img2img_gallery.clientHeight + "px"
|
img2img_preview.style.height = img2img_gallery.clientHeight + "px"
|
||||||
}
|
}
|
||||||
|
|
||||||
window.setTimeout(requestProgress, 500)
|
window.setTimeout(requestMoreProgress, 500)
|
||||||
});
|
});
|
||||||
mutationObserver.observe( progressbar, { childList:true, subtree:true })
|
mutationObserver.observe( progressbar, { childList:true, subtree:true })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function requestProgress(){
|
function requestMoreProgress(){
|
||||||
btn = gradioApp().getElementById("check_progress");
|
btn = gradioApp().getElementById("check_progress");
|
||||||
if(btn==null) return;
|
if(btn==null) return;
|
||||||
|
|
||||||
btn.click();
|
btn.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function requestProgress(){
|
||||||
|
btn = gradioApp().getElementById("check_progress_initial");
|
||||||
|
if(btn==null) return;
|
||||||
|
|
||||||
|
btn.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ function extract_image_from_gallery_extras(gallery){
|
|||||||
|
|
||||||
function submit(){
|
function submit(){
|
||||||
// this calls a function from progressbar.js
|
// this calls a function from progressbar.js
|
||||||
window.setTimeout(requestProgress, 500)
|
requestProgress()
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
for(var i=0;i<arguments.length;i++){
|
for(var i=0;i<arguments.length;i++){
|
||||||
|
@ -31,7 +31,7 @@ parser.add_argument("--embeddings-dir", type=str, default=os.path.join(script_pa
|
|||||||
parser.add_argument("--allow-code", action='store_true', help="allow custom script execution from webui")
|
parser.add_argument("--allow-code", action='store_true', help="allow custom script execution from webui")
|
||||||
parser.add_argument("--medvram", action='store_true', help="enable stable diffusion model optimizations for sacrificing a little speed for low VRM usage")
|
parser.add_argument("--medvram", action='store_true', help="enable stable diffusion model optimizations for sacrificing a little speed for low VRM usage")
|
||||||
parser.add_argument("--lowvram", action='store_true', help="enable stable diffusion model optimizations for sacrificing a lot of speed for very low VRM usage")
|
parser.add_argument("--lowvram", action='store_true', help="enable stable diffusion model optimizations for sacrificing a lot of speed for very low VRM usage")
|
||||||
parser.add_argument("--always-batch-cond-uncond", action='store_true', help="a workaround test; may help with speed if you use --lowvram")
|
parser.add_argument("--always-batch-cond-uncond", action='store_true', help="disables cond/uncond batching that is enabled to save memory with --medvram or --lowvram")
|
||||||
parser.add_argument("--unload-gfpgan", action='store_true', help="does not do anything.")
|
parser.add_argument("--unload-gfpgan", action='store_true', help="does not do anything.")
|
||||||
parser.add_argument("--precision", type=str, help="evaluate at this precision", choices=["full", "autocast"], default="autocast")
|
parser.add_argument("--precision", type=str, help="evaluate at this precision", choices=["full", "autocast"], default="autocast")
|
||||||
parser.add_argument("--share", action='store_true', help="use share=True for gradio and make the UI accessible through their site (doesn't work for me but you might have better luck)")
|
parser.add_argument("--share", action='store_true', help="use share=True for gradio and make the UI accessible through their site (doesn't work for me but you might have better luck)")
|
||||||
|
@ -159,7 +159,6 @@ def wrap_gradio_call(func):
|
|||||||
|
|
||||||
|
|
||||||
def check_progress_call():
|
def check_progress_call():
|
||||||
|
|
||||||
if shared.state.job_count == 0:
|
if shared.state.job_count == 0:
|
||||||
return "", gr_show(False), gr_show(False)
|
return "", gr_show(False), gr_show(False)
|
||||||
|
|
||||||
@ -196,6 +195,12 @@ def check_progress_call():
|
|||||||
return f"<span style='display: none'>{time.time()}</span><p>{progressbar}</p>", preview_visibility, image
|
return f"<span style='display: none'>{time.time()}</span><p>{progressbar}</p>", preview_visibility, image
|
||||||
|
|
||||||
|
|
||||||
|
def check_progress_call_initial():
|
||||||
|
shared.state.job_count = -1
|
||||||
|
|
||||||
|
return check_progress_call()
|
||||||
|
|
||||||
|
|
||||||
def roll_artist(prompt):
|
def roll_artist(prompt):
|
||||||
allowed_cats = set([x for x in shared.artist_db.categories() if len(opts.random_artist_categories)==0 or x in opts.random_artist_categories])
|
allowed_cats = set([x for x in shared.artist_db.categories() if len(opts.random_artist_categories)==0 or x in opts.random_artist_categories])
|
||||||
artist = random.choice([x for x in shared.artist_db.artists if x.category in allowed_cats])
|
artist = random.choice([x for x in shared.artist_db.artists if x.category in allowed_cats])
|
||||||
@ -303,14 +308,30 @@ def create_toprow(is_img2img):
|
|||||||
prompt_style_apply = gr.Button('Apply style', elem_id="style_apply")
|
prompt_style_apply = gr.Button('Apply style', elem_id="style_apply")
|
||||||
save_style = gr.Button('Create style', elem_id="style_create")
|
save_style = gr.Button('Create style', elem_id="style_create")
|
||||||
|
|
||||||
check_progress = gr.Button('Check progress', elem_id="check_progress", visible=False)
|
return prompt, roll, prompt_style, negative_prompt, prompt_style2, submit, interrogate, prompt_style_apply, save_style
|
||||||
|
|
||||||
return prompt, roll, prompt_style, negative_prompt, prompt_style2, submit, interrogate, prompt_style_apply, save_style, check_progress
|
|
||||||
|
def setup_progressbar(progressbar, preview):
|
||||||
|
check_progress = gr.Button('Check progress', elem_id="check_progress", visible=False)
|
||||||
|
check_progress.click(
|
||||||
|
fn=check_progress_call,
|
||||||
|
show_progress=False,
|
||||||
|
inputs=[],
|
||||||
|
outputs=[progressbar, preview, preview],
|
||||||
|
)
|
||||||
|
|
||||||
|
check_progress_initial = gr.Button('Check progress (first)', elem_id="check_progress_initial", visible=False)
|
||||||
|
check_progress_initial.click(
|
||||||
|
fn=check_progress_call_initial,
|
||||||
|
show_progress=False,
|
||||||
|
inputs=[],
|
||||||
|
outputs=[progressbar, preview, preview],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
||||||
with gr.Blocks(analytics_enabled=False) as txt2img_interface:
|
with gr.Blocks(analytics_enabled=False) as txt2img_interface:
|
||||||
txt2img_prompt, roll, txt2img_prompt_style, txt2img_negative_prompt, txt2img_prompt_style2, submit, _, txt2img_prompt_style_apply, txt2img_save_style, check_progress = create_toprow(is_img2img=False)
|
txt2img_prompt, roll, txt2img_prompt_style, txt2img_negative_prompt, txt2img_prompt_style2, submit, _, txt2img_prompt_style_apply, txt2img_save_style = create_toprow(is_img2img=False)
|
||||||
|
|
||||||
with gr.Row().style(equal_height=False):
|
with gr.Row().style(equal_height=False):
|
||||||
with gr.Column(variant='panel'):
|
with gr.Column(variant='panel'):
|
||||||
@ -343,6 +364,8 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
|||||||
txt2img_preview = gr.Image(elem_id='txt2img_preview', visible=False)
|
txt2img_preview = gr.Image(elem_id='txt2img_preview', visible=False)
|
||||||
txt2img_gallery = gr.Gallery(label='Output', elem_id='txt2img_gallery').style(grid=4)
|
txt2img_gallery = gr.Gallery(label='Output', elem_id='txt2img_gallery').style(grid=4)
|
||||||
|
|
||||||
|
setup_progressbar(progressbar, txt2img_preview)
|
||||||
|
|
||||||
with gr.Group():
|
with gr.Group():
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
save = gr.Button('Save')
|
save = gr.Button('Save')
|
||||||
@ -379,19 +402,13 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
|||||||
txt2img_gallery,
|
txt2img_gallery,
|
||||||
generation_info,
|
generation_info,
|
||||||
html_info
|
html_info
|
||||||
]
|
],
|
||||||
|
show_progress=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
txt2img_prompt.submit(**txt2img_args)
|
txt2img_prompt.submit(**txt2img_args)
|
||||||
submit.click(**txt2img_args)
|
submit.click(**txt2img_args)
|
||||||
|
|
||||||
check_progress.click(
|
|
||||||
fn=check_progress_call,
|
|
||||||
show_progress=False,
|
|
||||||
inputs=[],
|
|
||||||
outputs=[progressbar, txt2img_preview, txt2img_preview],
|
|
||||||
)
|
|
||||||
|
|
||||||
interrupt.click(
|
interrupt.click(
|
||||||
fn=lambda: shared.state.interrupt(),
|
fn=lambda: shared.state.interrupt(),
|
||||||
inputs=[],
|
inputs=[],
|
||||||
@ -424,7 +441,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
|||||||
)
|
)
|
||||||
|
|
||||||
with gr.Blocks(analytics_enabled=False) as img2img_interface:
|
with gr.Blocks(analytics_enabled=False) as img2img_interface:
|
||||||
img2img_prompt, roll, img2img_prompt_style, img2img_negative_prompt, img2img_prompt_style2, submit, img2img_interrogate, img2img_prompt_style_apply, img2img_save_style, check_progress = create_toprow(is_img2img=True)
|
img2img_prompt, roll, img2img_prompt_style, img2img_negative_prompt, img2img_prompt_style2, submit, img2img_interrogate, img2img_prompt_style_apply, img2img_save_style = create_toprow(is_img2img=True)
|
||||||
|
|
||||||
with gr.Row().style(equal_height=False):
|
with gr.Row().style(equal_height=False):
|
||||||
with gr.Column(variant='panel'):
|
with gr.Column(variant='panel'):
|
||||||
@ -480,6 +497,8 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
|||||||
img2img_preview = gr.Image(elem_id='img2img_preview', visible=False)
|
img2img_preview = gr.Image(elem_id='img2img_preview', visible=False)
|
||||||
img2img_gallery = gr.Gallery(label='Output', elem_id='img2img_gallery').style(grid=4)
|
img2img_gallery = gr.Gallery(label='Output', elem_id='img2img_gallery').style(grid=4)
|
||||||
|
|
||||||
|
setup_progressbar(progressbar, img2img_preview)
|
||||||
|
|
||||||
with gr.Group():
|
with gr.Group():
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
save = gr.Button('Save')
|
save = gr.Button('Save')
|
||||||
@ -584,7 +603,8 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
|||||||
img2img_gallery,
|
img2img_gallery,
|
||||||
generation_info,
|
generation_info,
|
||||||
html_info
|
html_info
|
||||||
]
|
],
|
||||||
|
show_progress=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
img2img_prompt.submit(**img2img_args)
|
img2img_prompt.submit(**img2img_args)
|
||||||
@ -596,13 +616,6 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
|||||||
outputs=[img2img_prompt],
|
outputs=[img2img_prompt],
|
||||||
)
|
)
|
||||||
|
|
||||||
check_progress.click(
|
|
||||||
fn=check_progress_call,
|
|
||||||
show_progress=False,
|
|
||||||
inputs=[],
|
|
||||||
outputs=[progressbar, img2img_preview, img2img_preview],
|
|
||||||
)
|
|
||||||
|
|
||||||
interrupt.click(
|
interrupt.click(
|
||||||
fn=lambda: shared.state.interrupt(),
|
fn=lambda: shared.state.interrupt(),
|
||||||
inputs=[],
|
inputs=[],
|
||||||
@ -611,7 +624,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
|||||||
|
|
||||||
save.click(
|
save.click(
|
||||||
fn=wrap_gradio_call(save_files),
|
fn=wrap_gradio_call(save_files),
|
||||||
_js = "(x, y, z) => [x, y, selected_gallery_index()]",
|
_js="(x, y, z) => [x, y, selected_gallery_index()]",
|
||||||
inputs=[
|
inputs=[
|
||||||
generation_info,
|
generation_info,
|
||||||
img2img_gallery,
|
img2img_gallery,
|
||||||
|
Loading…
Reference in New Issue
Block a user