multimodalart HF staff commited on
Commit
a99e3b7
β€’
1 Parent(s): f08f681

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -12
app.py CHANGED
@@ -149,15 +149,14 @@ def run_lora(prompt, negative, lora_scale, selected_state, progress=gr.Progress(
149
  loaded_state_dict = sdxl_loras[selected_state.index]["state_dict"]
150
  cross_attention_kwargs = None
151
  if last_lora != repo_name:
152
- pipe = copy.deepcopy(original_pipe)
153
- pipe.to(device)
154
- #if last_merged:
155
- # del pipe
156
- # gc.collect()
157
-
158
- #elif(last_fused):
159
- # pipe.unfuse_lora()
160
- # pipe.unload_lora_weights()
161
  is_compatible = sdxl_loras[selected_state.index]["is_compatible"]
162
 
163
  if is_compatible:
@@ -181,10 +180,9 @@ def run_lora(prompt, negative, lora_scale, selected_state, progress=gr.Progress(
181
 
182
  else:
183
  merge_incompatible_lora(full_path_lora, lora_scale)
184
- last_fused = False
185
-
186
  last_merged = True
187
-
188
  image = pipe(
189
  prompt=prompt,
190
  negative_prompt=negative,
 
149
  loaded_state_dict = sdxl_loras[selected_state.index]["state_dict"]
150
  cross_attention_kwargs = None
151
  if last_lora != repo_name:
152
+ if last_merged:
153
+ del pipe
154
+ gc.collect()
155
+ pipe = copy.deepcopy(original_pipe)
156
+ pipe.to(device)
157
+ elif(last_fused):
158
+ pipe.unfuse_lora()
159
+ pipe.unload_lora_weights()
 
160
  is_compatible = sdxl_loras[selected_state.index]["is_compatible"]
161
 
162
  if is_compatible:
 
180
 
181
  else:
182
  merge_incompatible_lora(full_path_lora, lora_scale)
183
+ last_fused=False
 
184
  last_merged = True
185
+
186
  image = pipe(
187
  prompt=prompt,
188
  negative_prompt=negative,