Spaces:
Running
on
Zero
Running
on
Zero
Refactor LoRA loading and fusion in app.py for improved clarity and efficiency
Browse files
app.py
CHANGED
|
@@ -51,24 +51,28 @@ scheduler = FlowMatchEulerDiscreteScheduler.from_config(scheduler_config)
|
|
| 51 |
pipe_stage1 = QwenImageEditPlusPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2511",
|
| 52 |
scheduler=scheduler,
|
| 53 |
torch_dtype=dtype).to(device)
|
|
|
|
| 54 |
pipe_stage1.load_lora_weights(
|
| 55 |
"lightx2v/Qwen-Image-Edit-2511-Lightning",
|
| 56 |
weight_name="Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors"
|
| 57 |
)
|
| 58 |
-
pipe_stage1.
|
| 59 |
-
|
|
|
|
| 60 |
pipe_stage1.fuse_lora()
|
| 61 |
|
| 62 |
# Load Stage 2 pipeline (Base Body -> Guide Body)
|
| 63 |
pipe_stage2 = QwenImageEditPlusPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2511",
|
| 64 |
scheduler=scheduler,
|
| 65 |
torch_dtype=dtype).to(device)
|
|
|
|
| 66 |
pipe_stage2.load_lora_weights(
|
| 67 |
"lightx2v/Qwen-Image-Edit-2511-Lightning",
|
| 68 |
weight_name="Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors"
|
| 69 |
)
|
| 70 |
-
pipe_stage2.
|
| 71 |
-
|
|
|
|
| 72 |
pipe_stage2.fuse_lora()
|
| 73 |
|
| 74 |
# # Apply the same optimizations from the first version
|
|
|
|
| 51 |
pipe_stage1 = QwenImageEditPlusPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2511",
|
| 52 |
scheduler=scheduler,
|
| 53 |
torch_dtype=dtype).to(device)
|
| 54 |
+
# Load 4-step Lightning LoRA and fuse
|
| 55 |
pipe_stage1.load_lora_weights(
|
| 56 |
"lightx2v/Qwen-Image-Edit-2511-Lightning",
|
| 57 |
weight_name="Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors"
|
| 58 |
)
|
| 59 |
+
pipe_stage1.fuse_lora()
|
| 60 |
+
# Load Stage 1 LoRA and fuse
|
| 61 |
+
pipe_stage1.load_lora_weights(STAGE1_LORA_REPO, weight_name=STAGE1_LORA_WEIGHT)
|
| 62 |
pipe_stage1.fuse_lora()
|
| 63 |
|
| 64 |
# Load Stage 2 pipeline (Base Body -> Guide Body)
|
| 65 |
pipe_stage2 = QwenImageEditPlusPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2511",
|
| 66 |
scheduler=scheduler,
|
| 67 |
torch_dtype=dtype).to(device)
|
| 68 |
+
# Load 4-step Lightning LoRA and fuse
|
| 69 |
pipe_stage2.load_lora_weights(
|
| 70 |
"lightx2v/Qwen-Image-Edit-2511-Lightning",
|
| 71 |
weight_name="Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors"
|
| 72 |
)
|
| 73 |
+
pipe_stage2.fuse_lora()
|
| 74 |
+
# Load Stage 2 LoRA and fuse
|
| 75 |
+
pipe_stage2.load_lora_weights(STAGE2_LORA_REPO, weight_name=STAGE2_LORA_WEIGHT)
|
| 76 |
pipe_stage2.fuse_lora()
|
| 77 |
|
| 78 |
# # Apply the same optimizations from the first version
|