Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -58,7 +58,7 @@ def clear_fn(*args):
|
|
58 |
def run_model(prompt, model_idx):
|
59 |
return send_it_idx(model_idx)(prompt)
|
60 |
|
61 |
-
|
62 |
primary_prompt = gr.Textbox(label="Prompt", value="")
|
63 |
run = gr.Button("Run")
|
64 |
clear_btn = gr.Button("Clear")
|
@@ -71,24 +71,38 @@ def build_ui():
|
|
71 |
end_box = gr.Number(visible=False)
|
72 |
tog_box = gr.Textbox(value=0, visible=False)
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
primary_prompt,
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
def run_model(prompt, model_idx):
|
59 |
return send_it_idx(model_idx)(prompt)
|
60 |
|
61 |
+
with gr.Blocks(title="SD Models") as my_interface:
|
62 |
primary_prompt = gr.Textbox(label="Prompt", value="")
|
63 |
run = gr.Button("Run")
|
64 |
clear_btn = gr.Button("Clear")
|
|
|
71 |
end_box = gr.Number(visible=False)
|
72 |
tog_box = gr.Textbox(value=0, visible=False)
|
73 |
|
74 |
+
# Define event handlers within the Blocks context
|
75 |
+
def main_function(prompt):
|
76 |
+
return {idx: run_model(prompt, idx) for idx in range(1, len(models) + 1)}
|
77 |
+
|
78 |
+
run.click(
|
79 |
+
fn=main_function,
|
80 |
+
inputs=[primary_prompt],
|
81 |
+
outputs=list(sd_outputs.values()),
|
82 |
+
concurrency_limit=10
|
83 |
+
)
|
84 |
+
|
85 |
+
clear_btn.click(
|
86 |
+
fn=clear_fn,
|
87 |
+
inputs=None,
|
88 |
+
outputs=[primary_prompt] + list(sd_outputs.values()),
|
89 |
+
concurrency_limit=10
|
90 |
+
)
|
91 |
+
|
92 |
+
start_box.change(
|
93 |
+
fn=all_task_end,
|
94 |
+
inputs=[start_box, end_box],
|
95 |
+
outputs=[start_box, tog_box],
|
96 |
+
every=1
|
97 |
+
)
|
98 |
+
|
99 |
+
primary_prompt.submit(all_task_start, inputs=None, outputs=[start_box, end_box, tog_box])
|
100 |
+
run.click(all_task_start, inputs=None, outputs=[start_box, end_box, tog_box])
|
101 |
+
tog_box.change(
|
102 |
+
fn=clear_it,
|
103 |
+
inputs=tog_box,
|
104 |
+
outputs=tog_box
|
105 |
+
)
|
106 |
+
|
107 |
+
# Launch the interface
|
108 |
+
my_interface.launch(max_threads=10)
|