Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -75,12 +75,6 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
|
|
75 |
return image, seed, f"Prompt used: {final_prompt}\nNegative prompt used: {full_negative_prompt}"
|
76 |
|
77 |
|
78 |
-
examples = [
|
79 |
-
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
80 |
-
"An astronaut riding a green horse",
|
81 |
-
"A delicious ceviche cheesecake slice",
|
82 |
-
]
|
83 |
-
|
84 |
css = """
|
85 |
#col-container {
|
86 |
margin: 0 auto;
|
@@ -89,111 +83,121 @@ css = """
|
|
89 |
#run-button {
|
90 |
width: 100%;
|
91 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
"""
|
93 |
|
94 |
with gr.Blocks(css=css) as demo:
|
95 |
|
96 |
-
with gr.
|
97 |
-
gr.
|
|
|
98 |
|
99 |
-
|
100 |
-
|
101 |
|
102 |
-
|
103 |
-
|
104 |
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
with gr.Tabs() as tabs:
|
110 |
-
with gr.TabItem("Prompt Input") as prompt_tab:
|
111 |
-
prompt = gr.Textbox(
|
112 |
-
label="Prompt",
|
113 |
-
show_label=False,
|
114 |
max_lines=1,
|
115 |
-
placeholder="Enter
|
116 |
-
|
117 |
-
)
|
118 |
-
prompt_tab.select(lambda: "Prompt Input", inputs=None, outputs=active_tab)
|
119 |
-
|
120 |
-
with gr.TabItem("Tag Selection") as tag_tab:
|
121 |
-
# Tag selection checkboxes for each tag group
|
122 |
-
selected_participant_tags = gr.CheckboxGroup(choices=list(participant_tags.keys()), label="Participant Tags")
|
123 |
-
selected_tribe_tags = gr.CheckboxGroup(choices=list(tribe_tags.keys()), label="Tribe Tags")
|
124 |
-
selected_skin_tone_tags = gr.CheckboxGroup(choices=list(skin_tone_tags.keys()), label="Skin Tone Tags")
|
125 |
-
selected_body_type_tags = gr.CheckboxGroup(choices=list(body_type_tags.keys()), label="Body Type Tags")
|
126 |
-
selected_tattoo_tags = gr.CheckboxGroup(choices=list(tattoo_tags.keys()), label="Tattoo Tags")
|
127 |
-
selected_piercing_tags = gr.CheckboxGroup(choices=list(piercing_tags.keys()), label="Piercing Tags")
|
128 |
-
selected_expression_tags = gr.CheckboxGroup(choices=list(expression_tags.keys()), label="Expression Tags")
|
129 |
-
selected_eye_tags = gr.CheckboxGroup(choices=list(eye_tags.keys()), label="Eye Tags")
|
130 |
-
selected_hair_style_tags = gr.CheckboxGroup(choices=list(hair_style_tags.keys()), label="Hair Style Tags")
|
131 |
-
selected_position_tags = gr.CheckboxGroup(choices=list(position_tags.keys()), label="Position Tags")
|
132 |
-
selected_fetish_tags = gr.CheckboxGroup(choices=list(fetish_tags.keys()), label="Fetish Tags")
|
133 |
-
selected_location_tags = gr.CheckboxGroup(choices=list(location_tags.keys()), label="Location Tags")
|
134 |
-
selected_camera_tags = gr.CheckboxGroup(choices=list(camera_tags.keys()), label="Camera Tags")
|
135 |
-
selected_atmosphere_tags = gr.CheckboxGroup(choices=list(atmosphere_tags.keys()), label="Atmosphere Tags")
|
136 |
-
tag_tab.select(lambda: "Tag Selection", inputs=None, outputs=active_tab)
|
137 |
-
|
138 |
-
# Full-width "Run" button
|
139 |
-
run_button = gr.Button("Run", scale=0, elem_id="run-button")
|
140 |
-
|
141 |
-
with gr.Accordion("Advanced Settings", open=False):
|
142 |
-
negative_prompt = gr.Textbox(
|
143 |
-
label="Negative prompt",
|
144 |
-
max_lines=1,
|
145 |
-
placeholder="Enter a negative prompt",
|
146 |
-
visible=True,
|
147 |
-
)
|
148 |
-
|
149 |
-
seed = gr.Slider(
|
150 |
-
label="Seed",
|
151 |
-
minimum=0,
|
152 |
-
maximum=MAX_SEED,
|
153 |
-
step=1,
|
154 |
-
value=0,
|
155 |
-
)
|
156 |
-
|
157 |
-
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
158 |
-
|
159 |
-
with gr.Row():
|
160 |
-
width = gr.Slider(
|
161 |
-
label="Width",
|
162 |
-
minimum=256,
|
163 |
-
maximum=MAX_IMAGE_SIZE,
|
164 |
-
step=32,
|
165 |
-
value=1024,
|
166 |
)
|
167 |
|
168 |
-
|
169 |
-
label="
|
170 |
-
minimum=
|
171 |
-
maximum=
|
172 |
-
step=32,
|
173 |
-
value=1024,
|
174 |
-
)
|
175 |
-
|
176 |
-
with gr.Row():
|
177 |
-
guidance_scale = gr.Slider(
|
178 |
-
label="Guidance scale",
|
179 |
-
minimum=0.0,
|
180 |
-
maximum=10.0,
|
181 |
-
step=0.1,
|
182 |
-
value=7,
|
183 |
-
)
|
184 |
-
|
185 |
-
num_inference_steps = gr.Slider(
|
186 |
-
label="Number of inference steps",
|
187 |
-
minimum=1,
|
188 |
-
maximum=50,
|
189 |
step=1,
|
190 |
-
value=
|
191 |
)
|
192 |
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
|
198 |
run_button.click(
|
199 |
infer,
|
@@ -205,4 +209,4 @@ with gr.Blocks(css=css) as demo:
|
|
205 |
outputs=[result, seed, prompt_info]
|
206 |
)
|
207 |
|
208 |
-
demo.queue().launch()
|
|
|
75 |
return image, seed, f"Prompt used: {final_prompt}\nNegative prompt used: {full_negative_prompt}"
|
76 |
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
css = """
|
79 |
#col-container {
|
80 |
margin: 0 auto;
|
|
|
83 |
#run-button {
|
84 |
width: 100%;
|
85 |
}
|
86 |
+
#left-column {
|
87 |
+
width: 50%;
|
88 |
+
display: inline-block;
|
89 |
+
padding-right: 20px;
|
90 |
+
}
|
91 |
+
#right-column {
|
92 |
+
width: 50%;
|
93 |
+
display: inline-block;
|
94 |
+
vertical-align: top;
|
95 |
+
}
|
96 |
"""
|
97 |
|
98 |
with gr.Blocks(css=css) as demo:
|
99 |
|
100 |
+
with gr.Row():
|
101 |
+
with gr.Column(elem_id="left-column"):
|
102 |
+
gr.Markdown("""# Text-to-Image Gradio Template""")
|
103 |
|
104 |
+
# Display result image at the top
|
105 |
+
result = gr.Image(label="Result", show_label=False)
|
106 |
|
107 |
+
# Add a textbox to display the prompts used for generation
|
108 |
+
prompt_info = gr.Textbox(label="Prompts Used", lines=3, interactive=False)
|
109 |
|
110 |
+
# Advanced Settings and Run Button
|
111 |
+
with gr.Accordion("Advanced Settings", open=False):
|
112 |
+
negative_prompt = gr.Textbox(
|
113 |
+
label="Negative prompt",
|
|
|
|
|
|
|
|
|
|
|
114 |
max_lines=1,
|
115 |
+
placeholder="Enter a negative prompt",
|
116 |
+
visible=True,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
)
|
118 |
|
119 |
+
seed = gr.Slider(
|
120 |
+
label="Seed",
|
121 |
+
minimum=0,
|
122 |
+
maximum=MAX_SEED,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
step=1,
|
124 |
+
value=0,
|
125 |
)
|
126 |
|
127 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
128 |
+
|
129 |
+
with gr.Row():
|
130 |
+
width = gr.Slider(
|
131 |
+
label="Width",
|
132 |
+
minimum=256,
|
133 |
+
maximum=MAX_IMAGE_SIZE,
|
134 |
+
step=32,
|
135 |
+
value=1024,
|
136 |
+
)
|
137 |
+
|
138 |
+
height = gr.Slider(
|
139 |
+
label="Height",
|
140 |
+
minimum=256,
|
141 |
+
maximum=MAX_IMAGE_SIZE,
|
142 |
+
step=32,
|
143 |
+
value=1024,
|
144 |
+
)
|
145 |
+
|
146 |
+
with gr.Row():
|
147 |
+
guidance_scale = gr.Slider(
|
148 |
+
label="Guidance scale",
|
149 |
+
minimum=0.0,
|
150 |
+
maximum=10.0,
|
151 |
+
step=0.1,
|
152 |
+
value=7,
|
153 |
+
)
|
154 |
+
|
155 |
+
num_inference_steps = gr.Slider(
|
156 |
+
label="Number of inference steps",
|
157 |
+
minimum=1,
|
158 |
+
maximum=50,
|
159 |
+
step=1,
|
160 |
+
value=35,
|
161 |
+
)
|
162 |
+
|
163 |
+
# Full-width "Run" button
|
164 |
+
run_button = gr.Button("Run", scale=0, elem_id="run-button")
|
165 |
+
|
166 |
+
with gr.Column(elem_id="right-column"):
|
167 |
+
gr.Markdown("### Prompt / Tag Input")
|
168 |
+
|
169 |
+
# State to track active tab
|
170 |
+
active_tab = gr.State("Prompt Input")
|
171 |
+
|
172 |
+
# Tabbed interface to select either Prompt or Tags
|
173 |
+
with gr.Tabs() as tabs:
|
174 |
+
with gr.TabItem("Prompt Input") as prompt_tab:
|
175 |
+
prompt = gr.Textbox(
|
176 |
+
label="Prompt",
|
177 |
+
show_label=False,
|
178 |
+
max_lines=1,
|
179 |
+
placeholder="Enter your prompt",
|
180 |
+
container=False,
|
181 |
+
)
|
182 |
+
prompt_tab.select(lambda: "Prompt Input", inputs=None, outputs=active_tab)
|
183 |
+
|
184 |
+
with gr.TabItem("Tag Selection") as tag_tab:
|
185 |
+
# Tag selection checkboxes for each tag group
|
186 |
+
selected_participant_tags = gr.CheckboxGroup(choices=list(participant_tags.keys()), label="Participant Tags")
|
187 |
+
selected_tribe_tags = gr.CheckboxGroup(choices=list(tribe_tags.keys()), label="Tribe Tags")
|
188 |
+
selected_skin_tone_tags = gr.CheckboxGroup(choices=list(skin_tone_tags.keys()), label="Skin Tone Tags")
|
189 |
+
selected_body_type_tags = gr.CheckboxGroup(choices=list(body_type_tags.keys()), label="Body Type Tags")
|
190 |
+
selected_tattoo_tags = gr.CheckboxGroup(choices=list(tattoo_tags.keys()), label="Tattoo Tags")
|
191 |
+
selected_piercing_tags = gr.CheckboxGroup(choices=list(piercing_tags.keys()), label="Piercing Tags")
|
192 |
+
selected_expression_tags = gr.CheckboxGroup(choices=list(expression_tags.keys()), label="Expression Tags")
|
193 |
+
selected_eye_tags = gr.CheckboxGroup(choices=list(eye_tags.keys()), label="Eye Tags")
|
194 |
+
selected_hair_style_tags = gr.CheckboxGroup(choices=list(hair_style_tags.keys()), label="Hair Style Tags")
|
195 |
+
selected_position_tags = gr.CheckboxGroup(choices=list(position_tags.keys()), label="Position Tags")
|
196 |
+
selected_fetish_tags = gr.CheckboxGroup(choices=list(fetish_tags.keys()), label="Fetish Tags")
|
197 |
+
selected_location_tags = gr.CheckboxGroup(choices=list(location_tags.keys()), label="Location Tags")
|
198 |
+
selected_camera_tags = gr.CheckboxGroup(choices=list(camera_tags.keys()), label="Camera Tags")
|
199 |
+
selected_atmosphere_tags = gr.CheckboxGroup(choices=list(atmosphere_tags.keys()), label="Atmosphere Tags")
|
200 |
+
tag_tab.select(lambda: "Tag Selection", inputs=None, outputs=active_tab)
|
201 |
|
202 |
run_button.click(
|
203 |
infer,
|
|
|
209 |
outputs=[result, seed, prompt_info]
|
210 |
)
|
211 |
|
212 |
+
demo.queue().launch()
|