Spaces:
Paused
Paused
Update frontend/webui/ui.py
Browse files- frontend/webui/ui.py +26 -0
frontend/webui/ui.py
CHANGED
@@ -9,6 +9,32 @@ from paths import FastStableDiffusionPaths
|
|
9 |
from state import get_settings
|
10 |
|
11 |
app_settings = get_settings()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
|
14 |
def _get_footer_message() -> str:
|
|
|
9 |
from state import get_settings
|
10 |
|
11 |
app_settings = get_settings()
|
12 |
+
import gradio as gr
|
13 |
+
|
14 |
+
# Start with the models you want to load (these could come from your config)
|
15 |
+
model_list = ["model-a", "model-b", "model-c"]
|
16 |
+
|
17 |
+
def update_model_array(text_input):
|
18 |
+
# Split lines, remove empty strings, strip whitespace
|
19 |
+
updated = [line.strip() for line in text_input.split("\n") if line.strip()]
|
20 |
+
return gr.Dropdown.update(choices=updated, value=updated[0] if updated else None), "\n".join(updated)
|
21 |
+
|
22 |
+
def start_webui(share=False):
|
23 |
+
with gr.Blocks(title="Model Selector") as demo:
|
24 |
+
gr.Markdown("## Model Selector with Editable List")
|
25 |
+
|
26 |
+
model_dropdown = gr.Dropdown(choices=model_list, label="Select Model", value=model_list[0])
|
27 |
+
model_text_area = gr.Textbox(value="\n".join(model_list), lines=10, label="Edit Model List")
|
28 |
+
|
29 |
+
update_button = gr.Button("Update Dropdown")
|
30 |
+
|
31 |
+
update_button.click(
|
32 |
+
fn=update_model_array,
|
33 |
+
inputs=model_text_area,
|
34 |
+
outputs=[model_dropdown, model_text_area],
|
35 |
+
)
|
36 |
+
|
37 |
+
demo.launch(share=share)
|
38 |
|
39 |
|
40 |
def _get_footer_message() -> str:
|