Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
app.py
CHANGED
@@ -536,32 +536,34 @@ def run_lora(prompt, image_input, image_strength, cfg_scale, steps, selected_ind
|
|
536 |
print("Prompt Mash: ", prompt_mash) #
|
537 |
|
538 |
# Load LoRA weights with respective scales
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
|
|
|
|
565 |
if image_input is not None:
|
566 |
pipe_i2i.set_adapters(lora_names, adapter_weights=lora_weights)
|
567 |
else:
|
|
|
536 |
print("Prompt Mash: ", prompt_mash) #
|
537 |
|
538 |
# Load LoRA weights with respective scales
|
539 |
+
if selected_indices:
|
540 |
+
with calculateDuration("Loading LoRA weights"):
|
541 |
+
for idx, lora in enumerate(selected_loras):
|
542 |
+
lora_name = f"lora_{idx}"
|
543 |
+
lora_names.append(lora_name)
|
544 |
+
print(f"Lora Name: {lora_name}")
|
545 |
+
lora_weights.append(lora_scale_1 if idx == 0 else lora_scale_2)
|
546 |
+
lora_path = lora['repo']
|
547 |
+
weight_name = lora.get("weights")
|
548 |
+
print(f"Lora Path: {lora_path}")
|
549 |
+
if image_input is not None:
|
550 |
+
pipe_i2i.load_lora_weights(
|
551 |
+
lora_path,
|
552 |
+
weight_name=weight_name if weight_name else None,
|
553 |
+
low_cpu_mem_usage=True,
|
554 |
+
adapter_name=lora_name,
|
555 |
+
token=HF_TOKEN
|
556 |
+
)
|
557 |
+
else:
|
558 |
+
pipe.load_lora_weights(
|
559 |
+
lora_path,
|
560 |
+
weight_name=weight_name if weight_name else None,
|
561 |
+
low_cpu_mem_usage=True,
|
562 |
+
adapter_name=lora_name,
|
563 |
+
token=HF_TOKEN
|
564 |
+
)
|
565 |
+
print("Loaded LoRAs:", lora_names)
|
566 |
+
if selected_indices or is_valid_lora(lora_json):
|
567 |
if image_input is not None:
|
568 |
pipe_i2i.set_adapters(lora_names, adapter_weights=lora_weights)
|
569 |
else:
|