Commit
·
c7fa047
1
Parent(s):
965ea29
Update app.py
Browse files
app.py
CHANGED
|
@@ -91,16 +91,18 @@ original_pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-
|
|
| 91 |
def merge_and_run(prompt, negative_prompt, shuffled_items, lora_1_scale=0.5, lora_2_scale=0.5, seed=-1, progress=gr.Progress(track_tqdm=True)):
|
| 92 |
repo_id_1 = shuffled_items[0]['repo']
|
| 93 |
repo_id_2 = shuffled_items[1]['repo']
|
|
|
|
| 94 |
state_dict_1 = copy.deepcopy(state_dicts[repo_id_1]["state_dict"])
|
| 95 |
state_dict_2 = copy.deepcopy(state_dicts[repo_id_2]["state_dict"])
|
|
|
|
| 96 |
pipe = copy.deepcopy(original_pipe)
|
| 97 |
pipe.to("cuda")
|
| 98 |
-
|
| 99 |
-
pipe.load_lora_weights(state_dict_1)
|
| 100 |
pipe.fuse_lora(lora_1_scale)
|
| 101 |
-
pipe.load_lora_weights(state_dict_2)
|
| 102 |
pipe.fuse_lora(lora_2_scale)
|
| 103 |
-
|
| 104 |
if negative_prompt == "":
|
| 105 |
negative_prompt = None
|
| 106 |
|
|
|
|
| 91 |
def merge_and_run(prompt, negative_prompt, shuffled_items, lora_1_scale=0.5, lora_2_scale=0.5, seed=-1, progress=gr.Progress(track_tqdm=True)):
|
| 92 |
repo_id_1 = shuffled_items[0]['repo']
|
| 93 |
repo_id_2 = shuffled_items[1]['repo']
|
| 94 |
+
print("Loading state dicts...")
|
| 95 |
state_dict_1 = copy.deepcopy(state_dicts[repo_id_1]["state_dict"])
|
| 96 |
state_dict_2 = copy.deepcopy(state_dicts[repo_id_2]["state_dict"])
|
| 97 |
+
print("Loaded state dicts.")
|
| 98 |
pipe = copy.deepcopy(original_pipe)
|
| 99 |
pipe.to("cuda")
|
| 100 |
+
print("Loading LoRA weights...")
|
| 101 |
+
pipe.load_lora_weights(state_dict_1.to("cuda"))
|
| 102 |
pipe.fuse_lora(lora_1_scale)
|
| 103 |
+
pipe.load_lora_weights(state_dict_2.to("cuda"))
|
| 104 |
pipe.fuse_lora(lora_2_scale)
|
| 105 |
+
print("Loaded LoRA weights.")
|
| 106 |
if negative_prompt == "":
|
| 107 |
negative_prompt = None
|
| 108 |
|