Spaces:
Running
on
A100
Running
on
A100
Commit
•
3dccffc
1
Parent(s):
79a1e5b
Update app.py
Browse files
app.py
CHANGED
@@ -154,19 +154,15 @@ def run_lora(prompt, negative, lora_scale, selected_state, sdxl_loras, progress=
|
|
154 |
full_path_lora = state_dicts[repo_name]["saved_name"]
|
155 |
loaded_state_dict = state_dicts[repo_name]["state_dict"]
|
156 |
cross_attention_kwargs = None
|
157 |
-
|
158 |
-
print("Last LoRA:", last_lora, "Was it last merged? ", last_merged, "Was it last fused?", last_fused)
|
159 |
-
print("Current LoRA: ", repo_name)
|
160 |
-
|
161 |
if last_lora != repo_name:
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
is_compatible = sdxl_loras[selected_state.index]["is_compatible"]
|
171 |
|
172 |
if is_compatible:
|
@@ -187,6 +183,7 @@ def run_lora(prompt, negative, lora_scale, selected_state, sdxl_loras, progress=
|
|
187 |
embedding_path = hf_hub_download(repo_id=repo_name, filename=text_embedding_name, repo_type="model")
|
188 |
embhandler = TokenEmbeddingsHandler(text_encoders, tokenizers)
|
189 |
embhandler.load_embeddings(embedding_path)
|
|
|
190 |
else:
|
191 |
merge_incompatible_lora(full_path_lora, lora_scale)
|
192 |
last_fused=False
|
@@ -198,7 +195,6 @@ def run_lora(prompt, negative, lora_scale, selected_state, sdxl_loras, progress=
|
|
198 |
width=1024,
|
199 |
height=1024,
|
200 |
num_inference_steps=20,
|
201 |
-
cross_attention_kwargs = {"scale" : lora_scale},
|
202 |
guidance_scale=7.5,
|
203 |
).images[0]
|
204 |
last_lora = repo_name
|
|
|
154 |
full_path_lora = state_dicts[repo_name]["saved_name"]
|
155 |
loaded_state_dict = state_dicts[repo_name]["state_dict"]
|
156 |
cross_attention_kwargs = None
|
|
|
|
|
|
|
|
|
157 |
if last_lora != repo_name:
|
158 |
+
if last_merged:
|
159 |
+
del pipe
|
160 |
+
gc.collect()
|
161 |
+
pipe = copy.deepcopy(original_pipe)
|
162 |
+
pipe.to(device)
|
163 |
+
elif(last_fused):
|
164 |
+
pipe.unfuse_lora()
|
165 |
+
pipe.unload_lora_weights()
|
166 |
is_compatible = sdxl_loras[selected_state.index]["is_compatible"]
|
167 |
|
168 |
if is_compatible:
|
|
|
183 |
embedding_path = hf_hub_download(repo_id=repo_name, filename=text_embedding_name, repo_type="model")
|
184 |
embhandler = TokenEmbeddingsHandler(text_encoders, tokenizers)
|
185 |
embhandler.load_embeddings(embedding_path)
|
186 |
+
|
187 |
else:
|
188 |
merge_incompatible_lora(full_path_lora, lora_scale)
|
189 |
last_fused=False
|
|
|
195 |
width=1024,
|
196 |
height=1024,
|
197 |
num_inference_steps=20,
|
|
|
198 |
guidance_scale=7.5,
|
199 |
).images[0]
|
200 |
last_lora = repo_name
|