Update app.py
Browse files
app.py
CHANGED
@@ -454,6 +454,7 @@ def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress)
|
|
454 |
output_type="pil",
|
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)}")
|
@@ -462,6 +463,7 @@ def generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress)
|
|
462 |
final_image = img # Update final_image with the current image
|
463 |
return final_image
|
464 |
|
|
|
465 |
@spaces.GPU(duration=75)
|
466 |
def run_lora(prompt, cfg_scale, steps, selected_info_1, selected_info_2, selected_info_3, selected_info_4, selected_indices, lora_scale_1, lora_scale_2, lora_scale_3, lora_scale_4, randomize_seed, seed, width, height, loras_state, image_input=None, progress=gr.Progress(track_tqdm=True)):
|
467 |
print("run_lora function called.") # Debugging statement
|
@@ -551,12 +553,27 @@ def run_lora(prompt, cfg_scale, steps, selected_info_1, selected_info_2, selecte
|
|
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
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
559 |
|
|
|
|
|
|
|
560 |
except Exception as e:
|
561 |
print(f"Error during image generation: {e}") # Error handling
|
562 |
raise gr.Error("An error occurred during image generation.")
|
|
|
454 |
output_type="pil",
|
455 |
good_vae=good_vae,
|
456 |
):
|
457 |
+
# Debugging: Check image type before yielding
|
458 |
print(f"Debug: Yielding image of type {type(img)}") # Debugging
|
459 |
if not isinstance(img, (PIL.Image.Image, torch.Tensor)): # Check if it's an image
|
460 |
print(f"Error: Expected an image, but got {type(img)}")
|
|
|
463 |
final_image = img # Update final_image with the current image
|
464 |
return final_image
|
465 |
|
466 |
+
|
467 |
@spaces.GPU(duration=75)
|
468 |
def run_lora(prompt, cfg_scale, steps, selected_info_1, selected_info_2, selected_info_3, selected_info_4, selected_indices, lora_scale_1, lora_scale_2, lora_scale_3, lora_scale_4, randomize_seed, seed, width, height, loras_state, image_input=None, progress=gr.Progress(track_tqdm=True)):
|
469 |
print("run_lora function called.") # Debugging statement
|
|
|
553 |
progress_bar = f'<div class="progress-container"><div class="progress-bar" style="--current: {step_counter}; --total: {steps};"></div></div>'
|
554 |
yield image, seed, gr.update(value=progress_bar, visible=True)
|
555 |
|
556 |
+
if image_input is not None:
|
557 |
+
final_image = generate_image_to_image(prompt_mash, image_input, image_strength, steps, cfg_scale, width, height, seed)
|
558 |
+
print(f"Debug: generate_image_to_image output type: {type(final_image)}") # Debugging
|
559 |
+
if not isinstance(final_image, (PIL.Image.Image, torch.Tensor)): # Check if it's an image
|
560 |
+
print(f"Error: Expected an image, but got {type(final_image)}")
|
561 |
+
raise ValueError("Expected an image from generate_image_to_image, but got a non-image value.")
|
562 |
+
print(f"Debug: generate_image_to_image output value: {final_image}") # Debugging
|
563 |
+
yield final_image, seed, gr.update(visible=False)
|
564 |
+
|
565 |
+
if final_image is None:
|
566 |
+
print("No final image generated.") # Debugging statement
|
567 |
+
else:
|
568 |
+
print(f"Debug: final_image type: {type(final_image)}") # Debugging
|
569 |
+
if not isinstance(final_image, (PIL.Image.Image, torch.Tensor)): # Check if it's an image
|
570 |
+
print(f"Error: Expected an image, but got {type(final_image)}")
|
571 |
+
raise ValueError("Expected an image, but got a non-image value.")
|
572 |
+
print(f"Debug: final_image value: {final_image}") # Debugging
|
573 |
|
574 |
+
yield final_image, seed, gr.update(value=progress_bar, visible=False)
|
575 |
+
|
576 |
+
|
577 |
except Exception as e:
|
578 |
print(f"Error during image generation: {e}") # Error handling
|
579 |
raise gr.Error("An error occurred during image generation.")
|