Keltezaa commited on
Commit
c828a5d
·
verified ·
1 Parent(s): 9a80634

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -438,7 +438,6 @@ def remove_custom_lora(selected_indices, current_loras, gallery):
438
 
439
  def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress):
440
  print("Generating image...")
441
- print("Debug: Starting image generation")
442
  pipe.to("cuda")
443
  generator = torch.Generator(device="cuda").manual_seed(seed)
444
  final_image = None # Initialize final_image
@@ -456,6 +455,9 @@ def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress)
456
  good_vae=good_vae,
457
  ):
458
  print(f"Debug: Yielding image of type {type(img)}") # Debugging
 
 
 
459
  yield img
460
  final_image = img # Update final_image with the current image
461
  return final_image
@@ -531,29 +533,29 @@ def run_lora(prompt, cfg_scale, steps, selected_info_1, selected_info_2, selecte
531
  try:
532
  if image_input is not None:
533
  final_image = generate_image_to_image(prompt_mash, image_input, image_strength, steps, cfg_scale, width, height, seed)
534
- print("Debug: generate_image_to_image output type:", type(final_image)) # Debugging
535
- print("Debug: generate_image_to_image output value:", final_image) # Debugging
 
 
 
536
  yield final_image, seed, gr.update(visible=False)
537
  else:
538
  image_generator = generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress)
539
- # Consume the generator to get the final image
540
  final_image = None
541
  step_counter = 0
542
  for image in image_generator:
543
- print("Debug: generate_image yielded type:", type(image)) # Debugging
544
- print("Debug: generate_image yielded value:", image) # Debugging
545
  step_counter += 1
546
  final_image = image
547
- print(f"Yielding image {step_counter}/{steps}") # Debugging statement
548
  progress_bar = f'<div class="progress-container"><div class="progress-bar" style="--current: {step_counter}; --total: {steps};"></div></div>'
549
  yield image, seed, gr.update(value=progress_bar, visible=True)
 
550
  if final_image is None:
551
  print("No final image generated.") # Debugging statement
552
  else:
553
- print("Debug: final_image type:", type(final_image)) # Debugging
554
- print("Debug: final_image value:", final_image) # Debugging
555
-
556
- yield final_image, seed, gr.update(value=progress_bar, visible=False)
557
 
558
  except Exception as e:
559
  print(f"Error during image generation: {e}") # Error handling
 
438
 
439
  def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress):
440
  print("Generating image...")
 
441
  pipe.to("cuda")
442
  generator = torch.Generator(device="cuda").manual_seed(seed)
443
  final_image = None # Initialize final_image
 
455
  good_vae=good_vae,
456
  ):
457
  print(f"Debug: Yielding image of type {type(img)}") # Debugging
458
+ if not isinstance(img, (PIL.Image.Image, torch.Tensor)): # Check if it's an image
459
+ print(f"Error: Expected an image, but got {type(img)}")
460
+ raise ValueError("Expected an image, but got a non-image value.")
461
  yield img
462
  final_image = img # Update final_image with the current image
463
  return final_image
 
533
  try:
534
  if image_input is not None:
535
  final_image = generate_image_to_image(prompt_mash, image_input, image_strength, steps, cfg_scale, width, height, seed)
536
+ print(f"Debug: generate_image_to_image output type: {type(final_image)}") # Debugging
537
+ if not isinstance(final_image, (PIL.Image.Image, torch.Tensor)): # Check if it's an image
538
+ print(f"Error: Expected an image, but got {type(final_image)}")
539
+ raise ValueError("Expected an image from generate_image_to_image, but got a non-image value.")
540
+ print(f"Debug: generate_image_to_image output value: {final_image}") # Debugging
541
  yield final_image, seed, gr.update(visible=False)
542
  else:
543
  image_generator = generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress)
 
544
  final_image = None
545
  step_counter = 0
546
  for image in image_generator:
547
+ print(f"Debug: generate_image yielded type: {type(image)}") # Debugging
548
+ print(f"Debug: generate_image yielded value: {image}") # Debugging
549
  step_counter += 1
550
  final_image = image
 
551
  progress_bar = f'<div class="progress-container"><div class="progress-bar" style="--current: {step_counter}; --total: {steps};"></div></div>'
552
  yield image, seed, gr.update(value=progress_bar, visible=True)
553
+
554
  if final_image is None:
555
  print("No final image generated.") # Debugging statement
556
  else:
557
+ print(f"Debug: final_image type: {type(final_image)}") # Debugging
558
+ yield final_image, seed, gr.update(value=progress_bar, visible=False)
 
 
559
 
560
  except Exception as e:
561
  print(f"Error during image generation: {e}") # Error handling