Spaces:
Runtime error
Runtime error
Update optimization.py
Browse files- optimization.py +12 -10
optimization.py
CHANGED
|
@@ -52,24 +52,26 @@ def optimize_pipeline_(pipeline: Callable[P, Any], *args: P.args, **kwargs: P.kw
|
|
| 52 |
# --- LoRA 2: lightning_2 (loads into transformer_2) ---
|
| 53 |
kwargs_lora = {"load_into_transformer_2": True}
|
| 54 |
pipeline.load_lora_weights(
|
| 55 |
-
"
|
| 56 |
-
weight_name="
|
| 57 |
adapter_name="lightning_2",
|
| 58 |
**kwargs_lora,
|
| 59 |
)
|
| 60 |
|
| 61 |
# --- LoRA 3: orbit_shot (the ostris repo you asked for) ---
|
| 62 |
# Load into transformer_2 as well (set load_into_transformer_2 True if this adapter targets transformer_2)
|
| 63 |
-
pipeline.load_lora_weights(
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
)
|
| 69 |
|
| 70 |
# Register adapters and their relative weights
|
| 71 |
# (adjust adapter_weights to taste; here each is weight 1.0)
|
| 72 |
-
pipeline.set_adapters(["lightning", "lightning_2", "orbit_shot"], adapter_weights=[1.0, 1.0, 1.0])
|
|
|
|
|
|
|
| 73 |
|
| 74 |
# Fuse each adapter into the correct component with chosen lora_scale:
|
| 75 |
# - lightning -> transformer (boosted by 3x in your original)
|
|
@@ -77,7 +79,7 @@ def optimize_pipeline_(pipeline: Callable[P, Any], *args: P.args, **kwargs: P.kw
|
|
| 77 |
# - orbit_shot -> transformer_2 (or transformer depending on the LoRA design)
|
| 78 |
pipeline.fuse_lora(adapter_names=["lightning"], lora_scale=3.0, components=["transformer"])
|
| 79 |
pipeline.fuse_lora(adapter_names=["lightning_2"], lora_scale=1.0, components=["transformer_2"])
|
| 80 |
-
pipeline.fuse_lora(adapter_names=["orbit_shot"], lora_scale=1.0, components=["transformer_2"])
|
| 81 |
|
| 82 |
# After fusing, you can unload LoRA weights to free memory (fused weights remain applied)
|
| 83 |
pipeline.unload_lora_weights()
|
|
|
|
| 52 |
# --- LoRA 2: lightning_2 (loads into transformer_2) ---
|
| 53 |
kwargs_lora = {"load_into_transformer_2": True}
|
| 54 |
pipeline.load_lora_weights(
|
| 55 |
+
"deadman44/Wan2.2_T2i_T2v_LoRA",
|
| 56 |
+
weight_name="lora_wan2.2_myjd_Low_v01.safetensors",
|
| 57 |
adapter_name="lightning_2",
|
| 58 |
**kwargs_lora,
|
| 59 |
)
|
| 60 |
|
| 61 |
# --- LoRA 3: orbit_shot (the ostris repo you asked for) ---
|
| 62 |
# Load into transformer_2 as well (set load_into_transformer_2 True if this adapter targets transformer_2)
|
| 63 |
+
# pipeline.load_lora_weights(
|
| 64 |
+
# "ostris/wan22_i2v_14b_orbit_shot_lora",
|
| 65 |
+
# weight_name="wan22_14b_i2v_orbit_low_noise.safetensors",
|
| 66 |
+
# adapter_name="orbit_shot",
|
| 67 |
+
# **kwargs_lora,
|
| 68 |
+
# )
|
| 69 |
|
| 70 |
# Register adapters and their relative weights
|
| 71 |
# (adjust adapter_weights to taste; here each is weight 1.0)
|
| 72 |
+
#pipeline.set_adapters(["lightning", "lightning_2", "orbit_shot"], adapter_weights=[1.0, 1.0, 1.0])
|
| 73 |
+
pipeline.set_adapters(["lightning", "lightning_2", "orbit_shot"], adapter_weights=[1., 1.])
|
| 74 |
+
|
| 75 |
|
| 76 |
# Fuse each adapter into the correct component with chosen lora_scale:
|
| 77 |
# - lightning -> transformer (boosted by 3x in your original)
|
|
|
|
| 79 |
# - orbit_shot -> transformer_2 (or transformer depending on the LoRA design)
|
| 80 |
pipeline.fuse_lora(adapter_names=["lightning"], lora_scale=3.0, components=["transformer"])
|
| 81 |
pipeline.fuse_lora(adapter_names=["lightning_2"], lora_scale=1.0, components=["transformer_2"])
|
| 82 |
+
#pipeline.fuse_lora(adapter_names=["orbit_shot"], lora_scale=1.0, components=["transformer_2"])
|
| 83 |
|
| 84 |
# After fusing, you can unload LoRA weights to free memory (fused weights remain applied)
|
| 85 |
pipeline.unload_lora_weights()
|