Qwen-Image-2.1-DMD2-2steps

linoyts/Qwen-Image-2.1-DMD2-2steps

作者
linoyts
任务
图像生成
下载量
3,864
点赞数
64
趋势分
17
许可证
other
收录时间
2026/11/4

base_model: Qwen/Qwen-Image-2.1 license: other license_name: qwen-research license_link: https://huggingface.co/Qwen/Qwen-Image-2.1/blob/main/LICENSE library_name: diffusers pipeline_tag: image-to-image tags:

  • lora
  • qwen-image
  • text-to-image
  • image-to-image
  • image-editing
  • distillation
  • dmd
  • few-step

Qwen-Image-2.1 2-step DMD2 LoRA

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

2026-10-30: New V1.5 checkpoint available, with improved prompt adherence and edit fidelity. Load it by passing weight_name="pytorch_lora_weights_v1_5.safetensors" to load_lora_weights (all other settings below are unchanged).

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.

2-step vs 20-step editing comparison

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, set use_dynamic_shifting=False and shift=1.0 on 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.

内容来源:Hugging Face 模型卡

在 Hugging Face 查看