Update app.py
Browse files
app.py
CHANGED
|
@@ -469,10 +469,13 @@ def run_lora(prompt, cfg_scale, steps, selected_indices, lora_scale_1, lora_scal
|
|
| 469 |
appends.append(trigger_word)
|
| 470 |
prompt_mash = " ".join(prepends + [prompt] + appends)
|
| 471 |
print("Prompt Mash: ", prompt_mash)
|
|
|
|
| 472 |
|
| 473 |
# Unload previous LoRA weights
|
| 474 |
with calculateDuration("Unloading LoRA"):
|
| 475 |
pipe.unload_lora_weights()
|
|
|
|
|
|
|
| 476 |
|
| 477 |
# Load LoRA weights
|
| 478 |
lora_names = []
|
|
@@ -481,6 +484,7 @@ def run_lora(prompt, cfg_scale, steps, selected_indices, lora_scale_1, lora_scal
|
|
| 481 |
for idx, lora in enumerate(selected_loras):
|
| 482 |
lora_name = f"lora_{idx}"
|
| 483 |
lora_names.append(lora_name)
|
|
|
|
| 484 |
lora_weights.append(lora_scale_1 if idx == 0 else lora_scale_2)
|
| 485 |
pipe.load_lora_weights(
|
| 486 |
lora['repo'],
|
|
@@ -488,6 +492,10 @@ def run_lora(prompt, cfg_scale, steps, selected_indices, lora_scale_1, lora_scal
|
|
| 488 |
low_cpu_mem_usage=True,
|
| 489 |
adapter_name=lora_name,
|
| 490 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 491 |
pipe.set_adapters(lora_names, adapter_weights=lora_weights)
|
| 492 |
|
| 493 |
# Set random seed if required
|
|
@@ -584,7 +592,7 @@ css = '''
|
|
| 584 |
#component-11{align-self: stretch;}
|
| 585 |
'''
|
| 586 |
font=[gr.themes.GoogleFont("Source Sans Pro"), "Arial", "sans-serif"]
|
| 587 |
-
with gr.Blocks(theme=gr.themes.Soft(font=font), css=css, delete_cache=(
|
| 588 |
title = gr.HTML(
|
| 589 |
"""<h1><img src="https://huggingface.co/spaces/keltezaa/Celebrity_pony_NSFW_Mix/resolve/main/solo-traveller_16875043.png" alt="LoRA"> Celebrity Pony NSFW Mix</h1>""",
|
| 590 |
elem_id="title",
|
|
|
|
| 469 |
appends.append(trigger_word)
|
| 470 |
prompt_mash = " ".join(prepends + [prompt] + appends)
|
| 471 |
print("Prompt Mash: ", prompt_mash)
|
| 472 |
+
print("--Seed--:", seed)
|
| 473 |
|
| 474 |
# Unload previous LoRA weights
|
| 475 |
with calculateDuration("Unloading LoRA"):
|
| 476 |
pipe.unload_lora_weights()
|
| 477 |
+
|
| 478 |
+
print(pipe.get_active_adapters())
|
| 479 |
|
| 480 |
# Load LoRA weights
|
| 481 |
lora_names = []
|
|
|
|
| 484 |
for idx, lora in enumerate(selected_loras):
|
| 485 |
lora_name = f"lora_{idx}"
|
| 486 |
lora_names.append(lora_name)
|
| 487 |
+
print(f"Lora Name: {lora_name}")
|
| 488 |
lora_weights.append(lora_scale_1 if idx == 0 else lora_scale_2)
|
| 489 |
pipe.load_lora_weights(
|
| 490 |
lora['repo'],
|
|
|
|
| 492 |
low_cpu_mem_usage=True,
|
| 493 |
adapter_name=lora_name,
|
| 494 |
)
|
| 495 |
+
|
| 496 |
+
print("Loaded LoRAs:", lora_names)
|
| 497 |
+
print("Adapter weights:", lora_weights)
|
| 498 |
+
|
| 499 |
pipe.set_adapters(lora_names, adapter_weights=lora_weights)
|
| 500 |
|
| 501 |
# Set random seed if required
|
|
|
|
| 592 |
#component-11{align-self: stretch;}
|
| 593 |
'''
|
| 594 |
font=[gr.themes.GoogleFont("Source Sans Pro"), "Arial", "sans-serif"]
|
| 595 |
+
with gr.Blocks(theme=gr.themes.Soft(font=font), css=css, delete_cache=(128, 256)) as app:
|
| 596 |
title = gr.HTML(
|
| 597 |
"""<h1><img src="https://huggingface.co/spaces/keltezaa/Celebrity_pony_NSFW_Mix/resolve/main/solo-traveller_16875043.png" alt="LoRA"> Celebrity Pony NSFW Mix</h1>""",
|
| 598 |
elem_id="title",
|