ajsbsd commited on
Commit
9d1a533
·
verified ·
1 Parent(s): e250949

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -214,7 +214,7 @@ def generate_txt2img(prompt, negative_prompt, num_steps, guidance_scale, width,
214
  negative_prompt or "", seed, num_steps, guidance_scale
215
  )
216
 
217
- return png_path, status
218
 
219
  except Exception as e:
220
  return None, f"Generation failed: {str(e)}"
@@ -291,7 +291,7 @@ def generate_img2img(input_image, prompt, negative_prompt, num_steps, guidance_s
291
  negative_prompt or "", seed, num_steps, guidance_scale, strength
292
  )
293
 
294
- return png_path, status
295
 
296
  except Exception as e:
297
  return None, f"Transformation failed: {str(e)}"
@@ -315,7 +315,8 @@ def set_example_prompt():
315
  return random.choice(EXAMPLE_PROMPTS)
316
 
317
  # Simplified negative prompt for better performance
318
- DEFAULT_NEGATIVE = """(low quality:1.3), (worst quality:1.3), (bad quality:1.2), blurry, noisy, ugly, deformed,
 
319
  (text, watermark:1.4), (extra limbs:1.3), (bad hands:1.3), (bad anatomy:1.2)
320
  """
321
 
@@ -374,7 +375,8 @@ with gr.Blocks(
374
  txt2img_btn = gr.Button("🎨 Generate", variant="primary", size="lg")
375
 
376
  with gr.Column():
377
- txt2img_output = gr.File(label="Generated PNG with Metadata", file_types=[".png"])
 
378
  txt2img_status = gr.Textbox(label="Generation Info", interactive=False, lines=6)
379
 
380
  with gr.TabItem("🖼️ Image to Image"):
@@ -420,7 +422,8 @@ with gr.Blocks(
420
  img2img_btn = gr.Button("🖼️ Transform", variant="primary", size="lg")
421
 
422
  with gr.Column():
423
- img2img_output = gr.File(label="Generated PNG with Metadata", file_types=[".png"])
 
424
  img2img_status = gr.Textbox(label="Generation Info", interactive=False, lines=6)
425
 
426
  # Event handlers
@@ -428,14 +431,14 @@ with gr.Blocks(
428
  fn=generate_txt2img,
429
  inputs=[txt2img_prompt, txt2img_negative, txt2img_steps, txt2img_guidance,
430
  txt2img_width, txt2img_height, txt2img_seed, txt2img_quality_tags],
431
- outputs=[txt2img_output, txt2img_status]
432
  )
433
 
434
  img2img_btn.click(
435
  fn=generate_img2img,
436
  inputs=[img2img_input, img2img_prompt, img2img_negative, img2img_steps, img2img_guidance,
437
  img2img_strength, img2img_seed, img2img_quality_tags],
438
- outputs=[img2img_output, img2img_status]
439
  )
440
 
441
  # Example prompt buttons
 
214
  negative_prompt or "", seed, num_steps, guidance_scale
215
  )
216
 
217
+ return result.images[0], png_path, status
218
 
219
  except Exception as e:
220
  return None, f"Generation failed: {str(e)}"
 
291
  negative_prompt or "", seed, num_steps, guidance_scale, strength
292
  )
293
 
294
+ return result.images[0], png_path, status
295
 
296
  except Exception as e:
297
  return None, f"Transformation failed: {str(e)}"
 
315
  return random.choice(EXAMPLE_PROMPTS)
316
 
317
  # Simplified negative prompt for better performance
318
+ DEFAULT_NEGATIVE = """
319
+ (low quality:1.3), (worst quality:1.3), (bad quality:1.2), blurry, noisy, ugly, deformed,
320
  (text, watermark:1.4), (extra limbs:1.3), (bad hands:1.3), (bad anatomy:1.2)
321
  """
322
 
 
375
  txt2img_btn = gr.Button("🎨 Generate", variant="primary", size="lg")
376
 
377
  with gr.Column():
378
+ txt2img_preview = gr.Image(label="Preview", height=400)
379
+ txt2img_output = gr.File(label="📥 Download PNG with Metadata", file_types=[".png"])
380
  txt2img_status = gr.Textbox(label="Generation Info", interactive=False, lines=6)
381
 
382
  with gr.TabItem("🖼️ Image to Image"):
 
422
  img2img_btn = gr.Button("🖼️ Transform", variant="primary", size="lg")
423
 
424
  with gr.Column():
425
+ img2img_preview = gr.Image(label="Preview", height=400)
426
+ img2img_output = gr.File(label="📥 Download PNG with Metadata", file_types=[".png"])
427
  img2img_status = gr.Textbox(label="Generation Info", interactive=False, lines=6)
428
 
429
  # Event handlers
 
431
  fn=generate_txt2img,
432
  inputs=[txt2img_prompt, txt2img_negative, txt2img_steps, txt2img_guidance,
433
  txt2img_width, txt2img_height, txt2img_seed, txt2img_quality_tags],
434
+ outputs=[txt2img_preview, txt2img_output, txt2img_status]
435
  )
436
 
437
  img2img_btn.click(
438
  fn=generate_img2img,
439
  inputs=[img2img_input, img2img_prompt, img2img_negative, img2img_steps, img2img_guidance,
440
  img2img_strength, img2img_seed, img2img_quality_tags],
441
+ outputs=[img2img_preview, img2img_output, img2img_status]
442
  )
443
 
444
  # Example prompt buttons