Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,6 +63,8 @@ pipe = DiffusionPipeline.from_pretrained(
|
|
| 63 |
LIGHTNING_LORA_REPO = "lightx2v/Qwen-Image-Lightning"
|
| 64 |
LIGHTNING_LORA_WEIGHT = "Qwen-Image-Lightning-4steps-V2.0-bf16.safetensors"
|
| 65 |
LIGHTNING8_LORA_WEIGHT = "Qwen-Image-Lightning-8steps-V2.0-bf16.safetensors"
|
|
|
|
|
|
|
| 66 |
|
| 67 |
MAX_SEED = np.iinfo(np.int32).max
|
| 68 |
|
|
@@ -234,6 +236,26 @@ def run_lora(prompt, cfg_scale, steps, selected_index, randomize_seed, seed, asp
|
|
| 234 |
adapter_name="style"
|
| 235 |
)
|
| 236 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
# Set both adapters active with their weights
|
| 238 |
pipe.set_adapters(["lightning", "style"], adapter_weights=[1.0, lora_scale])
|
| 239 |
elif speed_mode == "light 8":
|
|
@@ -300,12 +322,12 @@ def run_lora(prompt, cfg_scale, steps, selected_index, randomize_seed, seed, asp
|
|
| 300 |
# Formatear para Gallery: (img, "Seed: N")
|
| 301 |
#images_for_gallery = [(img, f"Seed: {s}") for (img, s) in pairs]
|
| 302 |
images_for_gallery = [
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
]
|
| 309 |
|
| 310 |
|
| 311 |
# Debe devolver DOS valores porque outputs=[result, seed]
|
|
@@ -519,7 +541,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css, delete_cache=(60, 60)) as app:
|
|
| 519 |
with gr.Column():
|
| 520 |
speed_mode = gr.Radio(
|
| 521 |
label="Generation Mode",
|
| 522 |
-
choices=["light 4", "light 8", "normal"],
|
| 523 |
value="light 4",
|
| 524 |
info="'light' modes use Lightning LoRA for faster generation"
|
| 525 |
)
|
|
|
|
| 63 |
LIGHTNING_LORA_REPO = "lightx2v/Qwen-Image-Lightning"
|
| 64 |
LIGHTNING_LORA_WEIGHT = "Qwen-Image-Lightning-4steps-V2.0-bf16.safetensors"
|
| 65 |
LIGHTNING8_LORA_WEIGHT = "Qwen-Image-Lightning-8steps-V2.0-bf16.safetensors"
|
| 66 |
+
LIGHTNING_FP8_4STEPS_LORA_WEIGHT = "Qwen-Image-fp8-e4m3fn-Lightning-4steps-V1.0-bf16.safetensors"
|
| 67 |
+
|
| 68 |
|
| 69 |
MAX_SEED = np.iinfo(np.int32).max
|
| 70 |
|
|
|
|
| 236 |
adapter_name="style"
|
| 237 |
)
|
| 238 |
|
| 239 |
+
# Set both adapters active with their weights
|
| 240 |
+
pipe.set_adapters(["lightning", "style"], adapter_weights=[1.0, lora_scale])
|
| 241 |
+
elif speed_mode == "light 4 fp8":
|
| 242 |
+
with calculateDuration("Loading Lightning LoRA and style LoRA"):
|
| 243 |
+
# Load Lightning LoRA first
|
| 244 |
+
pipe.load_lora_weights(
|
| 245 |
+
LIGHTNING_LORA_REPO,
|
| 246 |
+
weight_name=LIGHTNING_FP8_4STEPS_LORA_WEIGHT,
|
| 247 |
+
adapter_name="lightning"
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
# Load the selected style LoRA
|
| 251 |
+
weight_name = selected_lora.get("weights", None)
|
| 252 |
+
pipe.load_lora_weights(
|
| 253 |
+
lora_path,
|
| 254 |
+
weight_name=weight_name,
|
| 255 |
+
low_cpu_mem_usage=True,
|
| 256 |
+
adapter_name="style"
|
| 257 |
+
)
|
| 258 |
+
|
| 259 |
# Set both adapters active with their weights
|
| 260 |
pipe.set_adapters(["lightning", "style"], adapter_weights=[1.0, lora_scale])
|
| 261 |
elif speed_mode == "light 8":
|
|
|
|
| 322 |
# Formatear para Gallery: (img, "Seed: N")
|
| 323 |
#images_for_gallery = [(img, f"Seed: {s}") for (img, s) in pairs]
|
| 324 |
images_for_gallery = [
|
| 325 |
+
(
|
| 326 |
+
img,
|
| 327 |
+
s
|
| 328 |
+
)
|
| 329 |
+
for (img, s) in pairs
|
| 330 |
+
]
|
| 331 |
|
| 332 |
|
| 333 |
# Debe devolver DOS valores porque outputs=[result, seed]
|
|
|
|
| 541 |
with gr.Column():
|
| 542 |
speed_mode = gr.Radio(
|
| 543 |
label="Generation Mode",
|
| 544 |
+
choices=["light 4", "light 4 fp8", "light 8", "normal"],
|
| 545 |
value="light 4",
|
| 546 |
info="'light' modes use Lightning LoRA for faster generation"
|
| 547 |
)
|