Spaces:
Sleeping
Sleeping
Brian Watson
commited on
Commit
·
3af2576
1
Parent(s):
6ed4ca6
Update app.py
Browse files
app.py
CHANGED
@@ -69,52 +69,61 @@ def make_dropdown_searchable(dropdown_id):
|
|
69 |
|
70 |
css = """"""
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
]
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
css = """"""
|
71 |
|
72 |
+
iface = gr.Interface(
|
73 |
+
fn=text_it,
|
74 |
+
inputs="text",
|
75 |
+
outputs="text",
|
76 |
+
css=css,
|
77 |
+
capture_session=True
|
78 |
+
)
|
79 |
+
|
80 |
+
make_dropdown_searchable(iface.inputs[0].component_id) # Make the model dropdown searchable
|
81 |
+
|
82 |
+
input_text = iface.inputs[0]
|
83 |
+
model_name1 = gr.inputs.Dropdown(
|
84 |
+
label="Choose Model",
|
85 |
+
choices=[m["name"] for m in models],
|
86 |
+
type="index",
|
87 |
+
value=current_model["name"],
|
88 |
+
interactive=True,
|
89 |
+
)
|
90 |
+
see_prompts = gr.outputs.Button(label="Generate Prompts")
|
91 |
+
run = gr.outputs.Button(label="Generate Images", type="primary")
|
92 |
+
outputs = [
|
93 |
+
gr.outputs.Image(label=current_model["name"]),
|
94 |
+
gr.outputs.Image(label=current_model["name"]),
|
95 |
+
gr.outputs.Image(label=current_model["name"]),
|
96 |
+
gr.outputs.Image(label=current_model["name"]),
|
97 |
+
gr.outputs.Image(label=current_model["name"]),
|
98 |
+
gr.outputs.Image(label=current_model["name"]),
|
99 |
+
gr.outputs.Image(label=current_model["name"]),
|
100 |
+
gr.outputs.Image(label=current_model["name"]),
|
101 |
+
]
|
102 |
+
magic_inputs = [
|
103 |
+
gr.inputs.Textbox(lines=4),
|
104 |
+
gr.inputs.Textbox(lines=4),
|
105 |
+
gr.inputs.Textbox(lines=4),
|
106 |
+
gr.inputs.Textbox(lines=4),
|
107 |
+
gr.inputs.Textbox(lines=4),
|
108 |
+
gr.inputs.Textbox(lines=4),
|
109 |
+
gr.inputs.Textbox(lines=4),
|
110 |
+
]
|
111 |
+
|
112 |
+
iface.inputs = [input_text, model_name1, see_prompts, run] + magic_inputs
|
113 |
+
iface.outputs = outputs
|
114 |
+
|
115 |
+
|
116 |
+
def generate_prompts():
|
117 |
+
prompts = text_it(input_text.value)
|
118 |
+
for i, magic_input in enumerate(magic_inputs):
|
119 |
+
magic_input.update(prompts[i])
|
120 |
+
|
121 |
+
|
122 |
+
def generate_images():
|
123 |
+
return [send_it(magic_inputs[i].value, model_name1.value) for i in range(len(magic_inputs))]
|
124 |
+
|
125 |
+
|
126 |
+
see_prompts.set_action(generate_prompts)
|
127 |
+
run.set_action(generate_images)
|
128 |
+
|
129 |
+
iface.launch(inline=True, show=True)
|