Instructions to use lightx2v/Qwen-Image-2.1-Lightning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use lightx2v/Qwen-Image-2.1-Lightning with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("Qwen/Qwen-Image-2.1", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("lightx2v/Qwen-Image-2.1-Lightning") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
import torch
from diffusers import DiffusionPipeline
# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("Qwen/Qwen-Image-2.1", dtype=torch.bfloat16, device_map="cuda")
pipe.load_lora_weights("lightx2v/Qwen-Image-2.1-Lightning")
prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
image = pipe(prompt).images[0]LightX2V Lightning for Qwen-Image-2.1
A 4-step distilled LoRA for Qwen-Image-2.1, supporting text-to-image generation and image editing. Training was performed entirely on 16 Huawei Ascend 910B NPUs, using DMD in LightX2V.
For inference on heterogeneous hardware platforms, refer to the LightX2V platform scripts.
Text-to-image
Run this example from the directory containing pytorch_lora_weights.safetensors:
import torch
from diffusers import FlowMatchEulerDiscreteScheduler, QwenImage21Pipeline
pipe = QwenImage21Pipeline.from_pretrained(
"Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16
).to("cuda")
pipe.load_lora_weights(
".", weight_name="pytorch_lora_weights.safetensors", adapter_name="lightning"
)
pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config(
pipe.scheduler.config, shift_terminal=None
)
image = pipe(
prompt='A coffee shop entrance with a chalkboard reading "Qwen Coffee, $2 per cup" and a neon sign displaying "通义千问".',
width=1024,
height=1024,
num_inference_steps=4,
sigmas=[1.0, 0.75, 0.5, 0.25],
true_cfg_scale=1.0,
use_kv_cache=False,
generator=torch.Generator("cuda").manual_seed(42),
).images[0]
image.save("t2i.png")
Image editing
Run this example from the directory containing pytorch_lora_weights.safetensors and input.png:
import torch
from PIL import Image
from diffusers import FlowMatchEulerDiscreteScheduler, QwenImage21Pipeline
pipe = QwenImage21Pipeline.from_pretrained(
"Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16
).to("cuda")
pipe.load_lora_weights(
".", weight_name="pytorch_lora_weights.safetensors", adapter_name="lightning"
)
pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config(
pipe.scheduler.config, shift_terminal=None
)
image = pipe(
prompt="Change the red jacket to dark blue. Keep the person's identity, pose, background and lighting unchanged.",
image=Image.open("input.png"),
width=1024,
height=1024,
num_inference_steps=4,
sigmas=[1.0, 0.75, 0.5, 0.25],
true_cfg_scale=1.0,
use_kv_cache=False,
generator=torch.Generator("cuda").manual_seed(42),
).images[0]
image.save("edit.png")
For multiple references, use image=[Image.open("reference_1.png"), Image.open("reference_2.png")].
Comparison
Same prompts, seeds and output sizes; CFG is disabled for both models. The 40-step base-model images are from an earlier run. Click an example name to view its prompt.
Text-to-image
| Example | Qwen-Image-2.1 · 40 steps | Lightning LoRA · 4 steps |
|---|---|---|
| Coffee Shop Signage | ![]() |
![]() |
| Nine-Headed Fox Beast | ![]() |
![]() |
| Sheep Designer Toy | ![]() |
![]() |
| Office Cow Selfie | ![]() |
![]() |
| Floral Wine Advertisement | ![]() |
![]() |
Image editing
Both models use the same reference images, shown below in prompt order.
| Example | Reference images | Qwen-Image-2.1 · 40 steps | Lightning LoRA · 4 steps |
|---|---|---|---|
| Jacket Recolor | ![]() |
![]() |
![]() |
| Outfit and Night Scene | ![]() ![]() ![]() |
![]() |
![]() |
| Person and Cat | ![]() ![]() ![]() |
![]() |
![]() |
| Product Advertisement | ![]() ![]() ![]() |
![]() |
![]() |
| Sofa and Pendant Lamp | ![]() ![]() ![]() |
![]() |
![]() |
| Floor Material Transfer | ![]() ![]() |
![]() |
![]() |
| Mirror Reflection | ![]() ![]() ![]() |
![]() |
![]() |
| Backpack Try-On | ![]() ![]() ![]() |
![]() |
![]() |
- Downloads last month
- -
Model tree for lightx2v/Qwen-Image-2.1-Lightning
Base model
Qwen/Qwen-Image-2.1













































