Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
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 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
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)
|