Update app.py
Browse files
app.py
CHANGED
@@ -454,33 +454,14 @@ 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)}") #
|
458 |
if isinstance(img, float):
|
459 |
print("Error: A float was returned instead of an image.") # Log if img is a float
|
460 |
raise ValueError("Expected an image, but got a float.") # Raise error if a float is found
|
461 |
yield img
|
462 |
final_image = img # Update final_image with the current image
|
463 |
return final_image
|
464 |
-
|
465 |
-
def generate_image_to_image(prompt_mash, image_input_path, image_strength, steps, cfg_scale, width, height, seed):
|
466 |
-
pipe_i2i.to("cuda")
|
467 |
-
generator = torch.Generator(device="cuda").manual_seed(seed)
|
468 |
-
image_input = load_image(image_input_path)
|
469 |
-
final_image = pipe_i2i(
|
470 |
-
prompt=prompt_mash,
|
471 |
-
image=image_input,
|
472 |
-
strength=image_strength,
|
473 |
-
num_inference_steps=steps,
|
474 |
-
guidance_scale=cfg_scale,
|
475 |
-
width=width,
|
476 |
-
height=height,
|
477 |
-
generator=generator,
|
478 |
-
joint_attention_kwargs={"scale": 1.0},
|
479 |
-
output_type="pil",
|
480 |
-
).images[0]
|
481 |
-
return final_image
|
482 |
-
|
483 |
-
@spaces.GPU(duration=75)
|
484 |
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)):
|
485 |
print("run_lora function called.") # Debugging statement
|
486 |
print(f"Inputs received - Prompt: {prompt}, CFG Scale: {cfg_scale}, Steps: {steps}, Seed: {seed}, Width: {width}, Height: {height}") # Debugging statement
|
@@ -552,10 +533,9 @@ def run_lora(prompt, cfg_scale, steps, selected_info_1, selected_info_2, selecte
|
|
552 |
if image_input is not None:
|
553 |
final_image = generate_image_to_image(prompt_mash, image_input, image_strength, steps, cfg_scale, width, height, seed)
|
554 |
print(f"Debug: generate_image_to_image output type: {type(final_image)}") # Debugging
|
555 |
-
if
|
556 |
-
print(
|
557 |
-
raise ValueError("Expected an image
|
558 |
-
print(f"Debug: generate_image_to_image output value: {final_image}") # Debugging
|
559 |
yield final_image, seed, gr.update(visible=False)
|
560 |
else:
|
561 |
image_generator = generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress)
|
@@ -581,7 +561,6 @@ def run_lora(prompt, cfg_scale, steps, selected_info_1, selected_info_2, selecte
|
|
581 |
|
582 |
run_lora.zerogpu = True
|
583 |
|
584 |
-
|
585 |
def get_huggingface_safetensors(link):
|
586 |
split_link = link.split("/")
|
587 |
if len(split_link) == 4:
|
|
|
454 |
output_type="pil",
|
455 |
good_vae=good_vae,
|
456 |
):
|
457 |
+
print(f"Debug: Yielding image of type {type(img)}") # Check type of each image
|
458 |
if isinstance(img, float):
|
459 |
print("Error: A float was returned instead of an image.") # Log if img is a float
|
460 |
raise ValueError("Expected an image, but got a float.") # Raise error if a float is found
|
461 |
yield img
|
462 |
final_image = img # Update final_image with the current image
|
463 |
return final_image
|
464 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
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)):
|
466 |
print("run_lora function called.") # Debugging statement
|
467 |
print(f"Inputs received - Prompt: {prompt}, CFG Scale: {cfg_scale}, Steps: {steps}, Seed: {seed}, Width: {width}, Height: {height}") # Debugging statement
|
|
|
533 |
if image_input is not None:
|
534 |
final_image = generate_image_to_image(prompt_mash, image_input, image_strength, steps, cfg_scale, width, height, seed)
|
535 |
print(f"Debug: generate_image_to_image output type: {type(final_image)}") # Debugging
|
536 |
+
if isinstance(final_image, float):
|
537 |
+
print("Error: Expected an image but got a float.") # Log if it's a float
|
538 |
+
raise ValueError("Expected an image, but got a float.") # Raise error if a float is found
|
|
|
539 |
yield final_image, seed, gr.update(visible=False)
|
540 |
else:
|
541 |
image_generator = generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress)
|
|
|
561 |
|
562 |
run_lora.zerogpu = True
|
563 |
|
|
|
564 |
def get_huggingface_safetensors(link):
|
565 |
split_link = link.split("/")
|
566 |
if len(split_link) == 4:
|