Spaces:
Runtime error
Runtime error
Brian Watson
commited on
Commit
·
6ed4ca6
1
Parent(s):
cddbc8a
Update app.py
Browse files
app.py
CHANGED
@@ -26,7 +26,7 @@ def text_it(inputs, text_gen=text_gen):
|
|
26 |
def set_model(current_model_name):
|
27 |
global current_model
|
28 |
current_model = next((m for m in models if m["name"] == current_model_name), None)
|
29 |
-
return gr.
|
30 |
|
31 |
|
32 |
def send_it(inputs, model_choice):
|
@@ -64,43 +64,57 @@ def make_dropdown_searchable(dropdown_id):
|
|
64 |
makeDropdownSearchable("{dropdown_id}");
|
65 |
</script>
|
66 |
"""
|
67 |
-
return gr.HTML(script)
|
68 |
|
69 |
|
70 |
css = """"""
|
71 |
|
72 |
-
with gr.Interface(
|
73 |
-
make_dropdown_searchable(iface.inputs[
|
74 |
|
75 |
input_text = iface.inputs[0]
|
76 |
-
model_name1 =
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
outputs[
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
run.set_action(generate_images)
|
101 |
|
102 |
-
model_name1.choices = [m["name"] for m in models]
|
103 |
-
model_name1.default = current_model["name"]
|
104 |
-
model_name1.changed(set_model)
|
105 |
-
|
106 |
iface.launch(inline=True, show=True)
|
|
|
26 |
def set_model(current_model_name):
|
27 |
global current_model
|
28 |
current_model = next((m for m in models if m["name"] == current_model_name), None)
|
29 |
+
return gr.outputs.Label(current_model["name"])
|
30 |
|
31 |
|
32 |
def send_it(inputs, model_choice):
|
|
|
64 |
makeDropdownSearchable("{dropdown_id}");
|
65 |
</script>
|
66 |
"""
|
67 |
+
return gr.outputs.HTML(script)
|
68 |
|
69 |
|
70 |
css = """"""
|
71 |
|
72 |
+
with gr.Interface(text_it, inputs="text", outputs="text", css=css, capture_session=True) as iface:
|
73 |
+
make_dropdown_searchable(iface.inputs[0].component_id) # Make the model dropdown searchable
|
74 |
|
75 |
input_text = iface.inputs[0]
|
76 |
+
model_name1 = gr.inputs.Dropdown(
|
77 |
+
label="Choose Model",
|
78 |
+
choices=[m["name"] for m in models],
|
79 |
+
type="index",
|
80 |
+
value=current_model["name"],
|
81 |
+
interactive=True,
|
82 |
+
)
|
83 |
+
see_prompts = gr.outputs.Button(label="Generate Prompts")
|
84 |
+
run = gr.outputs.Button(label="Generate Images", type="primary")
|
85 |
+
outputs = [
|
86 |
+
gr.outputs.Image(label=current_model["name"]),
|
87 |
+
gr.outputs.Image(label=current_model["name"]),
|
88 |
+
gr.outputs.Image(label=current_model["name"]),
|
89 |
+
gr.outputs.Image(label=current_model["name"]),
|
90 |
+
gr.outputs.Image(label=current_model["name"]),
|
91 |
+
gr.outputs.Image(label=current_model["name"]),
|
92 |
+
gr.outputs.Image(label=current_model["name"]),
|
93 |
+
gr.outputs.Image(label=current_model["name"]),
|
94 |
+
]
|
95 |
+
magic_inputs = [
|
96 |
+
gr.inputs.Textbox(lines=4),
|
97 |
+
gr.inputs.Textbox(lines=4),
|
98 |
+
gr.inputs.Textbox(lines=4),
|
99 |
+
gr.inputs.Textbox(lines=4),
|
100 |
+
gr.inputs.Textbox(lines=4),
|
101 |
+
gr.inputs.Textbox(lines=4),
|
102 |
+
gr.inputs.Textbox(lines=4),
|
103 |
+
gr.inputs.Textbox(lines=4),
|
104 |
+
]
|
105 |
+
|
106 |
+
iface.inputs = [input_text, model_name1, see_prompts, run] + magic_inputs
|
107 |
+
iface.outputs = outputs
|
108 |
+
|
109 |
+
def generate_prompts():
|
110 |
+
prompts = text_it(input_text.value)
|
111 |
+
for i, magic_input in enumerate(magic_inputs):
|
112 |
+
magic_input.update(prompts[i])
|
113 |
+
|
114 |
+
def generate_images():
|
115 |
+
return [send_it(magic_inputs[i].value, model_name1.value) for i in range(len(magic_inputs))]
|
116 |
+
|
117 |
+
see_prompts.set_action(generate_prompts)
|
118 |
run.set_action(generate_images)
|
119 |
|
|
|
|
|
|
|
|
|
120 |
iface.launch(inline=True, show=True)
|