Qwen 模型发布·· 23 天前精选AI 评分72
Qwen 开源 Qwen-Image-2.1 统一文生图与图像编辑模型
Qwen/Qwen-Image-2.1
AI 导读
Qwen 开源 Qwen-Image-2.1,一个统一文生图与图像编辑的模型,视觉生成组件为 7B 参数、32 层 Single-Stream DiT。该版本支持原生 RGBA 透明图生成与透明层编辑,编辑时最多可输入 10 张参考图,并可用圈选、涂画或独立 mask 指定局部修改。
推荐理由
原文列出 7B 视觉生成组件、RGBA 透明图与最多 10 张参考图编辑等具体能力,可据此判断统一生成与编辑模型的取舍。
正文 · AI 翻译
🤖 ModelScope | 🤗 HuggingFace | 📑 博客 | 🖥️ 演示 | 🫨 Discord | 💬 微信
简介
我们很高兴开源 Qwen-Image-2.1,这是 Qwen 家族中统一的文生图生成与图像编辑模型。其视觉生成组件仅拥有 7B 参数(32 个 Single-Stream DiT 层),Qwen-Image-2.1 在生成质量、推理效率与多功能性之间取得了平衡。
本次发布包含四项关键改进:
- 紧凑高效 — 采用混合粒度注意力和前缀 KV 缓存复用的轻量架构,以较低的计算成本实现出色的图像质量。
- 原生透明,统一创作与编辑 — 从文本生成普通或透明(RGBA)图像、编辑透明图层,以及从照片中提取主体——全部在一个模型中完成。
- 多样化编辑 — 支持最多 10 张参考图像,可通过圆圈、涂绘标注或独立蒙版指定局部编辑,并保持人物和产品的身份一致性。
- 逼真质感与精致美学 — 改进的排版、人像光照和精细细节,带来更具视觉吸引力的结果。
快速开始
安装
pip install torch>=2.4.0
pip install transformers>=5.17
pip install git+https://github.com/huggingface/diffusers
pip install accelerate pillow
文生图
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, reflections on wet pavement",
width=2048, height=2048,
num_inference_steps=40,
generator=torch.Generator("cuda").manual_seed(42),
).images[0]
image.save("t2i_example.png")
图像编辑
import torch
from PIL import Image
from diffusers import QwenImage21Pipeline
pipe = QwenImage21Pipeline.from_pretrained(
"Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16
).to("cuda")
input_image = Image.open("input.png")
image = pipe(
prompt="Change the background to a sunset beach",
image=input_image,
num_inference_steps=40,
generator=torch.Generator("cuda").manual_seed(42),
).images[0]
image.save("edit_example.png")
透明图像生成(RGBA)
透明图像请使用推荐的提示词格式:
image = pipe(
prompt="This is an RGBA image with transparency. A cute cartoon dragon sticker. The image has alpha channel and the background is transparent.",
width=2048, height=2048,
num_inference_steps=40,
generator=torch.Generator("cuda").manual_seed(42),
).images[0]
image.save("transparent_example.png")
支持的宽高比
aspect_ratios = {
"1:1": (2048, 2048),
"4:3": (2400, 1792),
"3:4": (1792, 2400),
"3:2": (2528, 1696),
"2:3": (1696, 2528),
"16:9": (2752, 1536),
"9:16": (1536, 2752),
}
内存优化
pipe = QwenImage21Pipeline.from_pretrained(
"Qwen/Qwen-Image-2.1", torch_dtype=torch.bfloat16
)
pipe.enable_model_cpu_offload()
展示
原生透明图像生成
基于六张人像参考图生成的合影
文字渲染
许可证
本模型依据 Qwen 研究许可证协议 授权。
反馈
使用 Qwen-Image-2.1 时遇到问题? 我们的官方反馈表单可将您直接与 Qwen Image 研究团队联系起来。 分享您的提示词、图像或工作流,帮助我们调查和改进。
来源:Qwen 模型发布 · hf-mirror.com