Update app.py
Browse files
app.py
CHANGED
@@ -512,7 +512,53 @@ def run_lora(prompt, cfg_scale, steps, selected_info_1, selected_info_2, selecte
|
|
512 |
lora_path = lora['repo']
|
513 |
weight_name = lora.get("weights")
|
514 |
print(f"Lora Path: {lora_path}")
|
515 |
-
pipe_to_use = pipe_i2i if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
516 |
|
517 |
def get_huggingface_safetensors(link):
|
518 |
split_link = link.split("/")
|
|
|
512 |
lora_path = lora['repo']
|
513 |
weight_name = lora.get("weights")
|
514 |
print(f"Lora Path: {lora_path}")
|
515 |
+
pipe_to_use = pipe_i2i if image_input is not None else pipe
|
516 |
+
pipe_to_use.load_lora_weights(
|
517 |
+
lora_path,
|
518 |
+
weight_name=weight_name if weight_name else None,
|
519 |
+
low_cpu_mem_usage=True,
|
520 |
+
adapter_name=lora_name
|
521 |
+
)
|
522 |
+
print("Loaded LoRAs:", lora_names)
|
523 |
+
print("Adapter weights:", lora_weights)
|
524 |
+
|
525 |
+
# Set random seed for reproducibility
|
526 |
+
with calculateDuration("Randomizing seed"):
|
527 |
+
print("Image Seed:", seed)
|
528 |
+
|
529 |
+
# Generate image
|
530 |
+
try:
|
531 |
+
if image_input is not None:
|
532 |
+
final_image = generate_image_to_image(prompt_mash, image_input, image_strength, steps, cfg_scale, width, height, seed)
|
533 |
+
print("Debug: generate_image_to_image output type:", type(final_image)) # Debugging
|
534 |
+
print("Debug: generate_image_to_image output value:", final_image) # Debugging
|
535 |
+
yield final_image, seed, gr.update(visible=False)
|
536 |
+
else:
|
537 |
+
image_generator = generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress)
|
538 |
+
# Consume the generator to get the final image
|
539 |
+
final_image = None
|
540 |
+
step_counter = 0
|
541 |
+
for image in image_generator:
|
542 |
+
print("Debug: generate_image yielded type:", type(image)) # Debugging
|
543 |
+
print("Debug: generate_image yielded value:", image) # Debugging
|
544 |
+
step_counter += 1
|
545 |
+
final_image = image
|
546 |
+
print(f"Yielding image {step_counter}/{steps}") # Debugging statement
|
547 |
+
progress_bar = f'<div class="progress-container"><div class="progress-bar" style="--current: {step_counter}; --total: {steps};"></div></div>'
|
548 |
+
yield image, seed, gr.update(value=progress_bar, visible=True)
|
549 |
+
if final_image is None:
|
550 |
+
print("No final image generated.") # Debugging statement
|
551 |
+
else:
|
552 |
+
print("Debug: final_image type:", type(final_image)) # Debugging
|
553 |
+
print("Debug: final_image value:", final_image) # Debugging
|
554 |
+
|
555 |
+
yield final_image, seed, gr.update(value=progress_bar, visible=False)
|
556 |
+
|
557 |
+
except Exception as e:
|
558 |
+
print(f"Error during image generation: {e}") # Error handling
|
559 |
+
raise gr.Error("An error occurred during image generation.")
|
560 |
+
|
561 |
+
run_lora.zerogpu = True
|
562 |
|
563 |
def get_huggingface_safetensors(link):
|
564 |
split_link = link.split("/")
|