Skip to content

Override model with frozen settings #13868

Closed Answered by rkfg
rkfg asked this question in Q&A
Discussion options

You must be logged in to vote

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:

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)
…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rkfg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant