阿里开源 Qwen-Image-2.1:统一文生图与图像编辑的 7B 全能模型
Alibaba Qwen Releases Qwen-Image-2.1: A 7B Open-Weight Model for Image Generation and Editing
文章背景与核心概要
在生成式 AI (Generative AI) 领域,文生图与图像编辑以往往往由相互独立的模型或检查点分别处理,既增加了部署复杂度,也限制了多任务协同的效率。阿里巴巴 Qwen 团队正式开源发布了视觉生成全能模型 Qwen-Image-2.1,成功将高品质文本生图与高级多图参考编辑融合至单个 7B 架构之中。该模型基于 32 层的单流扩散 Transformer (Diffusion Transformer, DiT) 设计,并结合 8B 的 Qwen3-VL 文本编码器,原生支持多达 10 张图像的多图参考编辑、涂鸦圈选等局部控制、原生透明通道 (RGBA) 输出以及超高清 2K 图像生成。凭借新颖的混合粒度注意力机制与前缀键值缓存 (Prefix KV Cache) 复用技术,Qwen-Image-2.1 在显著提升推理速度与部署经济性的同时,还在自研评测基准 Qwen-Image-Bench 上斩获 60.28 的高分,强力领跑当前开源权重图像模型,为视觉生成领域树立了兼具卓越画质与高能效的全新标杆。
📋 内容总结
📋 Summary
阿里巴巴 Qwen 团队正式发布了 Qwen-Image-2.1 —— 这是一款统一了文本生成图像 (Text-to-Image) 与高阶图像编辑能力的 7B 开源权重模型。该模型采用 32 层的扩散 Transformer (Diffusion Transformer, DiT) ,并搭配 8B 的 Qwen3-VL 文本编码器,仅凭单一检查点 (Checkpoint) 即可全能支持多图参考编辑、局部精细修改、原生透明通道 (RGBA) 输出以及 2K 分辨率的高清图像生成。得益于混合粒度注意力机制 (Mixed-Granularity Attention) 与前缀键值缓存 (Prefix KV Cache) 技术,该模型在交付开源权重领域顶尖 SOTA 表现的同时,还在 Diffusers、ComfyUI、vLLM-Omni 以及 SGLang 等主流平台上大幅优化了推理速度与部署效率。
Alibaba’s Qwen team has released Qwen-Image-2.1, a unified 7B open-weight model for text-to-image generation and advanced image editing. Featuring a 32-layer Diffusion Transformer (DiT) combined with an 8B Qwen3-VL text encoder, this single checkpoint supports multi-reference editing, local edits, native transparency (RGBA), and 2K resolution generation. Thanks to mixed-granularity attention and prefix KV caching, the model delivers state-of-the-art open-weight performance while optimizing speed and deployment efficiency across platforms like Diffusers, ComfyUI, vLLM-Omni, and SGLang.
🚀 核心概述
🚀 Overview
阿里巴巴 Qwen 团队推出了 Qwen-Image-2.1,这是一款兼具文本生图与图像编辑功能的统一视觉生成模型。其视觉生成核心组件在 32 个单流 DiT 层中容纳了 7B 参数,仅需一个模型权重检查点,便能全面涵盖文生图、多参考图编辑、局部针对性修改以及带透明通道的 RGBA 输出等多种生成任务。
Alibaba’s Qwen team has introduced Qwen-Image-2.1, a unified text-to-image generation and image editing model. Its visual generation component packs 7B parameters across 32 single-stream DiT layers, with a single checkpoint covering text-to-image, multi-reference editing, local edits, and transparent RGBA output.
该模型目前可以直接部署吗? 对于学术研究与效果评估而言,答案是肯定的。模型发布首日 (Day 0) 便已全面获得 Diffusers、ComfyUI、vLLM-Omni、SGLang 和 LightX2V 等生态工具与框架的开箱即用支持;若计划将其投入商业化生产环境部署,则需单独获取 Qwen 官方的商业许可授权。
Is it deployable? Yes, for research and evaluation. Day 0 support covers Diffusers, ComfyUI, vLLM-Omni, SGLang, and LightX2V. Commercial deployment requires a separate license from Qwen.
📉 轻量进化:从 20B 到 7B
📉 From 20B to 7B
早先于 2025 年 8 月以 Apache 2.0 许可证开源的初代 Qwen-Image 是一个参数量达 20B 的大模型,且其图像编辑功能独立存放在另一个专门的检查点中。而新一代 Qwen-Image-2.1 将这两项重任合二为一,模型体积仅为初代的约三分之一,使其成为当前 Qwen-Image 家族中综合表现最为均衡、性价比最突出的代表之作。
The original Qwen-Image shipped in August 2025 as a 20B model under Apache 2.0, where image editing lived in a separate checkpoint. Qwen-Image-2.1 folds both jobs into one model at about a third of the size, making it the most balanced and cost-effective model in the Qwen-Image series.
关于显存与算力规划的说明: 7B 这一参数规模仅特指负责去噪生成的扩散 Transformer 主体。在实际运行流水线 (Pipeline) 时,系统还会同时加载一个 8B 参数的 Qwen3-VL 文本编码器。
Note on capacity planning: The 7B figure covers the diffusion transformer only. The pipeline also loads an 8B Qwen3-VL encoder.
⚙️ 核心架构设计
⚙️ Architecture
官方 GitHub 代码仓库 详细列出了模型的 4 大核心构成组件:
The GitHub Repo lists 4 core components:
- Transformer: 32 层、7B 参数,采用带块因果注意力 (Block-Causal Attention) 的单流设计。
- 文本编码器 (Text Encoder): Qwen3-VL 8B,负责将文本提示词指令与作为条件的参考图像编码并融合为统一的多模态表征。
- 变分自编码器 (VAE): 64 通道 RGBA 自编码器,具备 16 倍空间压缩率并原生支持透明通道。
- 调度器 (Scheduler): 流匹配 (Flow Matching) 框架,结合欧拉离散调度 (Euler Discrete Scheduling) 与动态时间步平移 (Dynamic Shifting) 策略。
- Transformer: 32 layers, 7B parameters, single-stream design with block-causal attention.
- Text encoder: Qwen3-VL 8B, which encodes text instructions and condition images into a unified representation.
- VAE: 64-channel RGBA autoencoder with 16x spatial compression and native transparency.
- Scheduler: Flow Matching with Euler discrete scheduling and dynamic shifting.
混合粒度注意力与推理速度优化
Mixed-Granularity Attention & Speed Optimization
Qwen-Image-2.1 极具竞争力的生成速度源于精心定制的注意力掩码 (Attention Mask) 机制:
Speed is achieved through a specialized attention mask:
- 文本 Token (Text tokens): 采用 Token 级别的因果掩码 (Token-Level Causal Mask) 。
- 图像 Token (Image tokens): 在每张图像内部采用块级别的双向掩码 (Chunk-Level Bidirectional Mask) 。
- Text tokens use a token-level causal mask.
- Image tokens use a chunk-level bidirectional mask within each image.
由于作为前置条件的前缀 (Condition Prefix) 位于带噪潜变量 (Noisy Latent) 之前,它在计算注意力时绝不会去关注后续的噪声潜变量 —— 这使得前缀部分的键 (Keys) 与值 (Values) 能够在所有去噪推理步骤中始终保持恒定。模型仅需在去噪第 1 步计算一次文本和输入图像的表征,之后便能在剩余所有步骤中全程复用这部分前缀键值缓存 (Prefix KV Cache) ,大幅降低了冗余计算,尤其在接入多张参考图像时能够带来极具威力的推理加速。
Because the condition prefix sits before the noisy latent, it never attends to it—keeping its keys and values fixed across denoising steps. The model computes text and input images once at the first step and reuses that prefix KV cache for every remaining step, substantially speeding up generation, especially when using multiple reference images.
🛠️ 关键核心特性
🛠️ Key Capabilities
- 原生透明通道 (Native Transparency): 支持直接根据文本提示词生成带透明背景的 RGBA 图像、自由编辑透明图层,以及从复杂真实照片中一键精准抠图抠出主体。
- 多图参考编辑 (Multi-Reference Editing): 支持输入最多 10 张参考图像 (例如将 6 张独立人物肖像融合成一张生动的集体大合影,或依据 5 张穿搭参考图合成定制时尚服饰) 。
- 局部精准控制 (Local Control): 支持通过涂鸦画圈、画笔标注或传入独立蒙版 (Mask) 进行局部定向修改,同时严密保护人物面部特征与产品关键主体的一致性。
- 原生 2K 分辨率 (Native 2K Resolution): 默认直出 2048 x 2048 像素超清画质,支持 7 种常用画面宽高比,最高分辨率可达 2752 x 1536。
- 高阶视觉质感 (Advanced Aesthetics): 在文字排版渲染、人像摄影布光、微观毛发细节刻画、超宽全景画面、信息图表 (Infographics)、分镜故事板 (Storyboards) 以及虚拟试穿试戴等高要求场景下均展现出卓越表现力。
- Native Transparency: Generates RGBA images from text, edits transparent layers, and extracts subjects from photos.
- Multi-Reference Editing: Accepts up to 10 reference images (e.g., building a group photo from 6 portraits or generating outfits from 5 references).
- Local Control: Targets edits using circles, painted annotations, or separate masks while preserving human and product identity.
- Native 2K Resolution: Defaults to 2048 x 2048, supporting 7 aspect ratios up to 2752 x 1536.
- Advanced Aesthetics: Enhanced typography, portrait lighting, fine details, panoramas, infographics, storyboards, and virtual try-ons.
📊 基准测试表现
📊 Benchmark Performance
根据官方 技术研发团队 公布的评测数据,Qwen-Image-2.1 在其自研的综合基准测试 Qwen-Image-Bench 中斩获了 60.28 的综合高分。这一优异战绩令其一举超越了 Nano Banana 2.0 (59.82) 以及榜单上所有已公开的开源权重模型,这其中甚至包括了参数量高达 32B 的重量级开源对手 FLUX 2 Max (55.33) 。在整个行业榜单中,仅有 6 款顶尖闭源商业模型的分数能够高于该模型,其中以 67.01 分领跑的是 GPT Image 2.5 Sunburst。
According to the research team, Qwen-Image-2.1 scores 60.28 overall on Qwen-Image-Bench (its in-house benchmark). This places it ahead of Nano Banana 2.0 (59.82) and all other listed open-weight models, including the 32B open model FLUX 2 Max (55.33). Only six closed-source models score higher, led by GPT Image 2.5 Sunburst at 67.01.
💻 快速上手与运行部署
💻 Getting Started & Running It
首先安装 PyTorch 2.4.0+、transformers 5.17+、通过源码安装的 Diffusers、accelerate 以及 Pillow,随后执行如下 Python 脚本即可快速体验:
Install PyTorch 2.4.0+, transformers 5.17+, Diffusers from source, accelerate, and Pillow, then run:
import torch
from diffusers import QwenImage21Pipeline
pipe = QwenImage21Pipeline.from_pretrained(
"Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16
).to("cuda")
image = pipe(
prompt="A neon shop sign that reads \"QWEN IMAGE 2.1\", rainy night",
num_inference_steps=40,
).images[0]
image.save("t2i.png")
- 图像编辑 (Editing): 直接在同一个推理流水线中传入带有单张或多张参考图的
image=参数即可。 - 显存优化 (Memory Optimization): 在显存较为紧张的中小规格 GPU 上,可开启
pipe.enable_model_cpu_offload()以将部分权重卸载至 CPU 内存。 - 服务化与推理框架生态 (Serving & Inference Frameworks): 已获主流框架无缝支持,包括 vLLM-Omni (支持 FP8 量化、前缀 KV 缓存复用与 CUDA Graph 解码) 、SGLang (支持 Cache-DiT 与组件级卸载) 以及 ComfyUI。同时,模型亦支持基于 ROCm 的 AMD Radeon 系列 GPU,并通过 FlagOS 适配支持了 8 款不同品牌的 AI 芯片平台。
- Editing: Pass
image=with one or more references into the same pipeline.- Memory Optimization: Use
pipe.enable_model_cpu_offload()on smaller GPUs.- Serving & Inference Frameworks: Supported by vLLM-Omni (FP8 quantization, prefix KV caching, CUDA Graph decode), SGLang (Cache-DiT, component offload), and ComfyUI. AMD Radeon GPUs are also supported via ROCm, and 8 chip platforms via FlagOS.
提示词扩写辅助模型
Prompt-Rewriting Models
Qwen 团队还同步推出了两个经过针对性微调的 Qwen3.5-VL 9B 检查点,分别针对 文生图 (text-to-image) 与 图像编辑 (editing) 任务进行了调优,能够自动将用户输入的大白话简短提示词扩写为细节生动的丰富描述,并智能推荐契合画面意境的理想宽高比。
The Qwen team also released two fine-tuned Qwen3.5-VL 9B checkpoints for text-to-image and editing to expand short prompts into detailed descriptions and choose ideal aspect ratios.
📌 核心要点速览
📌 Key Takeaways
- 统一精悍的生成管线: 将文本生成与高级编辑融汇于单一 7B DiT 模型中,并由 8B 的 Qwen3-VL 文本编码器协同驱动。
- 丰富硬核的前沿特性: 单一模型检查点原生支持 RGBA 透明通道输出,并可从容支持多达 10 张参考图的复杂图像编辑。
- 突破性的推理高能效: 引入前缀 KV 缓存复用机制,在整个图像生成流程中,文本提示词与参考图像仅需编码计算一次。
- 开源权重同类最强性能: 在官方基准测试 Qwen-Image-Bench 中获得 60.28 分,牢牢占据开源权重模型的领跑地位。
- 模型分发与开源许可: 采用 Qwen Research License (Qwen 研究许可证) 分发;涉及商业化用途需另行申请专门协议授权。
- Unified Pipeline: Combines generation and editing into a 7B DiT backed by an 8B Qwen3-VL encoder.
- Advanced Features: Native RGBA output and support for up to 10 reference images from a single checkpoint.
- High Efficiency: Prefix KV cache reuse computes text and reference assets only once per generation pass.
- Top-Tier Open-Weight Performance: Scores 60.28 on Qwen-Image-Bench, leading current open-weight alternatives.
- Licensing: Distributed under the Qwen Research License; commercial use requires a separate agreement.
🔗 资源汇总与社区链接
🔗 Resources & Community
- Hugging Face 上的模型权重 (Model Weights)
- GitHub 官方开源仓库 (GitHub Repository)
- 官方技术博客解读 (Official Technical Blog)
本项目的所有研发成果归属于 Qwen 研发团队。本文内容最初由 MarkTechPost 发布。
All credit for this project goes to the Qwen research team. Originally published by MarkTechPost.