Vijish commited on
Commit
703aec8
Β·
verified Β·
1 Parent(s): 412d47c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -381,7 +381,14 @@ def generate_images_with_progress(prompt, negative_prompt, batch_count, use_cont
381
  # Ensure all generated images are in PIL format
382
  pil_images = [img if isinstance(img, Image.Image) else Image.fromarray(np.array(img)) for img in images]
383
 
384
- return pil_images
 
 
 
 
 
 
 
385
 
386
  # Function to extract PNG metadata
387
  def extract_png_info(image_path):
@@ -463,6 +470,7 @@ with gr.Blocks() as demo:
463
  )
464
  generate_button = gr.Button("Generate Images")
465
  gallery = gr.Gallery(label="Generated Images", show_label=False, elem_id="gallery", height=820)
 
466
 
467
  selected_style = gr.State(value="Anime Studio Dance")
468
 
@@ -516,12 +524,13 @@ with gr.Blocks() as demo:
516
  selected_images = [img[1] for img in selected_folder_images]
517
  # Adjust the batch_count here to generate the desired number of images
518
  selected_images = selected_images * batch_count
519
- return generate_images_with_progress(prompt, negative_prompt, batch_count, use_controlnet, controlnet_type, mode, selected_images, num_inference_steps, progress)
 
520
 
521
  generate_button.click(
522
  generate_images_with_folder_images,
523
  inputs=[prompt, negative_prompt, batch_count, use_controlnet, controlnet_type, mode, use_control_folder, selected_folder_images, batch_images_input, num_inference_steps, control_image],
524
- outputs=gallery
525
  )
526
 
527
  metadata_button = gr.Button("Extract Metadata")
@@ -558,4 +567,4 @@ with gr.Blocks() as demo:
558
  if __name__ == "__main__":
559
  # Your Gradio interface setup here
560
  demo.launch(auth=("roland", "roland"), debug=True)
561
- clear_memory()
 
381
  # Ensure all generated images are in PIL format
382
  pil_images = [img if isinstance(img, Image.Image) else Image.fromarray(np.array(img)) for img in images]
383
 
384
+ # Save images as PNG files for download
385
+ output_files = []
386
+ for i, img in enumerate(pil_images):
387
+ output_path = f"output_{i}.png"
388
+ img.save(output_path, format="PNG")
389
+ output_files.append(output_path)
390
+
391
+ return pil_images, output_files
392
 
393
  # Function to extract PNG metadata
394
  def extract_png_info(image_path):
 
470
  )
471
  generate_button = gr.Button("Generate Images")
472
  gallery = gr.Gallery(label="Generated Images", show_label=False, elem_id="gallery", height=820)
473
+ download_links = gr.Files(label="Download Generated Images")
474
 
475
  selected_style = gr.State(value="Anime Studio Dance")
476
 
 
524
  selected_images = [img[1] for img in selected_folder_images]
525
  # Adjust the batch_count here to generate the desired number of images
526
  selected_images = selected_images * batch_count
527
+ pil_images, output_files = generate_images_with_progress(prompt, negative_prompt, batch_count, use_controlnet, controlnet_type, mode, selected_images, num_inference_steps, progress)
528
+ return pil_images, output_files
529
 
530
  generate_button.click(
531
  generate_images_with_folder_images,
532
  inputs=[prompt, negative_prompt, batch_count, use_controlnet, controlnet_type, mode, use_control_folder, selected_folder_images, batch_images_input, num_inference_steps, control_image],
533
+ outputs=[gallery, download_links]
534
  )
535
 
536
  metadata_button = gr.Button("Extract Metadata")
 
567
  if __name__ == "__main__":
568
  # Your Gradio interface setup here
569
  demo.launch(auth=("roland", "roland"), debug=True)
570
+ clear_memory()