Spaces:
Running
on
Zero
Running
on
Zero
Update optimization.py
Browse files- optimization.py +17 -0
optimization.py
CHANGED
@@ -36,6 +36,23 @@ def optimize_pipeline_(pipeline: Callable[P, Any], *args: P.args, **kwargs: P.kw
|
|
36 |
|
37 |
@spaces.GPU(duration=1500)
|
38 |
def compile_transformer():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
with capture_component_call(pipeline, 'transformer') as call:
|
41 |
pipeline(*args, **kwargs)
|
|
|
36 |
|
37 |
@spaces.GPU(duration=1500)
|
38 |
def compile_transformer():
|
39 |
+
|
40 |
+
pipeline.load_lora_weights(
|
41 |
+
"vrgamedevgirl84/Wan14BT2VFusioniX",
|
42 |
+
weight_name="FusionX_LoRa/Phantom_Wan_14B_FusionX_LoRA.safetensors",
|
43 |
+
adapter_name="phantom"
|
44 |
+
)
|
45 |
+
kwargs_lora = {}
|
46 |
+
kwargs_lora["load_into_transformer_2"] = True
|
47 |
+
pipeline.load_lora_weights(
|
48 |
+
"vrgamedevgirl84/Wan14BT2VFusioniX",
|
49 |
+
weight_name="FusionX_LoRa/Phantom_Wan_14B_FusionX_LoRA.safetensors",
|
50 |
+
adapter_name="phantom_2", **kwargs_lora
|
51 |
+
)
|
52 |
+
pipeline.set_adapters(["phantom", "phantom_2"], adapter_weights=[1., 1.])
|
53 |
+
pipeline.fuse_lora(adapter_names=["phantom"], lora_scale=3., components=["transformer"])
|
54 |
+
pipeline.fuse_lora(adapter_names=["phantom_2"], lora_scale=1., components=["transformer_2"])
|
55 |
+
pipeline.unload_lora_weights()
|
56 |
|
57 |
with capture_component_call(pipeline, 'transformer') as call:
|
58 |
pipeline(*args, **kwargs)
|