jiuface commited on
Commit
8cf9808
1 Parent(s): f5582fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -12
app.py CHANGED
@@ -191,18 +191,23 @@ def load_loras(lora_strings_json:str):
191
  adapter_names = []
192
  adapter_weights = []
193
  for lora_info in lora_configs:
194
- lora_repo = lora_info.get("repo")
195
- weights = lora_info.get("weights")
196
- adapter_name = lora_info.get("adapter_name")
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)
 
191
  adapter_names = []
192
  adapter_weights = []
193
  for lora_info in lora_configs:
194
+ lora_repo = lora_info.get("repo")
195
+ weights = lora_info.get("weights")
196
+ adapter_name = lora_info.get("adapter_name")
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
+ print(f"Adapter '{adapter_name}' is already loaded, skipping.")
202
+ continue
203
+
204
+ try:
205
+ pipe.load_lora_weights(lora_repo, weight_name=weights, adapter_name=adapter_name)
206
+ except ValueError as e:
207
+ print(f"Error loading LoRA adapter: {e}")
208
+ continue
209
+ adapter_names.append(adapter_name)
210
+ adapter_weights.append(adapter_weight)
211
  # set lora weights
212
  if len(adapter_names) > 0:
213
  pipe.set_adapters(adapter_names, adapter_weights=adapter_weights)