bakyt92 commited on
Commit
82d56ef
Β·
1 Parent(s): e4c0d3f

updates app.py - fix of errors

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -501,6 +501,7 @@ with gr.Blocks(title="AI Image Generator & Text Overlay") as demo:
501
  # Text pattern selection with template preview
502
  with gr.Row():
503
  with gr.Column(scale=2):
 
504
  pattern = gr.Dropdown(
505
  choices=[
506
  ("2-lines-top", "πŸ“„ 2 Lines - Top (Header style)"),
@@ -510,15 +511,15 @@ with gr.Blocks(title="AI Image Generator & Text Overlay") as demo:
510
  ("3-lines-center", "πŸ“‹ 3 Lines - Center (Full title)"),
511
  ("3-lines-bottom", "πŸ“‹ 3 Lines - Bottom (Credits style)")
512
  ],
513
- value="2-lines-top",
514
  label="Layout Pattern"
515
  )
516
 
517
  with gr.Column(scale=1):
518
- # Template preview image - initialize with None first
519
  template_preview = gr.Image(
520
  label="Template Preview",
521
- value=None, # Start with None to avoid initialization issues
522
  show_label=True,
523
  interactive=False,
524
  width=200,
@@ -593,13 +594,13 @@ with gr.Blocks(title="AI Image Generator & Text Overlay") as demo:
593
  outputs=[text_image, status_message]
594
  )
595
 
596
- # Initialize template preview after the interface is created
597
- demo.load(
598
- lambda: get_pattern_template("2-lines-top"),
599
- outputs=[template_preview]
600
- )
601
 
602
- # Launch the application
603
  if __name__ == "__main__":
604
  demo.launch(
605
  server_name="0.0.0.0",
 
501
  # Text pattern selection with template preview
502
  with gr.Row():
503
  with gr.Column(scale=2):
504
+ # FIXED: Use proper tuple format and matching value
505
  pattern = gr.Dropdown(
506
  choices=[
507
  ("2-lines-top", "πŸ“„ 2 Lines - Top (Header style)"),
 
511
  ("3-lines-center", "πŸ“‹ 3 Lines - Center (Full title)"),
512
  ("3-lines-bottom", "πŸ“‹ 3 Lines - Bottom (Credits style)")
513
  ],
514
+ value="2-lines-top", # This now matches the first tuple value
515
  label="Layout Pattern"
516
  )
517
 
518
  with gr.Column(scale=1):
519
+ # Template preview image
520
  template_preview = gr.Image(
521
  label="Template Preview",
522
+ value=None,
523
  show_label=True,
524
  interactive=False,
525
  width=200,
 
594
  outputs=[text_image, status_message]
595
  )
596
 
597
+ # FIXED: Move demo.load() INSIDE the Blocks context
598
+ demo.load(
599
+ lambda: get_pattern_template("2-lines-top"),
600
+ outputs=[template_preview]
601
+ )
602
 
603
+ # Launch the application - OUTSIDE the Blocks context
604
  if __name__ == "__main__":
605
  demo.launch(
606
  server_name="0.0.0.0",