jiuface commited on
Commit
f5582fe
1 Parent(s): 5481b33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -182,11 +182,12 @@ def load_loras(lora_strings_json:str):
182
  try:
183
  lora_configs = json.loads(lora_strings_json)
184
  except:
185
- print("parse lora failed")
186
 
187
  if lora_configs:
 
188
  with calculateDuration("Loading LoRA weights"):
189
- pipe.unload_lora_weights()
190
  adapter_names = []
191
  adapter_weights = []
192
  for lora_info in lora_configs:
@@ -196,11 +197,15 @@ def load_loras(lora_strings_json:str):
196
  adapter_weight = lora_info.get("adapter_weight")
197
  if lora_repo and weights and adapter_name:
198
  # load lora
199
- pipe.load_lora_weights(lora_repo, weight_name=weights, adapter_name=adapter_name)
200
- adapter_names.append(adapter_name)
201
- adapter_weights.append(adapter_weight)
 
 
 
202
  # set lora weights
203
- pipe.set_adapters(adapter_names, adapter_weights=adapter_weights)
 
204
 
205
 
206
  def generate_control_image(image, mask, width, height):
 
182
  try:
183
  lora_configs = json.loads(lora_strings_json)
184
  except:
185
+ print("parse lora configs failed")
186
 
187
  if lora_configs:
188
+
189
  with calculateDuration("Loading LoRA weights"):
190
+ active_adapters = pipe.get_active_adapters()
191
  adapter_names = []
192
  adapter_weights = []
193
  for lora_info in lora_configs:
 
197
  adapter_weight = lora_info.get("adapter_weight")
198
  if lora_repo and weights and adapter_name:
199
  # load lora
200
+ if adapter_name in active_adapters:
201
+ continue
202
+ else:
203
+ pipe.load_lora_weights(lora_repo, weight_name=weights, adapter_name=adapter_name)
204
+ adapter_names.append(adapter_name)
205
+ adapter_weights.append(adapter_weight)
206
  # set lora weights
207
+ if len(adapter_names) > 0:
208
+ pipe.set_adapters(adapter_names, adapter_weights=adapter_weights)
209
 
210
 
211
  def generate_control_image(image, mask, width, height):