Spaces:
Paused
Paused
Update app_lora_cpu.py
Browse files- app_lora_cpu.py +89 -32
app_lora_cpu.py
CHANGED
|
@@ -57,55 +57,112 @@ pipe.load_lora_weights(
|
|
| 57 |
)
|
| 58 |
kwargs_lora = {}
|
| 59 |
kwargs_lora["load_into_transformer_2"] = True
|
| 60 |
-
|
| 61 |
-
|
| 62 |
pipe.load_lora_weights(
|
| 63 |
"Kijai/WanVideo_comfy",
|
| 64 |
weight_name="Lightx2v/lightx2v_I2V_14B_480p_cfg_step_distill_rank128_bf16.safetensors",
|
| 65 |
adapter_name="lightx2v_2", **kwargs_lora
|
| 66 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
-
#
|
| 71 |
-
|
| 72 |
pipe.load_lora_weights(
|
| 73 |
-
"
|
| 74 |
-
weight_name="
|
| 75 |
-
adapter_name="
|
| 76 |
token=os.environ.get("HF_TOKEN")
|
| 77 |
)
|
| 78 |
-
#
|
| 79 |
pipe.load_lora_weights(
|
| 80 |
-
"
|
| 81 |
-
weight_name="
|
| 82 |
-
adapter_name="
|
| 83 |
token=os.environ.get("HF_TOKEN"),
|
| 84 |
load_into_transformer_2=True
|
| 85 |
)
|
| 86 |
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
#
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
#
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
#
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
#
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
pipe.unload_lora_weights()
|
| 110 |
|
| 111 |
quantize_(pipe.text_encoder, Int8WeightOnlyConfig())
|
|
|
|
| 57 |
)
|
| 58 |
kwargs_lora = {}
|
| 59 |
kwargs_lora["load_into_transformer_2"] = True
|
|
|
|
|
|
|
| 60 |
pipe.load_lora_weights(
|
| 61 |
"Kijai/WanVideo_comfy",
|
| 62 |
weight_name="Lightx2v/lightx2v_I2V_14B_480p_cfg_step_distill_rank128_bf16.safetensors",
|
| 63 |
adapter_name="lightx2v_2", **kwargs_lora
|
| 64 |
)
|
| 65 |
+
# 原始:加载 v8nomal high noise LoRA
|
| 66 |
+
pipe.load_lora_weights(
|
| 67 |
+
"mimigona1/twote2",
|
| 68 |
+
weight_name="ultrade_high.safetensors",
|
| 69 |
+
adapter_name="high_noise_lora",
|
| 70 |
+
token=os.environ.get("HF_TOKEN")
|
| 71 |
+
)
|
| 72 |
+
# 原始:加载 v8nomal low noise LoRA
|
| 73 |
+
pipe.load_lora_weights(
|
| 74 |
+
"mimigona1/twote2",
|
| 75 |
+
weight_name="ultrade_low.safetensors",
|
| 76 |
+
adapter_name="low_noise_lora",
|
| 77 |
+
token=os.environ.get("HF_TOKEN"),
|
| 78 |
+
load_into_transformer_2=True
|
| 79 |
+
)
|
| 80 |
|
| 81 |
+
# 新增:加载 high noise LoRA (dremal)
|
| 82 |
+
pipe.load_lora_weights(
|
| 83 |
+
"mimigona1/twote2",
|
| 84 |
+
weight_name="pusylick_high.safetensors",
|
| 85 |
+
adapter_name="high_dremal_lora",
|
| 86 |
+
token=os.environ.get("HF_TOKEN")
|
| 87 |
+
)
|
| 88 |
+
# 新增:加载 low noise LoRA (dremal)
|
| 89 |
+
pipe.load_lora_weights(
|
| 90 |
+
"mimigona1/twote2",
|
| 91 |
+
weight_name="pusylick_low.safetensors",
|
| 92 |
+
adapter_name="low_dremal_lora",
|
| 93 |
+
token=os.environ.get("HF_TOKEN"),
|
| 94 |
+
load_into_transformer_2=True
|
| 95 |
+
)
|
| 96 |
|
| 97 |
+
# 🚀 增加额外新 LoRA 1: missimd_high.safetensors (high noise)
|
| 98 |
+
pipe.load_lora_weights(
|
| 99 |
+
"mimigona1/twote2",
|
| 100 |
+
weight_name="redouble_high.safetensors",
|
| 101 |
+
adapter_name="high_missimd_lora", # 新增 adapter name
|
| 102 |
+
token=os.environ.get("HF_TOKEN")
|
| 103 |
+
)
|
| 104 |
+
# 🚀 增加额外新 LoRA 1: missimd_low.safetensors (low noise)
|
| 105 |
+
pipe.load_lora_weights(
|
| 106 |
+
"mimigona1/twote2",
|
| 107 |
+
weight_name="redouble_low.safetensors",
|
| 108 |
+
adapter_name="low_missimd_lora", # 新增 adapter name
|
| 109 |
+
token=os.environ.get("HF_TOKEN"),
|
| 110 |
+
load_into_transformer_2=True
|
| 111 |
+
)
|
| 112 |
|
| 113 |
+
# 🚀 增加额外新 LoRA 2: sitfov_high.safetensors (high noise) - 配置与 dremal 一致
|
|
|
|
| 114 |
pipe.load_lora_weights(
|
| 115 |
+
"mimigona1/twote2",
|
| 116 |
+
weight_name="dog02_high.safetensors",
|
| 117 |
+
adapter_name="high_ultrade_lora", # 适配器名称
|
| 118 |
token=os.environ.get("HF_TOKEN")
|
| 119 |
)
|
| 120 |
+
# 🚀 增加额外新 LoRA 2: sitfov_low.safetensors (low noise) - 配置与 dremal 一致
|
| 121 |
pipe.load_lora_weights(
|
| 122 |
+
"mimigona1/twote2",
|
| 123 |
+
weight_name="dog02_low.safetensors",
|
| 124 |
+
adapter_name="low_ultrade_lora", # 适配器名称
|
| 125 |
token=os.environ.get("HF_TOKEN"),
|
| 126 |
load_into_transformer_2=True
|
| 127 |
)
|
| 128 |
|
| 129 |
|
| 130 |
+
# 修改 set_adapters: 包含所有 LoRA
|
| 131 |
+
pipe.set_adapters(
|
| 132 |
+
[
|
| 133 |
+
"lightx2v", "lightx2v_2",
|
| 134 |
+
"high_noise_lora", "low_noise_lora",
|
| 135 |
+
"high_dremal_lora", "low_dremal_lora",
|
| 136 |
+
"high_missimd_lora", "low_missimd_lora", # 🚀 新增 missimd LoRA
|
| 137 |
+
"high_ultrade_lora", "low_ultrade_lora" # 🚀 新增 ultrade LoRA
|
| 138 |
+
],
|
| 139 |
+
# 权重列表对应上述适配器。missimd 和 ultrade 均设置为 1.0
|
| 140 |
+
adapter_weights=[1.5, 1.2, 0,0 , 0.7, 0.7, 0.7, 0.7, 0.7, 0.7]
|
| 141 |
+
)
|
| 142 |
+
# 修改 fuse_lora (transformer): 加入 high_missimd_lora, high_ultrade_lora (lora_scale=2.0)
|
| 143 |
+
pipe.fuse_lora(
|
| 144 |
+
adapter_names=[
|
| 145 |
+
"lightx2v",
|
| 146 |
+
"high_noise_lora",
|
| 147 |
+
"high_dremal_lora",
|
| 148 |
+
"high_missimd_lora", # 🚀 新增
|
| 149 |
+
"high_ultrade_lora" # 🚀 新增
|
| 150 |
+
],
|
| 151 |
+
lora_scales=[4.0, 3.0, 2.0, 2.0, 2.0], # 🚀 missimd 和 ultrade scale 设置为 2.0
|
| 152 |
+
components=["transformer"]
|
| 153 |
+
)
|
| 154 |
+
# 修改 fuse_lora (transformer_2): 加入 low_missimd_lora, low_ultrade_lora (lora_scale=1.0)
|
| 155 |
+
pipe.fuse_lora(
|
| 156 |
+
adapter_names=[
|
| 157 |
+
"lightx2v_2",
|
| 158 |
+
"low_noise_lora",
|
| 159 |
+
"low_dremal_lora",
|
| 160 |
+
"low_missimd_lora", # 🚀 新增
|
| 161 |
+
"low_ultrade_lora" # 🚀 新增
|
| 162 |
+
],
|
| 163 |
+
lora_scales=[2.0, 1.5, 1.0, 1.0, 1.0], # 🚀 missimd 和 ultrade scale 设置为 1.0
|
| 164 |
+
components=["transformer_2"]
|
| 165 |
+
)
|
| 166 |
pipe.unload_lora_weights()
|
| 167 |
|
| 168 |
quantize_(pipe.text_encoder, Int8WeightOnlyConfig())
|