Vijish commited on
Commit
5240fe1
Β·
verified Β·
1 Parent(s): 158f005

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -9
app.py CHANGED
@@ -311,7 +311,7 @@ def process_image_batch(images, pipe, prompt, negative_prompt, num_inference_ste
311
  clear_memory() # Clear memory after each batch
312
  return all_processed_images
313
 
314
- # Function to generate images
315
  def generate_images_with_progress(prompt, negative_prompt, batch_count, use_controlnet, controlnet_type, mode, control_images, num_inference_steps, progress=gr.Progress(track_tqdm=True)):
316
  global controlnet_pipe, pipe, reference_pipe
317
 
@@ -378,13 +378,8 @@ def generate_images_with_progress(prompt, negative_prompt, batch_count, use_cont
378
 
379
  clear_memory()
380
 
381
- # Ensure all generated images are in PIL format and save as PNG
382
- pil_images = []
383
- for img in images:
384
- if not isinstance(img, Image.Image):
385
- img = Image.fromarray(np.array(img))
386
- img.save("temp.png", format="PNG")
387
- pil_images.append(Image.open("temp.png"))
388
 
389
  return pil_images
390
 
@@ -563,4 +558,4 @@ with gr.Blocks() as demo:
563
  if __name__ == "__main__":
564
  # Your Gradio interface setup here
565
  demo.launch(auth=("roland", "roland"), debug=True)
566
- clear_memory()
 
311
  clear_memory() # Clear memory after each batch
312
  return all_processed_images
313
 
314
+ # Define the function to generate images
315
  def generate_images_with_progress(prompt, negative_prompt, batch_count, use_controlnet, controlnet_type, mode, control_images, num_inference_steps, progress=gr.Progress(track_tqdm=True)):
316
  global controlnet_pipe, pipe, reference_pipe
317
 
 
378
 
379
  clear_memory()
380
 
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
 
 
558
  if __name__ == "__main__":
559
  # Your Gradio interface setup here
560
  demo.launch(auth=("roland", "roland"), debug=True)
561
+ clear_memory()