Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -50,6 +50,7 @@ print("Checking available fonts...")
|
|
50 |
available_fonts = check_available_fonts()
|
51 |
if not available_fonts:
|
52 |
print("WARNING: No Korean fonts found! Please ensure font files are in the same directory as app.py")
|
|
|
53 |
else:
|
54 |
print(f"Available fonts: {', '.join(available_fonts)}")
|
55 |
|
@@ -365,15 +366,6 @@ with gr.Blocks(theme=gr.themes.Soft(), analytics_enabled=False) as demo:
|
|
365 |
max_lines=1,
|
366 |
placeholder="Enter your prompt",
|
367 |
container=False,
|
368 |
-
# Font change event handler for debugging
|
369 |
-
def on_font_change(font_name):
|
370 |
-
print(f"Font changed to: {font_name}")
|
371 |
-
return font_name
|
372 |
-
|
373 |
-
font_name.change(
|
374 |
-
fn=on_font_change,
|
375 |
-
inputs=[font_name],
|
376 |
-
outputs=[font_name]
|
377 |
)
|
378 |
augment_button = gr.Button("μ¦κ°", scale=0)
|
379 |
run_button = gr.Button("Run", scale=0)
|
@@ -398,7 +390,7 @@ with gr.Blocks(theme=gr.themes.Soft(), analytics_enabled=False) as demo:
|
|
398 |
label="μ λͺ© κΈμ ν¬κΈ°",
|
399 |
minimum=20,
|
400 |
maximum=100,
|
401 |
-
value=
|
402 |
step=2
|
403 |
)
|
404 |
with gr.Column():
|
@@ -412,20 +404,49 @@ with gr.Blocks(theme=gr.themes.Soft(), analytics_enabled=False) as demo:
|
|
412 |
label="μ§μμ΄ κΈμ ν¬κΈ°",
|
413 |
minimum=16,
|
414 |
maximum=60,
|
415 |
-
value=
|
416 |
step=2
|
417 |
)
|
418 |
|
419 |
with gr.Row():
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
|
430 |
with gr.Accordion("Advanced Settings", open=False):
|
431 |
seed = gr.Slider(
|
@@ -497,6 +518,22 @@ with gr.Blocks(theme=gr.themes.Soft(), analytics_enabled=False) as demo:
|
|
497 |
# Event handlers
|
498 |
def refresh_gallery():
|
499 |
return load_generated_images()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
500 |
|
501 |
refresh_btn.click(
|
502 |
fn=refresh_gallery,
|
@@ -504,25 +541,29 @@ with gr.Blocks(theme=gr.themes.Soft(), analytics_enabled=False) as demo:
|
|
504 |
outputs=generated_gallery,
|
505 |
)
|
506 |
|
507 |
-
# Augment button handler
|
508 |
augment_button.click(
|
509 |
fn=augment_prompt,
|
510 |
inputs=[prompt],
|
511 |
outputs=[prompt],
|
512 |
)
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
|
|
|
|
|
|
|
|
|
|
526 |
|
527 |
gr.on(
|
528 |
triggers=[run_button.click, prompt.submit],
|
|
|
50 |
available_fonts = check_available_fonts()
|
51 |
if not available_fonts:
|
52 |
print("WARNING: No Korean fonts found! Please ensure font files are in the same directory as app.py")
|
53 |
+
available_fonts = ["λλκ³ λ"] # Default fallback
|
54 |
else:
|
55 |
print(f"Available fonts: {', '.join(available_fonts)}")
|
56 |
|
|
|
366 |
max_lines=1,
|
367 |
placeholder="Enter your prompt",
|
368 |
container=False,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
)
|
370 |
augment_button = gr.Button("μ¦κ°", scale=0)
|
371 |
run_button = gr.Button("Run", scale=0)
|
|
|
390 |
label="μ λͺ© κΈμ ν¬κΈ°",
|
391 |
minimum=20,
|
392 |
maximum=100,
|
393 |
+
value=100,
|
394 |
step=2
|
395 |
)
|
396 |
with gr.Column():
|
|
|
404 |
label="μ§μμ΄ κΈμ ν¬κΈ°",
|
405 |
minimum=16,
|
406 |
maximum=60,
|
407 |
+
value=24,
|
408 |
step=2
|
409 |
)
|
410 |
|
411 |
with gr.Row():
|
412 |
+
with gr.Column():
|
413 |
+
font_name = gr.Dropdown(
|
414 |
+
label="ν°νΈ μ ν",
|
415 |
+
choices=available_fonts,
|
416 |
+
value=available_fonts[0] if available_fonts else "λλκ³ λ"
|
417 |
+
)
|
418 |
+
with gr.Column():
|
419 |
+
gr.Markdown("### κΈμ μμ μ ν")
|
420 |
+
color_buttons = gr.Radio(
|
421 |
+
label="미리 μ μλ μμ",
|
422 |
+
choices=[
|
423 |
+
("ν°μ", "#FFFFFF"),
|
424 |
+
("κ²μ μ", "#000000"),
|
425 |
+
("λΉ¨κ°μ", "#FF0000"),
|
426 |
+
("νλμ", "#0000FF"),
|
427 |
+
("μ΄λ‘μ", "#00FF00"),
|
428 |
+
("λ
Έλμ", "#FFFF00"),
|
429 |
+
("μ£Όν©μ", "#FFA500"),
|
430 |
+
("보λΌμ", "#800080"),
|
431 |
+
("νμ", "#808080"),
|
432 |
+
("κΈμ", "#FFD700"),
|
433 |
+
("μμ", "#C0C0C0"),
|
434 |
+
("컀μ€ν
", "custom")
|
435 |
+
],
|
436 |
+
value="#FFFFFF",
|
437 |
+
type="value"
|
438 |
+
)
|
439 |
+
|
440 |
+
custom_color = gr.ColorPicker(
|
441 |
+
label="컀μ€ν
μμ μ ν",
|
442 |
+
value="#FFFFFF",
|
443 |
+
visible=False
|
444 |
+
)
|
445 |
+
|
446 |
+
text_color = gr.Textbox(
|
447 |
+
value="#FFFFFF",
|
448 |
+
visible=False
|
449 |
+
)
|
450 |
|
451 |
with gr.Accordion("Advanced Settings", open=False):
|
452 |
seed = gr.Slider(
|
|
|
518 |
# Event handlers
|
519 |
def refresh_gallery():
|
520 |
return load_generated_images()
|
521 |
+
|
522 |
+
def update_color_visibility(selected_color):
|
523 |
+
if selected_color == "custom":
|
524 |
+
return gr.update(visible=True), gr.update(value="#FFFFFF")
|
525 |
+
else:
|
526 |
+
return gr.update(visible=False), gr.update(value=selected_color)
|
527 |
+
|
528 |
+
def update_final_color(selected_color, custom_color_value):
|
529 |
+
if selected_color == "custom":
|
530 |
+
return custom_color_value
|
531 |
+
else:
|
532 |
+
return selected_color
|
533 |
+
|
534 |
+
def on_font_change(font_name):
|
535 |
+
print(f"Font changed to: {font_name}")
|
536 |
+
return font_name
|
537 |
|
538 |
refresh_btn.click(
|
539 |
fn=refresh_gallery,
|
|
|
541 |
outputs=generated_gallery,
|
542 |
)
|
543 |
|
|
|
544 |
augment_button.click(
|
545 |
fn=augment_prompt,
|
546 |
inputs=[prompt],
|
547 |
outputs=[prompt],
|
548 |
)
|
549 |
+
|
550 |
+
font_name.change(
|
551 |
+
fn=on_font_change,
|
552 |
+
inputs=[font_name],
|
553 |
+
outputs=[font_name]
|
554 |
+
)
|
555 |
+
|
556 |
+
color_buttons.change(
|
557 |
+
fn=update_color_visibility,
|
558 |
+
inputs=[color_buttons],
|
559 |
+
outputs=[custom_color, text_color]
|
560 |
+
)
|
561 |
+
|
562 |
+
custom_color.change(
|
563 |
+
fn=update_final_color,
|
564 |
+
inputs=[color_buttons, custom_color],
|
565 |
+
outputs=[text_color]
|
566 |
+
)
|
567 |
|
568 |
gr.on(
|
569 |
triggers=[run_button.click, prompt.submit],
|