Commit
·
0fac10f
1
Parent(s):
9bd2ea4
Update app.py
Browse files
app.py
CHANGED
|
@@ -59,12 +59,9 @@ original_pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-
|
|
| 59 |
|
| 60 |
def merge_and_run(prompt, negative_prompt, shuffled_items, lora_1_scale=0.5, lora_2_scale=0.5, progress=gr.Progress(track_tqdm=True)):
|
| 61 |
state_dict_1 = copy.deepcopy(shuffled_items[0]['state_dict'])
|
| 62 |
-
print("state_1", state_dict_1)
|
| 63 |
state_dict_2 = copy.deepcopy(shuffled_items[1]['state_dict'])
|
| 64 |
-
print("state_2", state_dict_2)
|
| 65 |
pipe = copy.deepcopy(original_pipe)
|
| 66 |
-
pipe.to("cuda")
|
| 67 |
-
|
| 68 |
|
| 69 |
pipe.load_lora_weights(state_dict_1)
|
| 70 |
pipe.fuse_lora(lora_1_scale)
|
|
@@ -75,10 +72,10 @@ def merge_and_run(prompt, negative_prompt, shuffled_items, lora_1_scale=0.5, lor
|
|
| 75 |
negative_prompt = None
|
| 76 |
|
| 77 |
image = pipe(prompt=prompt, negative_prompt=negative_prompt, num_inference_steps=20, width=768, height=768).images[0]
|
| 78 |
-
yield image
|
| 79 |
del pipe
|
| 80 |
gc.collect()
|
| 81 |
torch.cuda.empty_cache()
|
|
|
|
| 82 |
|
| 83 |
def get_description(item):
|
| 84 |
trigger_word = item["trigger_word"]
|
|
|
|
| 59 |
|
| 60 |
def merge_and_run(prompt, negative_prompt, shuffled_items, lora_1_scale=0.5, lora_2_scale=0.5, progress=gr.Progress(track_tqdm=True)):
|
| 61 |
state_dict_1 = copy.deepcopy(shuffled_items[0]['state_dict'])
|
|
|
|
| 62 |
state_dict_2 = copy.deepcopy(shuffled_items[1]['state_dict'])
|
|
|
|
| 63 |
pipe = copy.deepcopy(original_pipe)
|
| 64 |
+
pipe.to("cuda")
|
|
|
|
| 65 |
|
| 66 |
pipe.load_lora_weights(state_dict_1)
|
| 67 |
pipe.fuse_lora(lora_1_scale)
|
|
|
|
| 72 |
negative_prompt = None
|
| 73 |
|
| 74 |
image = pipe(prompt=prompt, negative_prompt=negative_prompt, num_inference_steps=20, width=768, height=768).images[0]
|
|
|
|
| 75 |
del pipe
|
| 76 |
gc.collect()
|
| 77 |
torch.cuda.empty_cache()
|
| 78 |
+
return image
|
| 79 |
|
| 80 |
def get_description(item):
|
| 81 |
trigger_word = item["trigger_word"]
|