multimodalart HF staff commited on
Commit
79a1e5b
β€’
1 Parent(s): 85fa60e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -154,28 +154,30 @@ 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
  print("Last LoRA:", last_lora, "Was it last merged? ", last_merged, "Was it last fused?", last_fused)
158
  print("Current LoRA: ", repo_name)
 
159
  if last_lora != repo_name:
160
- if last_merged:
161
- del pipe
162
- gc.collect()
163
- pipe = copy.deepcopy(original_pipe)
164
- pipe.to(device)
165
- elif(last_fused):
166
  #pipe.unfuse_lora()
167
- pipe.unload_lora_weights()
168
  is_compatible = sdxl_loras[selected_state.index]["is_compatible"]
169
 
170
  if is_compatible:
171
  pipe.load_lora_weights(loaded_state_dict)
172
- #pipe.fuse_lora(lora_scale)
173
  last_fused = True
174
  else:
175
  is_pivotal = sdxl_loras[selected_state.index]["is_pivotal"]
176
  if(is_pivotal):
177
  pipe.load_lora_weights(loaded_state_dict)
178
- #pipe.fuse_lora(lora_scale)
179
  last_fused = True
180
 
181
  #Add the textual inversion embeddings from pivotal tuning models
 
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
+ #if last_merged:
163
+ del pipe
164
+ gc.collect()
165
+ pipe = copy.deepcopy(original_pipe)
166
+ pipe.to(device)
167
+ #elif(last_fused):
168
  #pipe.unfuse_lora()
169
+ #pipe.unload_lora_weights()
170
  is_compatible = sdxl_loras[selected_state.index]["is_compatible"]
171
 
172
  if is_compatible:
173
  pipe.load_lora_weights(loaded_state_dict)
174
+ pipe.fuse_lora(lora_scale)
175
  last_fused = True
176
  else:
177
  is_pivotal = sdxl_loras[selected_state.index]["is_pivotal"]
178
  if(is_pivotal):
179
  pipe.load_lora_weights(loaded_state_dict)
180
+ pipe.fuse_lora(lora_scale)
181
  last_fused = True
182
 
183
  #Add the textual inversion embeddings from pivotal tuning models