🤗 Hugging Face  |   💻 GitHub  |   🌐 LightX2V  |   💬 WeChat

Introduction

Four-step image generation and editing. Built with Qwen.

This model is the reinforcement-learning-refined version of LightX2V Lightning v2, distilled from Qwen-Image-2.1. It supports text-to-image generation, single-reference image editing, and multi-reference image generation with 4 denoising steps and CFG = 1.0.

RL training was performed with LightX2V RL.

Model files

The release provides the full transformer weights in a single diffusion_pytorch_model.safetensors file, together with config.json. The weights are stored in FP32 and can be loaded in BF16 for inference.

inference_config.json records the base model, four sampling sigmas, guidance scale, KV cache setting, and scheduler parameters. It is a release-specific configuration file, explicitly read by the example below; Diffusers does not load it automatically.

The inference files are:

config.json
diffusion_pytorch_model.safetensors
inference_config.json
README.md
assets/img_lightx2v.png
assets/wechat.jpg
assets/comparison/

merge_manifest.json is a local export audit record, is not used for inference, and can be excluded when uploading.

Load the processor, text encoder, and VAE from the original Qwen-Image-2.1 pipeline, then replace its transformer as shown below. This checkpoint is not a LoRA adapter or a standalone pipeline bundle.

Quick start

Install a recent Diffusers version with QwenImage21Pipeline support:

pip install git+https://github.com/huggingface/diffusers.git
pip install "transformers>=5.17.0" accelerate safetensors pillow

Run the following code from the downloaded model directory, or change MODEL_DIR to its local path. The base pipeline components will be downloaded from Hugging Face when needed.

Load the model

import json
from pathlib import Path

import torch
from PIL import Image
from diffusers import (
    FlowMatchEulerDiscreteScheduler,
    QwenImage21Pipeline,
    QwenImage21Transformer2DModel,
)

MODEL_DIR = "."
with (Path(MODEL_DIR) / "inference_config.json").open(encoding="utf-8") as f:
    inference_config = json.load(f)
SIGMAS = inference_config["sample_sigmas"]

transformer = QwenImage21Transformer2DModel.from_pretrained(
    MODEL_DIR,
    torch_dtype=torch.bfloat16,
)
pipe = QwenImage21Pipeline.from_pretrained(
    inference_config["base_model"],
    transformer=transformer,
    torch_dtype=torch.bfloat16,
)
# The four sigmas are already shifted. Do not apply dynamic shifting again.
pipe.scheduler = FlowMatchEulerDiscreteScheduler(
    **inference_config["scheduler"],
)
pipe.to("cuda")


def generate(prompt, image=None, seed=42):
    return pipe(
        prompt=prompt,
        image=image,
        width=1024,
        height=1024,
        sigmas=SIGMAS,
        num_inference_steps=len(SIGMAS),
        true_cfg_scale=inference_config["true_cfg_scale"],
        use_kv_cache=inference_config["use_kv_cache"],
        generator=torch.Generator("cpu").manual_seed(seed),
    ).images[0]

Use this exact sigma schedule for all three tasks. The terminal sigma of zero is appended by the scheduler. Setting only num_inference_steps=4 does not reproduce this schedule.

Text-to-image

image = generate(
    "A ceramic teapot beside a small bowl of oranges on a wooden table, "
    "soft morning window light, detailed glaze, natural colors."
)
image.save("t2i.png")

Single-reference editing

reference = Image.open("reference.png").convert("RGB")
image = generate(
    "Change the jacket to dark green. Preserve the person's face, pose, "
    "and the rest of the scene.",
    image=[reference],
)
image.save("edit.png")

Multi-reference generation

Pass reference images in the same order used by the prompt:

references = [
    Image.open("person.png").convert("RGB"),
    Image.open("jacket.png").convert("RGB"),
]
image = generate(
    "Show the person from image 1 wearing the jacket from image 2. "
    "Preserve the person's identity and the jacket's design, "
    "with natural lighting and a simple studio background.",
    image=references,
)
image.save("multi_reference.png")

The examples use 1024 × 1024 output. For other aspect ratios, set both dimensions to multiples of 32. Generation quality can vary with the prompt and seed; fine text, anatomy, object counts, and precise reference preservation may still require checking.

Comparison with Qwen-Image-2.1 (40 steps)

Selected qualitative examples from our validation runs: Lightning v2 RL uses 4 steps, while the baseline uses the original Qwen-Image-2.1 weights with 40-step Euler sampling. Both use CFG = 1.0, the same full enhanced prompts, the same input references where applicable, and 1024 × 1024 output.

Text-to-image

Example / prompt Qwen-Image-2.1 · 40 steps Lightning v2 RL · 4 steps
Dolphin at a Burning Shoreline Dolphin at a Burning Shoreline, original model, 40 steps Dolphin at a Burning Shoreline, RL model, 4 steps
Weathered Bicycle in the Rain Weathered Bicycle in the Rain, original model, 40 steps Weathered Bicycle in the Rain, RL model, 4 steps

Single-reference editing

Example / prompt Reference images Qwen-Image-2.1 · 40 steps Lightning v2 RL · 4 steps
Flying Dragon above Waterfall Gardens Reference 1 Flying Dragon above Waterfall Gardens, original model, 40 steps Flying Dragon above Waterfall Gardens, RL model, 4 steps
Guitarist and Cat in a Busy Marketplace Reference 1 Guitarist and Cat in a Busy Marketplace, original model, 40 steps Guitarist and Cat in a Busy Marketplace, RL model, 4 steps

Multi-reference generation

Example / prompt Reference images Qwen-Image-2.1 · 40 steps Lightning v2 RL · 4 steps
Food Transfer into a Stylized Scene Reference 1
Reference 2
Food Transfer into a Stylized Scene, original model, 40 steps Food Transfer into a Stylized Scene, RL model, 4 steps
Floral Porcelain Teapot in a Portrait Scene Reference 1
Reference 2
Floral Porcelain Teapot in a Portrait Scene, original model, 40 steps Floral Porcelain Teapot in a Portrait Scene, RL model, 4 steps

License and acknowledgements

This model is derived from Qwen-Image-2.1 and is subject to the Qwen Research License, including its non-commercial terms.

Thanks to the Qwen team and the Diffusers community. See LightX2V, the earlier Qwen-Image-2.1-Lightning release, and Qwen-Image-2.1-Turbo for related work.

Downloads last month
7,621
Safetensors
Model size
7B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for lightx2v/Qwen-Image-2.1-Lightning-v2-RL

Finetuned
(88)
this model

Spaces using lightx2v/Qwen-Image-2.1-Lightning-v2-RL 3

Collection including lightx2v/Qwen-Image-2.1-Lightning-v2-RL