Spaces:
Running
on
Zero
Running
on
Zero
Enhance LoRA loading process in app.py by adding adapter names and setting equal weights for improved functionality
Browse files
app.py
CHANGED
|
@@ -51,28 +51,32 @@ 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 |
-
# Load 4-step Lightning LoRA
|
| 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 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
| 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
|
| 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 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
| 76 |
pipe_stage2.fuse_lora()
|
| 77 |
|
| 78 |
# # 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
|
| 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 |
+
adapter_name="lightning"
|
| 59 |
)
|
| 60 |
+
# Load Stage 1 LoRA
|
| 61 |
+
pipe_stage1.load_lora_weights(STAGE1_LORA_REPO, weight_name=STAGE1_LORA_WEIGHT, adapter_name="stage1")
|
| 62 |
+
# Set both adapters with equal weights and fuse
|
| 63 |
+
pipe_stage1.set_adapters(["lightning", "stage1"], adapter_weights=[1.0, 1.0])
|
| 64 |
pipe_stage1.fuse_lora()
|
| 65 |
|
| 66 |
# Load Stage 2 pipeline (Base Body -> Guide Body)
|
| 67 |
pipe_stage2 = QwenImageEditPlusPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2511",
|
| 68 |
scheduler=scheduler,
|
| 69 |
torch_dtype=dtype).to(device)
|
| 70 |
+
# Load 4-step Lightning LoRA
|
| 71 |
pipe_stage2.load_lora_weights(
|
| 72 |
"lightx2v/Qwen-Image-Edit-2511-Lightning",
|
| 73 |
+
weight_name="Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors",
|
| 74 |
+
adapter_name="lightning"
|
| 75 |
)
|
| 76 |
+
# Load Stage 2 LoRA
|
| 77 |
+
pipe_stage2.load_lora_weights(STAGE2_LORA_REPO, weight_name=STAGE2_LORA_WEIGHT, adapter_name="stage2")
|
| 78 |
+
# Set both adapters with equal weights and fuse
|
| 79 |
+
pipe_stage2.set_adapters(["lightning", "stage2"], adapter_weights=[1.0, 1.0])
|
| 80 |
pipe_stage2.fuse_lora()
|
| 81 |
|
| 82 |
# # Apply the same optimizations from the first version
|