ginipick commited on
Commit
3c27458
Β·
verified Β·
1 Parent(s): 90443db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -34
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=48,
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=32,
416
  step=2
417
  )
418
 
419
  with gr.Row():
420
- font_name = gr.Dropdown(
421
- label="폰트 선택",
422
- choices=["λ‚˜λˆ”κ³ λ”•", "λ‚˜λˆ”λͺ…μ‘°", "맑은 κ³ λ”•", "바탕", "돋움", "κΈ°λ³Έ"],
423
- value="λ‚˜λˆ”κ³ λ”•"
424
- )
425
- text_color = gr.ColorPicker(
426
- label="κΈ€μž 색상",
427
- value="#FFFFFF"
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
- # Auto-augment Korean prompts
515
- def handle_prompt_change(prompt_text):
516
- if is_korean_only(prompt_text):
517
- return augment_prompt_with_llm(prompt_text)
518
- return prompt_text
519
-
520
- # Optional: Auto-augment on prompt change (commented out to avoid too many API calls)
521
- # prompt.change(
522
- # fn=handle_prompt_change,
523
- # inputs=[prompt],
524
- # outputs=[prompt]
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],