Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[alternative fix] can't load webui if selected wrong extra option in ui #15121

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import math

import gradio as gr
from modules import scripts, shared, ui_components, ui_settings, infotext_utils
from modules import scripts, shared, ui_components, ui_settings, infotext_utils, errors
from modules.ui_components import FormColumn


Expand Down Expand Up @@ -42,7 +42,11 @@ def ui(self, is_img2img):
setting_name = extra_options[index]

with FormColumn():
comp = ui_settings.create_setting_component(setting_name)
try:
comp = ui_settings.create_setting_component(setting_name)
except KeyError:
errors.report(f"Can't add extra options for {setting_name} in ui")
continue

self.comps.append(comp)
self.setting_names.append(setting_name)
Expand Down
4 changes: 3 additions & 1 deletion modules/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ def create_ui():

parameters_copypaste.reset()

settings = ui_settings.UiSettings()
settings.register_settings()

scripts.scripts_current = scripts.scripts_txt2img
scripts.scripts_txt2img.initialize_scripts(is_img2img=False)

Expand Down Expand Up @@ -1116,7 +1119,6 @@ def get_textual_inversion_template_names():
loadsave = ui_loadsave.UiLoadsave(cmd_opts.ui_config_file)
ui_settings_from_file = loadsave.ui_settings.copy()

settings = ui_settings.UiSettings()
settings.create_ui(loadsave, dummy_component)

interfaces = [
Expand Down
4 changes: 3 additions & 1 deletion modules/ui_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ def run_settings_single(self, value, key):

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 = {}
self.dummy_component = dummy_component

shared.settings_components = self.component_dict

script_callbacks.ui_settings_callback()
opts.reorder()

with gr.Blocks(analytics_enabled=False) as settings_interface:
Expand Down
Loading