Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -159,98 +159,368 @@ examples = [
|
|
159 |
"Ghibli style robot farmer tending to floating rice paddies in the sky, wearing a traditional straw hat with advanced sensors. Its gentle movements create ripples in the water as it plants glowing rice seedlings. Flying fish leap between the terraced fields, leaving trails of sparkles in their wake, while future Tokyo's spires gleam in the distance. [trigger]"
|
160 |
]
|
161 |
|
|
|
162 |
css = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
footer {
|
164 |
-
|
165 |
}
|
166 |
-
"""
|
167 |
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
minimum=0,
|
184 |
-
maximum=MAX_SEED,
|
185 |
-
step=1,
|
186 |
-
value=42,
|
187 |
-
)
|
188 |
-
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
189 |
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
minimum=256,
|
194 |
-
maximum=MAX_IMAGE_SIZE,
|
195 |
-
step=32,
|
196 |
-
value=1024,
|
197 |
-
)
|
198 |
-
height = gr.Slider(
|
199 |
-
label="Height",
|
200 |
-
minimum=256,
|
201 |
-
maximum=MAX_IMAGE_SIZE,
|
202 |
-
step=32,
|
203 |
-
value=768,
|
204 |
-
)
|
205 |
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
-
gr.
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
seed_text = gr.Number(label="Used Seed", value=42)
|
237 |
|
238 |
-
with gr.
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
|
|
|
|
|
|
|
|
247 |
|
248 |
# Event handlers
|
249 |
def refresh_gallery():
|
250 |
return load_generated_images()
|
251 |
|
252 |
def clear_output():
|
253 |
-
return "", gr.update(value=None), seed
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
|
255 |
refresh_btn.click(
|
256 |
fn=refresh_gallery,
|
@@ -261,10 +531,15 @@ with gr.Blocks(css=css, analytics_enabled=False) as demo:
|
|
261 |
clear_button.click(
|
262 |
fn=clear_output,
|
263 |
inputs=None,
|
264 |
-
outputs=[prompt, result, seed_text]
|
265 |
)
|
266 |
-
|
|
|
267 |
run_button.click(
|
|
|
|
|
|
|
|
|
268 |
fn=inference,
|
269 |
inputs=[
|
270 |
prompt,
|
@@ -277,9 +552,17 @@ with gr.Blocks(css=css, analytics_enabled=False) as demo:
|
|
277 |
lora_scale,
|
278 |
],
|
279 |
outputs=[result, seed_text, generated_gallery],
|
|
|
|
|
|
|
|
|
280 |
)
|
281 |
|
282 |
prompt.submit(
|
|
|
|
|
|
|
|
|
283 |
fn=inference,
|
284 |
inputs=[
|
285 |
prompt,
|
@@ -292,11 +575,37 @@ with gr.Blocks(css=css, analytics_enabled=False) as demo:
|
|
292 |
lora_scale,
|
293 |
],
|
294 |
outputs=[result, seed_text, generated_gallery],
|
|
|
|
|
|
|
|
|
295 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
|
297 |
# Launch with fallback options
|
298 |
try:
|
299 |
-
demo.queue(concurrency_count=1, max_size=
|
300 |
demo.launch(debug=True, show_api=False)
|
301 |
except Exception as e:
|
302 |
print(f"Error during launch: {e}")
|
|
|
159 |
"Ghibli style robot farmer tending to floating rice paddies in the sky, wearing a traditional straw hat with advanced sensors. Its gentle movements create ripples in the water as it plants glowing rice seedlings. Flying fish leap between the terraced fields, leaving trails of sparkles in their wake, while future Tokyo's spires gleam in the distance. [trigger]"
|
160 |
]
|
161 |
|
162 |
+
# Enhanced CSS for a more visually refined UI
|
163 |
css = """
|
164 |
+
:root {
|
165 |
+
--primary-color: #6a92cc;
|
166 |
+
--primary-hover: #557ab8;
|
167 |
+
--secondary-color: #f4c062;
|
168 |
+
--background-color: #f7f9fc;
|
169 |
+
--panel-background: #ffffff;
|
170 |
+
--text-color: #333333;
|
171 |
+
--border-radius: 12px;
|
172 |
+
--shadow: 0 4px 12px rgba(0,0,0,0.08);
|
173 |
+
--font-main: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
|
174 |
+
}
|
175 |
+
|
176 |
+
body {
|
177 |
+
background-color: var(--background-color);
|
178 |
+
font-family: var(--font-main);
|
179 |
+
}
|
180 |
+
|
181 |
+
.gradio-container {
|
182 |
+
margin: 0 auto;
|
183 |
+
max-width: 1200px !important;
|
184 |
+
}
|
185 |
+
|
186 |
+
.main-header {
|
187 |
+
text-align: center;
|
188 |
+
padding: 2rem 1rem 1rem;
|
189 |
+
background: linear-gradient(90deg, #6a92cc 0%, #8f7fc8 100%);
|
190 |
+
color: white;
|
191 |
+
margin-bottom: 2rem;
|
192 |
+
border-radius: var(--border-radius);
|
193 |
+
box-shadow: var(--shadow);
|
194 |
+
}
|
195 |
+
|
196 |
+
.main-header h1 {
|
197 |
+
font-size: 2.5rem;
|
198 |
+
margin-bottom: 0.5rem;
|
199 |
+
font-weight: 700;
|
200 |
+
text-shadow: 0 2px 4px rgba(0,0,0,0.2);
|
201 |
+
}
|
202 |
+
|
203 |
+
.main-header p {
|
204 |
+
font-size: 1rem;
|
205 |
+
margin-bottom: 0.5rem;
|
206 |
+
opacity: 0.9;
|
207 |
+
}
|
208 |
+
|
209 |
+
.main-header a {
|
210 |
+
color: var(--secondary-color);
|
211 |
+
text-decoration: none;
|
212 |
+
font-weight: 600;
|
213 |
+
transition: all 0.2s ease;
|
214 |
+
}
|
215 |
+
|
216 |
+
.main-header a:hover {
|
217 |
+
text-decoration: underline;
|
218 |
+
opacity: 0.9;
|
219 |
+
}
|
220 |
+
|
221 |
+
.container {
|
222 |
+
background-color: var(--panel-background);
|
223 |
+
padding: 1.5rem;
|
224 |
+
border-radius: var(--border-radius);
|
225 |
+
box-shadow: var(--shadow);
|
226 |
+
margin-bottom: 1.5rem;
|
227 |
+
}
|
228 |
+
|
229 |
+
button.primary {
|
230 |
+
background: var(--primary-color) !important;
|
231 |
+
border: none !important;
|
232 |
+
color: white !important;
|
233 |
+
padding: 10px 20px !important;
|
234 |
+
border-radius: 8px !important;
|
235 |
+
font-weight: 600 !important;
|
236 |
+
box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
|
237 |
+
transition: all 0.2s ease !important;
|
238 |
+
}
|
239 |
+
|
240 |
+
button.primary:hover {
|
241 |
+
background: var(--primary-hover) !important;
|
242 |
+
transform: translateY(-2px) !important;
|
243 |
+
box-shadow: 0 4px 8px rgba(0,0,0,0.15) !important;
|
244 |
+
}
|
245 |
+
|
246 |
+
button.secondary {
|
247 |
+
background: white !important;
|
248 |
+
border: 1px solid #ddd !important;
|
249 |
+
color: var(--text-color) !important;
|
250 |
+
padding: 10px 20px !important;
|
251 |
+
border-radius: 8px !important;
|
252 |
+
font-weight: 500 !important;
|
253 |
+
box-shadow: 0 2px 5px rgba(0,0,0,0.05) !important;
|
254 |
+
transition: all 0.2s ease !important;
|
255 |
+
}
|
256 |
+
|
257 |
+
button.secondary:hover {
|
258 |
+
background: #f5f5f5 !important;
|
259 |
+
transform: translateY(-2px) !important;
|
260 |
+
}
|
261 |
+
|
262 |
+
.gr-box {
|
263 |
+
border-radius: var(--border-radius) !important;
|
264 |
+
border: 1px solid #e0e0e0 !important;
|
265 |
+
}
|
266 |
+
|
267 |
+
.gr-panel {
|
268 |
+
border-radius: var(--border-radius) !important;
|
269 |
+
}
|
270 |
+
|
271 |
+
.gr-input {
|
272 |
+
border-radius: 8px !important;
|
273 |
+
border: 1px solid #ddd !important;
|
274 |
+
padding: 12px !important;
|
275 |
+
}
|
276 |
+
|
277 |
+
.gr-form {
|
278 |
+
border-radius: var(--border-radius) !important;
|
279 |
+
background-color: var(--panel-background) !important;
|
280 |
+
}
|
281 |
+
|
282 |
+
.gr-accordion {
|
283 |
+
border-radius: var(--border-radius) !important;
|
284 |
+
overflow: hidden !important;
|
285 |
+
}
|
286 |
+
|
287 |
+
.gr-button {
|
288 |
+
border-radius: 8px !important;
|
289 |
+
}
|
290 |
+
|
291 |
+
.gallery-item {
|
292 |
+
border-radius: var(--border-radius) !important;
|
293 |
+
transition: all 0.3s ease !important;
|
294 |
+
}
|
295 |
+
|
296 |
+
.gallery-item:hover {
|
297 |
+
transform: scale(1.02) !important;
|
298 |
+
box-shadow: 0 6px 15px rgba(0,0,0,0.1) !important;
|
299 |
+
}
|
300 |
+
|
301 |
+
.tabs {
|
302 |
+
border-radius: var(--border-radius) !important;
|
303 |
+
overflow: hidden !important;
|
304 |
+
}
|
305 |
+
|
306 |
footer {
|
307 |
+
display: none !important;
|
308 |
}
|
|
|
309 |
|
310 |
+
.settings-accordion legend span {
|
311 |
+
font-weight: 600 !important;
|
312 |
+
}
|
313 |
|
314 |
+
.example-prompt {
|
315 |
+
font-size: 0.9rem;
|
316 |
+
color: #555;
|
317 |
+
padding: 8px;
|
318 |
+
background: #f5f7fa;
|
319 |
+
border-radius: 6px;
|
320 |
+
border-left: 3px solid var(--primary-color);
|
321 |
+
margin-bottom: 8px;
|
322 |
+
cursor: pointer;
|
323 |
+
transition: all 0.2s;
|
324 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
|
326 |
+
.example-prompt:hover {
|
327 |
+
background: #eef2f8;
|
328 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
|
330 |
+
/* Status indicators */
|
331 |
+
.status-generating {
|
332 |
+
color: #ffa200;
|
333 |
+
font-weight: 500;
|
334 |
+
display: flex;
|
335 |
+
align-items: center;
|
336 |
+
gap: 8px;
|
337 |
+
}
|
338 |
+
|
339 |
+
.status-generating::before {
|
340 |
+
content: "";
|
341 |
+
display: inline-block;
|
342 |
+
width: 12px;
|
343 |
+
height: 12px;
|
344 |
+
border-radius: 50%;
|
345 |
+
background-color: #ffa200;
|
346 |
+
animation: pulse 1.5s infinite;
|
347 |
+
}
|
348 |
+
|
349 |
+
.status-complete {
|
350 |
+
color: #00c853;
|
351 |
+
font-weight: 500;
|
352 |
+
display: flex;
|
353 |
+
align-items: center;
|
354 |
+
gap: 8px;
|
355 |
+
}
|
356 |
+
|
357 |
+
.status-complete::before {
|
358 |
+
content: "";
|
359 |
+
display: inline-block;
|
360 |
+
width: 12px;
|
361 |
+
height: 12px;
|
362 |
+
border-radius: 50%;
|
363 |
+
background-color: #00c853;
|
364 |
+
}
|
365 |
+
|
366 |
+
@keyframes pulse {
|
367 |
+
0% {
|
368 |
+
opacity: 0.6;
|
369 |
+
}
|
370 |
+
50% {
|
371 |
+
opacity: 1;
|
372 |
+
}
|
373 |
+
100% {
|
374 |
+
opacity: 0.6;
|
375 |
+
}
|
376 |
+
}
|
377 |
+
|
378 |
+
/* Custom accordions and tabs styling */
|
379 |
+
.gr-accordion-title {
|
380 |
+
font-weight: 600 !important;
|
381 |
+
color: var(--text-color) !important;
|
382 |
+
}
|
383 |
+
|
384 |
+
.tabs button {
|
385 |
+
font-weight: 500 !important;
|
386 |
+
padding: 10px 16px !important;
|
387 |
+
}
|
388 |
+
|
389 |
+
.tabs button.selected {
|
390 |
+
font-weight: 600 !important;
|
391 |
+
color: var(--primary-color) !important;
|
392 |
+
background: rgba(106, 146, 204, 0.1) !important;
|
393 |
+
}
|
394 |
+
|
395 |
+
/* Improve slider appearance */
|
396 |
+
.gr-slider-container {
|
397 |
+
padding: 10px 0 !important;
|
398 |
+
}
|
399 |
+
|
400 |
+
/* Enhanced Markdown content */
|
401 |
+
.gr-prose h3 {
|
402 |
+
font-weight: 600 !important;
|
403 |
+
color: var(--primary-color) !important;
|
404 |
+
margin-bottom: 1rem !important;
|
405 |
+
}
|
406 |
+
"""
|
407 |
+
|
408 |
+
# Use a cleaner, more visual UI configuration
|
409 |
+
with gr.Blocks(css=css, analytics_enabled=False, theme="soft") as demo:
|
410 |
+
with gr.Column():
|
411 |
+
# Custom header with improved styling
|
412 |
+
gr.HTML('''
|
413 |
+
<div class="main-header">
|
414 |
+
<h1>✨ FLUX Ghibli LoRA Generator ✨</h1>
|
415 |
+
<p>Community: <a href="https://discord.gg/openfreeai" target="_blank">https://discord.gg/openfreeai</a></p>
|
416 |
+
</div>
|
417 |
+
''')
|
418 |
+
|
419 |
+
with gr.Row():
|
420 |
+
with gr.Column(scale=3):
|
421 |
+
with gr.Group(elem_classes="container"):
|
422 |
+
prompt = gr.Textbox(
|
423 |
+
label="Enter your imagination",
|
424 |
+
placeholder="Describe your Ghibli-style image here...",
|
425 |
+
lines=3
|
426 |
)
|
427 |
+
|
428 |
+
with gr.Row():
|
429 |
+
run_button = gr.Button("✨ Generate Image", elem_classes="primary")
|
430 |
+
clear_button = gr.Button("Clear", elem_classes="secondary")
|
431 |
+
|
432 |
+
with gr.Accordion("Advanced Settings", open=False, elem_classes="settings-accordion"):
|
433 |
+
with gr.Row():
|
434 |
+
seed = gr.Slider(
|
435 |
+
label="Seed",
|
436 |
+
minimum=0,
|
437 |
+
maximum=MAX_SEED,
|
438 |
+
step=1,
|
439 |
+
value=42,
|
440 |
+
)
|
441 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
442 |
+
|
443 |
+
with gr.Row():
|
444 |
+
width = gr.Slider(
|
445 |
+
label="Width",
|
446 |
+
minimum=256,
|
447 |
+
maximum=MAX_IMAGE_SIZE,
|
448 |
+
step=32,
|
449 |
+
value=1024,
|
450 |
+
)
|
451 |
+
height = gr.Slider(
|
452 |
+
label="Height",
|
453 |
+
minimum=256,
|
454 |
+
maximum=MAX_IMAGE_SIZE,
|
455 |
+
step=32,
|
456 |
+
value=768,
|
457 |
+
)
|
458 |
+
|
459 |
+
with gr.Row():
|
460 |
+
guidance_scale = gr.Slider(
|
461 |
+
label="Guidance scale",
|
462 |
+
minimum=0.0,
|
463 |
+
maximum=10.0,
|
464 |
+
step=0.1,
|
465 |
+
value=3.5,
|
466 |
+
)
|
467 |
+
|
468 |
+
with gr.Row():
|
469 |
+
num_inference_steps = gr.Slider(
|
470 |
+
label="Steps",
|
471 |
+
minimum=1,
|
472 |
+
maximum=50,
|
473 |
+
step=1,
|
474 |
+
value=30,
|
475 |
+
)
|
476 |
+
lora_scale = gr.Slider(
|
477 |
+
label="LoRA scale",
|
478 |
+
minimum=0.0,
|
479 |
+
maximum=1.0,
|
480 |
+
step=0.1,
|
481 |
+
value=1.0,
|
482 |
+
)
|
483 |
+
|
484 |
+
with gr.Group(elem_classes="container"):
|
485 |
+
gr.Markdown("### ✨ Example Prompts")
|
486 |
+
# Create HTML for examples manually
|
487 |
+
examples_html = '\n'.join([f'<div class="example-prompt">{example}</div>' for example in examples])
|
488 |
+
example_container = gr.HTML(examples_html)
|
489 |
|
490 |
+
with gr.Column(scale=4):
|
491 |
+
with gr.Group(elem_classes="container"):
|
492 |
+
# Image result container with status indicator
|
493 |
+
with gr.Group():
|
494 |
+
generation_status = gr.HTML('<div class="status-complete">Ready to generate</div>')
|
495 |
+
result = gr.Image(label="Generated Image", elem_id="result-image")
|
496 |
+
seed_text = gr.Number(label="Used Seed", value=42)
|
|
|
497 |
|
498 |
+
with gr.Tabs(elem_classes="tabs") as tabs:
|
499 |
+
with gr.TabItem("Gallery"):
|
500 |
+
with gr.Group(elem_classes="container"):
|
501 |
+
gallery_header = gr.Markdown("### 🖼️ Your Generated Masterpieces")
|
502 |
+
with gr.Row():
|
503 |
+
refresh_btn = gr.Button("🔄 Refresh Gallery", elem_classes="secondary")
|
504 |
+
generated_gallery = gr.Gallery(
|
505 |
+
label="Generated Images",
|
506 |
+
columns=3,
|
507 |
+
value=load_generated_images(),
|
508 |
+
height="500px",
|
509 |
+
elem_classes="gallery-item"
|
510 |
+
)
|
511 |
|
512 |
# Event handlers
|
513 |
def refresh_gallery():
|
514 |
return load_generated_images()
|
515 |
|
516 |
def clear_output():
|
517 |
+
return "", gr.update(value=None), seed, '<div class="status-complete">Ready to generate</div>'
|
518 |
+
|
519 |
+
def before_generate():
|
520 |
+
return '<div class="status-generating">Generating image...</div>'
|
521 |
+
|
522 |
+
def after_generate(image, seed, gallery):
|
523 |
+
return image, seed, gallery, '<div class="status-complete">Generation complete!</div>'
|
524 |
|
525 |
refresh_btn.click(
|
526 |
fn=refresh_gallery,
|
|
|
531 |
clear_button.click(
|
532 |
fn=clear_output,
|
533 |
inputs=None,
|
534 |
+
outputs=[prompt, result, seed_text, generation_status]
|
535 |
)
|
536 |
+
|
537 |
+
# Update with status indicators for generation process
|
538 |
run_button.click(
|
539 |
+
fn=before_generate,
|
540 |
+
inputs=None,
|
541 |
+
outputs=generation_status,
|
542 |
+
).then(
|
543 |
fn=inference,
|
544 |
inputs=[
|
545 |
prompt,
|
|
|
552 |
lora_scale,
|
553 |
],
|
554 |
outputs=[result, seed_text, generated_gallery],
|
555 |
+
).then(
|
556 |
+
fn=after_generate,
|
557 |
+
inputs=[result, seed_text, generated_gallery],
|
558 |
+
outputs=[result, seed_text, generated_gallery, generation_status],
|
559 |
)
|
560 |
|
561 |
prompt.submit(
|
562 |
+
fn=before_generate,
|
563 |
+
inputs=None,
|
564 |
+
outputs=generation_status,
|
565 |
+
).then(
|
566 |
fn=inference,
|
567 |
inputs=[
|
568 |
prompt,
|
|
|
575 |
lora_scale,
|
576 |
],
|
577 |
outputs=[result, seed_text, generated_gallery],
|
578 |
+
).then(
|
579 |
+
fn=after_generate,
|
580 |
+
inputs=[result, seed_text, generated_gallery],
|
581 |
+
outputs=[result, seed_text, generated_gallery, generation_status],
|
582 |
)
|
583 |
+
|
584 |
+
# Custom JavaScript for handling example prompts
|
585 |
+
gr.HTML("""
|
586 |
+
<script>
|
587 |
+
document.addEventListener('DOMContentLoaded', function() {
|
588 |
+
// Add click handlers to example prompts
|
589 |
+
setTimeout(() => {
|
590 |
+
const examples = document.querySelectorAll('.example-prompt');
|
591 |
+
const promptInput = document.querySelector('textarea');
|
592 |
+
|
593 |
+
examples.forEach(example => {
|
594 |
+
example.addEventListener('click', function() {
|
595 |
+
promptInput.value = this.textContent.trim();
|
596 |
+
// Trigger input event to update Gradio's state
|
597 |
+
const event = new Event('input', { bubbles: true });
|
598 |
+
promptInput.dispatchEvent(event);
|
599 |
+
});
|
600 |
+
});
|
601 |
+
}, 1000); // Small delay to ensure elements are loaded
|
602 |
+
});
|
603 |
+
</script>
|
604 |
+
""")
|
605 |
|
606 |
# Launch with fallback options
|
607 |
try:
|
608 |
+
demo.queue(concurrency_count=1, max_size=20)
|
609 |
demo.launch(debug=True, show_api=False)
|
610 |
except Exception as e:
|
611 |
print(f"Error during launch: {e}")
|