bakyt92 commited on
Commit
c3aeeb1
·
1 Parent(s): 6114732

updates for errors

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -266,6 +266,9 @@ with gr.Blocks(title="AI Image Generator & Text Overlay") as demo:
266
  gr.Markdown("# 🎨 AI Image Generator & Text Overlay")
267
  gr.Markdown("Generate images with AI or upload your own, then add custom text overlays!")
268
 
 
 
 
269
  # Tab 1: Image Generation
270
  with gr.Tab("🖼️ Image Generation", id="generation_tab"):
271
  gr.Markdown("## Generate or Upload Images")
@@ -323,19 +326,19 @@ with gr.Blocks(title="AI Image Generator & Text Overlay") as demo:
323
  ideogram_btn.click(
324
  generate_ideogram_image,
325
  inputs=[ideogram_key, prompt, ideogram_aspect],
326
- outputs=[generated_image, status_message]
327
  )
328
 
329
  dalle_btn.click(
330
  generate_dalle_image,
331
  inputs=[dalle_key, prompt, dalle_size],
332
- outputs=[generated_image, status_message]
333
  )
334
 
335
  upload_btn.click(
336
  process_uploaded_image,
337
  inputs=[upload_image],
338
- outputs=[generated_image, status_message]
339
  )
340
 
341
  # Tab 2: Add Text Overlay
@@ -348,12 +351,12 @@ with gr.Blocks(title="AI Image Generator & Text Overlay") as demo:
348
  # Text pattern selection
349
  pattern = gr.Dropdown(
350
  choices=[
351
- ("2-lines-top", "2 lines - Top"),
352
- ("2-lines-center", "2 lines - Center"),
353
- ("2-lines-bottom", "2 lines - Bottom"),
354
- ("3-lines-top", "3 lines - Top"),
355
- ("3-lines-center", "3 lines - Center"),
356
- ("3-lines-bottom", "3 lines - Bottom")
357
  ],
358
  value="2-lines-top",
359
  label="Layout Pattern"
@@ -396,7 +399,7 @@ with gr.Blocks(title="AI Image Generator & Text Overlay") as demo:
396
  # Event handler for Tab 2
397
  add_text_btn.click(
398
  add_text_to_image,
399
- inputs=[generated_image, pattern, line1_inp, line2_inp, line3_inp, font_size, color],
400
  outputs=[text_image, status_message]
401
  )
402
 
 
266
  gr.Markdown("# 🎨 AI Image Generator & Text Overlay")
267
  gr.Markdown("Generate images with AI or upload your own, then add custom text overlays!")
268
 
269
+ # Shared state for the current image
270
+ current_image = gr.State(value=None)
271
+
272
  # Tab 1: Image Generation
273
  with gr.Tab("🖼️ Image Generation", id="generation_tab"):
274
  gr.Markdown("## Generate or Upload Images")
 
326
  ideogram_btn.click(
327
  generate_ideogram_image,
328
  inputs=[ideogram_key, prompt, ideogram_aspect],
329
+ outputs=[generated_image, status_message, current_image]
330
  )
331
 
332
  dalle_btn.click(
333
  generate_dalle_image,
334
  inputs=[dalle_key, prompt, dalle_size],
335
+ outputs=[generated_image, status_message, current_image]
336
  )
337
 
338
  upload_btn.click(
339
  process_uploaded_image,
340
  inputs=[upload_image],
341
+ outputs=[generated_image, status_message, current_image]
342
  )
343
 
344
  # Tab 2: Add Text Overlay
 
351
  # Text pattern selection
352
  pattern = gr.Dropdown(
353
  choices=[
354
+ "2-lines-top",
355
+ "2-lines-center",
356
+ "2-lines-bottom",
357
+ "3-lines-top",
358
+ "3-lines-center",
359
+ "3-lines-bottom"
360
  ],
361
  value="2-lines-top",
362
  label="Layout Pattern"
 
399
  # Event handler for Tab 2
400
  add_text_btn.click(
401
  add_text_to_image,
402
+ inputs=[current_image, pattern, line1_inp, line2_inp, line3_inp, font_size, color],
403
  outputs=[text_image, status_message]
404
  )
405