multimodalart HF staff commited on
Commit
0e74af9
1 Parent(s): 81147fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -108,7 +108,9 @@ def run_lora(prompt, cfg_scale, steps, selected_index, randomize_seed, seed, wid
108
  pipe.load_lora_weights(lora_path, weight_name=selected_lora["weights"])
109
  else:
110
  pipe.load_lora_weights(lora_path)
111
-
 
 
112
  # Set random seed for reproducibility
113
  with calculateDuration("Randomizing seed"):
114
  if randomize_seed:
@@ -122,8 +124,9 @@ def run_lora(prompt, cfg_scale, steps, selected_index, randomize_seed, seed, wid
122
  final_image = image
123
  yield image, seed # Yield intermediate images and seed
124
 
125
- pipe.to("cpu")
126
- pipe.unload_lora_weights()
 
127
 
128
  return final_image, seed # Return the final image and seed
129
 
 
108
  pipe.load_lora_weights(lora_path, weight_name=selected_lora["weights"])
109
  else:
110
  pipe.load_lora_weights(lora_path)
111
+ with calculateDuration(f"Fusing LoRA weights for {selected_lora['title']}"):
112
+ pipe.fuse_lora(lora_scale)
113
+
114
  # Set random seed for reproducibility
115
  with calculateDuration("Randomizing seed"):
116
  if randomize_seed:
 
124
  final_image = image
125
  yield image, seed # Yield intermediate images and seed
126
 
127
+ with calculateDuration("Unfuse and unload"):
128
+ pipe.unfuse_lora()
129
+ pipe.unload_lora_weights()
130
 
131
  return final_image, seed # Return the final image and seed
132