Brian Watson commited on
Commit
3af2576
·
1 Parent(s): 6ed4ca6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -49
app.py CHANGED
@@ -69,52 +69,61 @@ def make_dropdown_searchable(dropdown_id):
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)
 
 
 
 
 
 
 
 
 
 
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)