Gradio 4 + WebUI 1.10

This commit is contained in:
layerdiffusion
2024-07-26 08:51:34 -07:00
parent e95333c556
commit e26abf87ec
201 changed files with 7562 additions and 4834 deletions

View File

@@ -1,7 +1,8 @@
import gradio as gr
from modules import ui_common, shared, script_callbacks, scripts, sd_models, sysinfo, timer
from modules.call_queue import wrap_gradio_call
from modules import ui_common, shared, script_callbacks, scripts, sd_models, sysinfo, timer, shared_items
from modules.call_queue import wrap_gradio_call_no_job
from modules.options import options_section
from modules.shared import opts
from modules.ui_components import FormRow
from modules.ui_gradio_extensions import reload_javascript
@@ -98,6 +99,9 @@ class UiSettings:
return get_value_for_setting(key), opts.dumpjson()
def register_settings(self):
script_callbacks.ui_settings_callback()
def create_ui(self, loadsave, dummy_component):
self.components = []
self.component_dict = {}
@@ -105,7 +109,11 @@ class UiSettings:
shared.settings_components = self.component_dict
script_callbacks.ui_settings_callback()
# we add this as late as possible so that scripts have already registered their callbacks
opts.data_labels.update(options_section(('callbacks', "Callbacks", "system"), {
**shared_items.callbacks_order_settings(),
}))
opts.reorder()
with gr.Blocks(analytics_enabled=False) as settings_interface:
@@ -287,7 +295,7 @@ class UiSettings:
def add_functionality(self, demo):
self.submit.click(
fn=wrap_gradio_call(lambda *args: self.run_settings(*args), extra_outputs=[gr.update()]),
fn=wrap_gradio_call_no_job(lambda *args: self.run_settings(*args), extra_outputs=[gr.update()]),
inputs=self.components,
outputs=[self.text_settings, self.result],
)
@@ -303,30 +311,20 @@ class UiSettings:
methods = [component.change]
for method in methods:
handler = method(
method(
fn=lambda value, k=k: self.run_settings_single(value, key=k),
inputs=[component],
outputs=[component, self.text_settings],
show_progress=False,
)
script_callbacks.setting_updated_event_subscriber_chain(
handler=handler,
component=component,
setting_name=k,
)
button_set_checkpoint = gr.Button('Change checkpoint', elem_id='change_checkpoint', visible=False)
handler = button_set_checkpoint.click(
button_set_checkpoint.click(
fn=lambda value, _: self.run_settings_single(value, key='sd_model_checkpoint'),
_js="function(v){ var res = desiredCheckpointName; desiredCheckpointName = ''; return [res || v, null]; }",
inputs=[self.component_dict['sd_model_checkpoint'], self.dummy_component],
outputs=[self.component_dict['sd_model_checkpoint'], self.text_settings],
)
script_callbacks.setting_updated_event_subscriber_chain(
handler=handler,
component=self.component_dict['sd_model_checkpoint'],
setting_name="sd_model_checkpoint"
)
component_keys = [k for k in opts.data_labels.keys() if k in self.component_dict]