Commit
•
6b7c1b1
1
Parent(s):
ad569d5
Update app.py
Browse files
app.py
CHANGED
@@ -54,7 +54,7 @@ pipe.to(device)
|
|
54 |
|
55 |
last_lora = ""
|
56 |
last_merged = False
|
57 |
-
|
58 |
def update_selection(selected_state: gr.SelectData):
|
59 |
lora_repo = sdxl_loras[selected_state.index]["repo"]
|
60 |
instance_prompt = sdxl_loras[selected_state.index]["trigger_word"]
|
@@ -154,18 +154,20 @@ def run_lora(prompt, negative, lora_scale, selected_state, progress=gr.Progress(
|
|
154 |
gc.collect()
|
155 |
pipe = copy.deepcopy(original_pipe)
|
156 |
pipe.to(device)
|
157 |
-
|
158 |
pipe.unload_lora_weights()
|
159 |
pipe.unfuse_lora()
|
160 |
is_compatible = sdxl_loras[selected_state.index]["is_compatible"]
|
161 |
if is_compatible:
|
162 |
pipe.load_lora_weights(loaded_state_dict)
|
163 |
pipe.fuse_lora(lora_scale)
|
|
|
164 |
else:
|
165 |
is_pivotal = sdxl_loras[selected_state.index]["is_pivotal"]
|
166 |
if(is_pivotal):
|
167 |
pipe.load_lora_weights(loaded_state_dict)
|
168 |
pipe.fuse_lora(lora_scale)
|
|
|
169 |
|
170 |
#Add the textual inversion embeddings from pivotal tuning models
|
171 |
text_embedding_name = sdxl_loras[selected_state.index]["text_embedding_weights"]
|
@@ -174,9 +176,11 @@ def run_lora(prompt, negative, lora_scale, selected_state, progress=gr.Progress(
|
|
174 |
embedding_path = hf_hub_download(repo_id=repo_name, filename=text_embedding_name, repo_type="model")
|
175 |
embhandler = TokenEmbeddingsHandler(text_encoders, tokenizers)
|
176 |
embhandler.load_embeddings(embedding_path)
|
|
|
177 |
else:
|
178 |
merge_incompatible_lora(full_path_lora, lora_scale)
|
179 |
last_merged = True
|
|
|
180 |
|
181 |
image = pipe(
|
182 |
prompt=prompt,
|
|
|
54 |
|
55 |
last_lora = ""
|
56 |
last_merged = False
|
57 |
+
last_fused = False
|
58 |
def update_selection(selected_state: gr.SelectData):
|
59 |
lora_repo = sdxl_loras[selected_state.index]["repo"]
|
60 |
instance_prompt = sdxl_loras[selected_state.index]["trigger_word"]
|
|
|
154 |
gc.collect()
|
155 |
pipe = copy.deepcopy(original_pipe)
|
156 |
pipe.to(device)
|
157 |
+
elif(last_fused):
|
158 |
pipe.unload_lora_weights()
|
159 |
pipe.unfuse_lora()
|
160 |
is_compatible = sdxl_loras[selected_state.index]["is_compatible"]
|
161 |
if is_compatible:
|
162 |
pipe.load_lora_weights(loaded_state_dict)
|
163 |
pipe.fuse_lora(lora_scale)
|
164 |
+
last_fused = True
|
165 |
else:
|
166 |
is_pivotal = sdxl_loras[selected_state.index]["is_pivotal"]
|
167 |
if(is_pivotal):
|
168 |
pipe.load_lora_weights(loaded_state_dict)
|
169 |
pipe.fuse_lora(lora_scale)
|
170 |
+
last_fused = True
|
171 |
|
172 |
#Add the textual inversion embeddings from pivotal tuning models
|
173 |
text_embedding_name = sdxl_loras[selected_state.index]["text_embedding_weights"]
|
|
|
176 |
embedding_path = hf_hub_download(repo_id=repo_name, filename=text_embedding_name, repo_type="model")
|
177 |
embhandler = TokenEmbeddingsHandler(text_encoders, tokenizers)
|
178 |
embhandler.load_embeddings(embedding_path)
|
179 |
+
|
180 |
else:
|
181 |
merge_incompatible_lora(full_path_lora, lora_scale)
|
182 |
last_merged = True
|
183 |
+
last_fused=False
|
184 |
|
185 |
image = pipe(
|
186 |
prompt=prompt,
|