Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -154,88 +154,78 @@ body {
|
|
154 |
|
155 |
# --- Gradio Interface ---
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
with gr.
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
with
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
seed = gr.Number(label="Seed", value=-1)
|
226 |
|
227 |
text_button.click(flip_text, inputs=[prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed], outputs=image_output)
|
228 |
-
|
229 |
-
|
230 |
-
tabs = gr.Tabs()
|
231 |
-
with tabs:
|
232 |
-
with gr.TabItem("Welcome Screen"):
|
233 |
-
welcome_screen
|
234 |
-
with gr.TabItem("Main Generation Screen"):
|
235 |
-
demo
|
236 |
-
|
237 |
-
# Connect Welcome Screen to Generation Screen
|
238 |
-
start_button.click(fn=lambda: tabs.set_selected("Main Generation Screen"))
|
239 |
|
240 |
# Launch the Gradio app
|
241 |
-
|
|
|
154 |
|
155 |
# --- Gradio Interface ---
|
156 |
|
157 |
+
with gr.Blocks(css=css) as demo:
|
158 |
+
state = gr.State(value="Welcome Screen") # To control the visibility of tabs
|
159 |
+
|
160 |
+
with gr.Tabs() as tabs:
|
161 |
+
with gr.TabItem("Welcome Screen"):
|
162 |
+
with gr.Row():
|
163 |
+
logo = gr.Image(
|
164 |
+
value="http://disneypixaraigenerator.com/wp-content/uploads/2023/12/cropped-android-chrome-512x512-1.png",
|
165 |
+
elem_id="logo",
|
166 |
+
height=200,
|
167 |
+
width=300
|
168 |
+
)
|
169 |
+
|
170 |
+
with gr.Row():
|
171 |
+
title = gr.Markdown("<h1 style='text-align: center;'>Disney Pixar AI Generator</h1>", elem_id="title")
|
172 |
+
|
173 |
+
with gr.Row():
|
174 |
+
start_button = gr.Button("Get Started", variant='primary', elem_id="start-button")
|
175 |
+
|
176 |
+
with gr.TabItem("Main Generation Screen"):
|
177 |
+
with gr.Row():
|
178 |
+
gr.Markdown("<h1 style='text-align: center;'>Create Your Disney Pixar AI Poster</h1>", elem_id="title")
|
179 |
+
|
180 |
+
with gr.Row(elem_id="image-output-container"):
|
181 |
+
image_output = gr.Image(
|
182 |
+
value="https://cdn-uploads.huggingface.co/production/uploads/noauth/XWJyh9DhMGXrzyRJk7SfP.png",
|
183 |
+
label="Generated Image",
|
184 |
+
elem_id="image-output"
|
185 |
+
)
|
186 |
+
|
187 |
+
with gr.Row(elem_id="settings"):
|
188 |
+
with gr.Column(scale=1, min_width=300, elem_classes="setting-group"):
|
189 |
+
prompt = gr.Textbox(
|
190 |
+
"space warrior, beautiful, female, ultrarealistic, soft lighting, 8k",
|
191 |
+
placeholder="Enter your prompt here...",
|
192 |
+
show_label=False,
|
193 |
+
lines=3,
|
194 |
+
elem_id="prompt-input"
|
195 |
+
)
|
196 |
+
negative_prompt = gr.Textbox(
|
197 |
+
placeholder="Enter negative prompts (optional)...",
|
198 |
+
show_label=False,
|
199 |
+
lines=3,
|
200 |
+
value="3d, cartoon, anime, (deformed eyes, nose, ears, nose), bad anatomy, ugly"
|
201 |
+
)
|
202 |
+
text_button = gr.Button("Generate", variant='primary', elem_id="generate")
|
203 |
+
|
204 |
+
with gr.Column(scale=1, min_width=300, elem_classes="setting-group"):
|
205 |
+
model = gr.Dropdown(
|
206 |
+
interactive=True,
|
207 |
+
value="sd_xl_base_1.0.safetensors [be9edd61]",
|
208 |
+
show_label=True,
|
209 |
+
label="Model",
|
210 |
+
choices=prodia_client.list_models()
|
211 |
+
)
|
212 |
+
sampler = gr.Dropdown(
|
213 |
+
value="DPM++ 2M Karras",
|
214 |
+
show_label=True,
|
215 |
+
label="Sampling Method",
|
216 |
+
choices=prodia_client.list_samplers()
|
217 |
+
)
|
218 |
+
steps = gr.Slider(label="Sampling Steps", minimum=1, maximum=25, value=20, step=1)
|
219 |
+
|
220 |
+
with gr.Column(scale=1, min_width=300, elem_classes="setting-group"):
|
221 |
+
width = gr.Slider(label="Width", minimum=512, maximum=1536, value=1024, step=8)
|
222 |
+
height = gr.Slider(label="Height", minimum=512, maximum=1536, value=1024, step=8)
|
223 |
+
cfg_scale = gr.Slider(label="CFG Scale", minimum=1, maximum=20, value=7, step=1)
|
224 |
+
seed = gr.Number(label="Seed", value=-1)
|
|
|
225 |
|
226 |
text_button.click(flip_text, inputs=[prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed], outputs=image_output)
|
227 |
+
start_button.click(fn=lambda: "Main Generation Screen", inputs=None, outputs=state)
|
228 |
+
state.change(fn=lambda x: gr.update(visible=(x == "Main Generation Screen")), inputs=state, outputs=tabs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
|
230 |
# Launch the Gradio app
|
231 |
+
demo.launch(max_threads=128)
|