Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -109,23 +109,28 @@ def run_lora(prompt, lora_strings_json, cfg_scale, steps, randomize_seed, seed,
|
|
109 |
lora_configs = json.loads(lora_strings_json)
|
110 |
except:
|
111 |
lora_configs = None
|
|
|
|
|
112 |
if lora_configs:
|
113 |
with calculateDuration("Loading LoRA weights"):
|
114 |
-
pipe.
|
115 |
adapter_names = []
|
116 |
adapter_weights = []
|
117 |
for lora_info in lora_configs:
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
127 |
# set lora weights
|
128 |
-
|
|
|
129 |
|
130 |
# Set random seed for reproducibility
|
131 |
if randomize_seed:
|
|
|
109 |
lora_configs = json.loads(lora_strings_json)
|
110 |
except:
|
111 |
lora_configs = None
|
112 |
+
print("parse lora config json failed")
|
113 |
+
|
114 |
if lora_configs:
|
115 |
with calculateDuration("Loading LoRA weights"):
|
116 |
+
active_adapters = pipe.get_active_adapters()
|
117 |
adapter_names = []
|
118 |
adapter_weights = []
|
119 |
for lora_info in lora_configs:
|
120 |
+
lora_repo = lora_info.get("repo")
|
121 |
+
weights = lora_info.get("weights")
|
122 |
+
adapter_name = lora_info.get("adapter_name")
|
123 |
+
adapter_weight = lora_info.get("adapter_weight")
|
124 |
+
if adapter_name in active_adapters:
|
125 |
+
continue
|
126 |
+
if lora_repo and weights and adapter_name:
|
127 |
+
# load lora
|
128 |
+
pipe.load_lora_weights(lora_repo, weight_name=weights, adapter_name=adapter_name)
|
129 |
+
adapter_names.append(adapter_name)
|
130 |
+
adapter_weights.append(adapter_weight)
|
131 |
# set lora weights
|
132 |
+
if len(adapter_names) > 0:
|
133 |
+
pipe.set_adapters(adapter_names, adapter_weights=adapter_weights)
|
134 |
|
135 |
# Set random seed for reproducibility
|
136 |
if randomize_seed:
|