-
I run a semi-private instance for friends with frozen settings so that no one can accidentally or maliciously break things. However, this doesn't allow swapping models for just one generation. I changed the code to allow overriding settings and wrote an extra network extension that adds a tag like Long story short, I need to add the If this is too big of a problem, maybe there's another way to run a public web UI instance with most of the settings blocked but still allow people to use different models, parameters and other stuff without interfering with each other? Basically apply the parameters (clip skip etc.), load the desired model, generate, return results, revert the parameters back to some default that I set, then process the next job and so on. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
After much struggle I found a way to connect back to Python from JS, and that is via events. I create a hidden text input, set the value and emulate the input event because otherwise Gradio doesn't update the internal value. In short, the code is like this: In def update(x: str, dd):
params = dict([e.split(': ')[0], e.split(': ')[1]] for e in dd)
parts = x.split('|')
params["Model"] = parts[1]
params["Model hash"] = parts[0]
return gr.Dropdown.update(value=[e + ': ' + params[e] for e in params.keys()], choices=params)
control = gr.Textbox(elem_id="override_settings_control", visible=False)
control.input(fn=update, inputs=[control, dropdown], outputs=[dropdown]) Not very foolproof but okay. It merges the value in form of "onclick": '"' + f"""var ta = get_uiCurrentTabContent().querySelector('#override_settings_control textarea');
ta.value = '{checkpoint.shorthash}|{checkpoint.name_for_extra}';
ta.dispatchEvent(new Event('input'));
get_uiCurrentTabContent().querySelector('.extra-networks > .tab-nav > button:nth-child(1)').click()""" + '"', It finds the textbox from above, sets the value and emulates user input, after that it switches to the Goal achieved but at what cost... |
Beta Was this translation helpful? Give feedback.
After much struggle I found a way to connect back to Python from JS, and that is via events. I create a hidden text input, set the value and emulate the input event because otherwise Gradio doesn't update the internal value. In short, the code is like this:
In
ui.py
,create_override_settings_dropdown
I added this: