Update app.py
Browse files
app.py
CHANGED
|
@@ -797,21 +797,31 @@ def prepare_env(char_enable: bool, char_lora: str, unet_choice: str, task_id: st
|
|
| 797 |
|
| 798 |
def select_base_loras(engine: str, lora_states: tuple) -> list[tuple[str, float]]:
|
| 799 |
selected = []
|
| 800 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 801 |
for i in range(0, len(lora_states), 2):
|
| 802 |
enable = lora_states[i]
|
| 803 |
try:
|
| 804 |
strength = float(lora_states[i + 1])
|
| 805 |
except (ValueError, TypeError):
|
| 806 |
strength = 1.0
|
| 807 |
-
if enable and strength > 0:
|
| 808 |
-
lora_name, lora_cfg = base_choices_list[i // 2]
|
| 809 |
|
| 810 |
-
|
| 811 |
-
|
| 812 |
-
|
| 813 |
-
if
|
|
|
|
| 814 |
selected.append((lora_cfg["filename"], strength))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 815 |
return selected
|
| 816 |
|
| 817 |
def _build_clip_inputs(engine_cfg: dict, clip_loader_node: str) -> dict:
|
|
|
|
| 797 |
|
| 798 |
def select_base_loras(engine: str, lora_states: tuple) -> list[tuple[str, float]]:
|
| 799 |
selected = []
|
| 800 |
+
|
| 801 |
+
# 找出当前引擎专属的 Base LoRA 列表,保持顺序
|
| 802 |
+
valid_loras = []
|
| 803 |
+
for name, cfg in BASE_LORAS_CHOICES.items():
|
| 804 |
+
if cfg["engine"] == engine:
|
| 805 |
+
valid_loras.append((name, cfg))
|
| 806 |
+
|
| 807 |
+
# 解析前端传来的勾选状态
|
| 808 |
for i in range(0, len(lora_states), 2):
|
| 809 |
enable = lora_states[i]
|
| 810 |
try:
|
| 811 |
strength = float(lora_states[i + 1])
|
| 812 |
except (ValueError, TypeError):
|
| 813 |
strength = 1.0
|
|
|
|
|
|
|
| 814 |
|
| 815 |
+
if enable and strength > 0:
|
| 816 |
+
# 如果前端的数组长度和当前引擎实际可用的 LoRA 列表长度一致
|
| 817 |
+
idx = i // 2
|
| 818 |
+
if idx < len(valid_loras):
|
| 819 |
+
lora_name, lora_cfg = valid_loras[idx]
|
| 820 |
selected.append((lora_cfg["filename"], strength))
|
| 821 |
+
|
| 822 |
+
# 你的探针(保留观察)
|
| 823 |
+
print(f"[LoRA选择探针] ✅ 成功匹配并加载: {lora_name} ({strength})")
|
| 824 |
+
|
| 825 |
return selected
|
| 826 |
|
| 827 |
def _build_clip_inputs(engine_cfg: dict, clip_loader_node: str) -> dict:
|