Merge remote-tracking branch 'upstream/main'

# Conflicts:
#	webui.py
This commit is contained in:
Manuel Schmid
2023-12-30 14:40:49 +01:00
4 changed files with 43 additions and 17 deletions
+1 -1
View File
@@ -1 +1 @@
version = '2.1.855' version = '2.1.856'
+6 -2
View File
@@ -3,7 +3,7 @@ import gradio as gr
import modules.config import modules.config
def load_parameter_button_click(raw_prompt_txt): def load_parameter_button_click(raw_prompt_txt, is_generating):
loaded_parameter_dict = json.loads(raw_prompt_txt) loaded_parameter_dict = json.loads(raw_prompt_txt)
assert isinstance(loaded_parameter_dict, dict) assert isinstance(loaded_parameter_dict, dict)
@@ -136,7 +136,11 @@ def load_parameter_button_click(raw_prompt_txt):
results.append(gr.update()) results.append(gr.update())
results.append(gr.update()) results.append(gr.update())
results.append(gr.update(visible=True)) if is_generating:
results.append(gr.update())
else:
results.append(gr.update(visible=True))
results.append(gr.update(visible=False)) results.append(gr.update(visible=False))
for i in range(1, 6): for i in range(1, 6):
+22 -7
View File
@@ -44,13 +44,28 @@ def log(img, dic):
) )
js = ( js = (
"<script>" """<script>
"function to_clipboard(txt) { " function to_clipboard(txt) {
"txt = decodeURIComponent(txt);" txt = decodeURIComponent(txt);
"navigator.clipboard.writeText(txt);" if (navigator.clipboard && navigator.permissions) {
"alert('Copied to Clipboard!\\nPaste to prompt area to load parameters.\\nCurrent clipboard content is:\\n\\n' + txt);" navigator.clipboard.writeText(txt)
"}" } else {
"</script>" const textArea = document.createElement('textArea')
textArea.value = txt
textArea.style.width = 0
textArea.style.position = 'fixed'
textArea.style.left = '-999px'
textArea.style.top = '10px'
textArea.setAttribute('readonly', 'readonly')
document.body.appendChild(textArea)
textArea.select()
document.execCommand('copy')
document.body.removeChild(textArea)
}
alert('Copied to Clipboard!\\nPaste to prompt area to load parameters.\\nCurrent clipboard content is:\\n\\n' + txt);
}
</script>"""
) )
begin_part = f"<html><head><title>Fooocus Log {date_string}</title>{css_styles}</head><body>{js}<p>Fooocus Log {date_string} (private)</p>\n<p>All images are clean, without any hidden data/meta, and safe to share with others.</p><!--fooocus-log-split-->\n\n" begin_part = f"<html><head><title>Fooocus Log {date_string}</title>{css_styles}</head><body>{js}<p>Fooocus Log {date_string} (private)</p>\n<p>All images are clean, without any hidden data/meta, and safe to share with others.</p><!--fooocus-log-split-->\n\n"
+14 -7
View File
@@ -604,7 +604,9 @@ with shared.gradio_root:
ctrls += [outpaint_selections, inpaint_input_image, inpaint_additional_prompt] ctrls += [outpaint_selections, inpaint_input_image, inpaint_additional_prompt]
ctrls += ip_ctrls ctrls += ip_ctrls
def parse_meta(raw_prompt_txt): state_is_generating = gr.State(False)
def parse_meta(raw_prompt_txt, is_generating):
loaded_json = None loaded_json = None
try: try:
if '{' in raw_prompt_txt: if '{' in raw_prompt_txt:
@@ -616,13 +618,16 @@ with shared.gradio_root:
loaded_json = None loaded_json = None
if loaded_json is None: if loaded_json is None:
return gr.update(), gr.update(), gr.update(visible=False) if is_generating:
return gr.update(), gr.update(), gr.update()
else:
return gr.update(), gr.update(visible=True), gr.update(visible=False)
return json.dumps(loaded_json), gr.update(visible=False), gr.update(visible=True) return json.dumps(loaded_json), gr.update(visible=False), gr.update(visible=True)
prompt.input(parse_meta, inputs=prompt, outputs=[prompt, generate_button, load_parameter_button], queue=False, show_progress=False) prompt.input(parse_meta, inputs=[prompt, state_is_generating], outputs=[prompt, generate_button, load_parameter_button], queue=False, show_progress=False)
load_parameter_button.click(modules.meta_parser.load_parameter_button_click, inputs=prompt, outputs=[ load_parameter_button.click(modules.meta_parser.load_parameter_button_click, inputs=[prompt, state_is_generating], outputs=[
advanced_checkbox, advanced_checkbox,
image_number, image_number,
prompt, prompt,
@@ -649,12 +654,14 @@ with shared.gradio_root:
load_parameter_button load_parameter_button
] + lora_ctrls, queue=False, show_progress=False) ] + lora_ctrls, queue=False, show_progress=False)
generate_button.click(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=True, interactive=True), gr.update(visible=False, interactive=False), []), outputs=[stop_button, skip_button, generate_button, gallery]) \ generate_button.click(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=True, interactive=True), gr.update(visible=False, interactive=False), [], True),
outputs=[stop_button, skip_button, generate_button, gallery, state_is_generating]) \
.then(fn=refresh_seed, inputs=[seed_random, image_seed], outputs=image_seed) \ .then(fn=refresh_seed, inputs=[seed_random, image_seed], outputs=image_seed) \
.then(advanced_parameters.set_all_advanced_parameters, inputs=adps) \ .then(advanced_parameters.set_all_advanced_parameters, inputs=adps) \
.then(fn=get_task, inputs=ctrls, outputs=currentTask) \ .then(fn=get_task, inputs=ctrls, outputs=currentTask) \
.then(fn=generate_clicked, inputs=currentTask, outputs=[progress_html, progress_window, progress_gallery, gallery]) \ .then(fn=generate_clicked, inputs=currentTask, outputs=[progress_html, progress_window, progress_gallery, gallery]) \
.then(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=False), gr.update(visible=False)), outputs=[generate_button, stop_button, skip_button]) \ .then(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=False, interactive=False), gr.update(visible=False, interactive=False), False),
outputs=[generate_button, stop_button, skip_button, state_is_generating]) \
.then(fn=lambda: None, _js='playNotification').then(fn=lambda: None, _js='refresh_grid_delayed') .then(fn=lambda: None, _js='playNotification').then(fn=lambda: None, _js='refresh_grid_delayed')
def trigger_describe(mode, img): def trigger_describe(mode, img):
@@ -667,7 +674,7 @@ with shared.gradio_root:
return mode, ["Fooocus V2"] return mode, ["Fooocus V2"]
desc_btn.click(trigger_describe, inputs=[desc_method, desc_input_image], desc_btn.click(trigger_describe, inputs=[desc_method, desc_input_image],
outputs=[prompt, style_selections], show_progress=True, queue=False) outputs=[prompt, style_selections], show_progress=True, queue=True)
def dump_default_english_config(): def dump_default_english_config():
from modules.localization import dump_english_config from modules.localization import dump_english_config