Instructions to use linoyts/Qwen-Image-2.1-DMD2-2steps with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use linoyts/Qwen-Image-2.1-DMD2-2steps with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # 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("linoyts/Qwen-Image-2.1-DMD2-2steps") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
Qwen-Image-2.1 2-step DMD2 LoRA (V1)
A 2-step distillation LoRA for Qwen-Image-2.1, trained with DMD2 (Distribution Matching Distillation). It turns the base model's 20-step sampling into a 2 forward-pass run while keeping instruction editing and text-to-image quality close to the full-step teacher, which makes it suitable for real-time and interactive pipelines.
- Base model: Qwen/Qwen-Image-2.1
- Method: DMD2 (on-policy distribution matching, no regression/GAN loss), teacher CFG guidance
- LoRA: rank 32, alpha 32, attention-only (
to_q,to_k,to_v,to_out.0) - Inference: 2 steps, fixed sigmas
[1.0, 0.5],true_cfg_scale=1.0 - Training: multi-aspect (~1 MP) DMD2, 2000 steps on a single H100
Editing: 2 steps vs base 20 steps
The official Qwen-Image-2.1 demo edits (sketch-to-photo, hairstyle, expression, photo restoration), same input, prompt and seed. Middle column is this LoRA at 2 steps; right column is the base model at 20 steps.
Multi-reference composition
Qwen-Image-2.1 takes a list of condition images, referred to as "Picture 1", "Picture 2", ... in the prompt, and the LoRA keeps this working at 2 steps:
image = pipe(
prompt="Place the cat from Picture 1 on the beach from Picture 2.",
image=[cat, beach], # a list of condition images
num_inference_steps=2,
sigmas=[1.0, 0.5],
true_cfg_scale=1.0,
).images[0]
Usage
This model uses the QwenImage21Pipeline, which needs a diffusers build with Qwen-Image-2.1 support (currently the dev branch, not yet on PyPI):
pip install "git+https://github.com/huggingface/diffusers.git@qwenimage21-lora-training"
Image editing
import torch
from diffusers import QwenImage21Pipeline, FlowMatchEulerDiscreteScheduler
from diffusers.utils import load_image
pipe = QwenImage21Pipeline.from_pretrained("Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16).to("cuda")
# this LoRA was trained with fixed sigmas (no dynamic shifting)
pipe.scheduler = FlowMatchEulerDiscreteScheduler.from_config(
pipe.scheduler.config, use_dynamic_shifting=False, shift=1.0, shift_terminal=None
)
pipe.load_lora_weights("linoyts/Qwen-Image-2.1-DMD2-2steps", weight_name="pytorch_lora_weights.safetensors")
image = load_image("input.png")
out = pipe(
prompt="Turn this into a claymation character of colorful clay.",
image=image,
num_inference_steps=2,
sigmas=[1.0, 0.5],
true_cfg_scale=1.0,
generator=torch.Generator("cuda").manual_seed(0),
).images[0]
out.save("edited.png")
Text to image
Drop the image argument and keep everything else the same:
out = pipe(
prompt="a cute 3d render of a baby dragon made of jelly, soft shadows",
num_inference_steps=2,
sigmas=[1.0, 0.5],
true_cfg_scale=1.0,
generator=torch.Generator("cuda").manual_seed(0),
).images[0]
Notes
- The
[1.0, 0.5]sigma schedule is the schedule the LoRA was trained on. Because it was trained with fixed sigmas, setuse_dynamic_shifting=Falseandshift=1.0on the scheduler so the nodes are used exactly as given, rather than being resolution-shifted. - No CFG at inference (
true_cfg_scale=1.0): the LoRA bakes the teacher's guidance into the student, so a single conditional pass per step is enough. - Attention-only adaptation keeps conditioning fidelity high for editing; it preserves the input image more faithfully than adapting the feed-forward blocks as well.
License
Built with Qwen. This is a LoRA adapter for Qwen-Image-2.1 and is a derivative work of it, so it is governed by the Qwen Research License: non-commercial, research and evaluation use only. Commercial use requires a separate license from Qwen.
Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) 2026 Hangzhou Tongyi Laboratory Technology Co., Ltd. All Rights Reserved.
- Downloads last month
- 1,460
Model tree for linoyts/Qwen-Image-2.1-DMD2-2steps
Base model
Qwen/Qwen-Image-2.1