Spaces:
Paused
Paused
Commit
•
e04dd59
1
Parent(s):
3e0af01
Update app.py
Browse files
app.py
CHANGED
@@ -36,8 +36,8 @@ pipe = StableDiffusionXLPipeline.from_pretrained(
|
|
36 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
37 |
vae=vae,
|
38 |
torch_dtype=torch.float16,
|
39 |
-
).to(
|
40 |
-
|
41 |
pipe.to(device)
|
42 |
|
43 |
last_lora = ""
|
@@ -136,11 +136,10 @@ def run_lora(prompt, negative, lora_scale, selected_state):
|
|
136 |
cross_attention_kwargs = None
|
137 |
if last_lora != repo_name:
|
138 |
if last_merged:
|
139 |
-
pipe
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
).to(device)
|
144 |
else:
|
145 |
pipe.unload_lora_weights()
|
146 |
is_compatible = sdxl_loras[selected_state.index]["is_compatible"]
|
@@ -162,6 +161,7 @@ def run_lora(prompt, negative, lora_scale, selected_state):
|
|
162 |
cross_attention_kwargs=cross_attention_kwargs,
|
163 |
).images[0]
|
164 |
last_lora = repo_name
|
|
|
165 |
return image, gr.update(visible=True)
|
166 |
|
167 |
|
|
|
36 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
37 |
vae=vae,
|
38 |
torch_dtype=torch.float16,
|
39 |
+
).to("cpu")
|
40 |
+
original_pipe = copy.deepcopy(pipe)
|
41 |
pipe.to(device)
|
42 |
|
43 |
last_lora = ""
|
|
|
136 |
cross_attention_kwargs = None
|
137 |
if last_lora != repo_name:
|
138 |
if last_merged:
|
139 |
+
del pipe
|
140 |
+
gc.collect()
|
141 |
+
pipe = copy.deepcopy(original_pipe)
|
142 |
+
pipe.to(device)
|
|
|
143 |
else:
|
144 |
pipe.unload_lora_weights()
|
145 |
is_compatible = sdxl_loras[selected_state.index]["is_compatible"]
|
|
|
161 |
cross_attention_kwargs=cross_attention_kwargs,
|
162 |
).images[0]
|
163 |
last_lora = repo_name
|
164 |
+
gc.collect()
|
165 |
return image, gr.update(visible=True)
|
166 |
|
167 |
|