Qwen-Image-Layered: Layered Decomposition for Inherent Editablity
🤗 HuggingFace | 🤖 ModelScope | 📑 研究论文 | 📑 博客 | 🤗 演示
简介
我们荣幸地推出Qwen-Image-Layered,这是一款能够将图像分解为多个RGBA图层的模型。这种分层表示解锁了内在可编辑性:每个图层都可以独立操作,而不会影响其他内容。同时,这种分层表示天然支持高保真基础操作,如调整大小、重新定位和重新着色。通过将语义或结构组件物理隔离到不同的图层中,我们的方法实现了高保真且一致的编辑。
新闻
- 2025.12.22:您可以在 Huggingface Spaces 和 Modelscope Studio 上试用 Qwen-Image-Layered。
- 2025.12.19:我们发布了 Qwen-Image-Layered 权重!请在 Huggingface 和 ModelScope 查看!
- 2025.12.19:我们发布了 Qwen-Image-Layered!更多详情请查看我们的 博客!
- 2025.12.18:我们在 Arxiv 上发布了 研究论文!
Note
- 文本提示旨在描述输入图像的整体内容,包括可能被部分遮挡的元素(例如,您可以指定隐藏在前景对象后面的文本)。它并非设计用于显式控制单个图层的语义内容。
- 发布的权重是专门针对图像到多 RGBA 分解任务进行微调的。因此,虽然该模型支持文本条件推理,但其在文本到多 RGBA 生成任务上的性能有限。
快速开始
-
确保您的 transformers>=4.51.3(支持 Qwen2.5-VL)
-
安装最新版本的 diffusers
pip install git+https://github.com/huggingface/diffusers
pip install python-pptx
pip install psd-tools
from diffusers import QwenImageLayeredPipeline
import torch
from PIL import Image
pipeline = QwenImageLayeredPipeline.from_pretrained("Qwen/Qwen-Image-Layered")
pipeline = pipeline.to("cuda", torch.bfloat16)
pipeline.set_progress_bar_config(disable=None)
image = Image.open("asserts/test_images/1.png").convert("RGBA")
inputs = {
"image": image,
"generator": torch.Generator(device='cuda').manual_seed(777),
"true_cfg_scale": 4.0,
"negative_prompt": " ",
"num_inference_steps": 50,
"num_images_per_prompt": 1,
"layers": 4,
"resolution": 640, # Using different bucket (640, 1024) to determine the resolution. For this version, 640 is recommended
"cfg_normalize": True, # Whether enable cfg normalization.
"use_en_prompt": True, # Automatic caption language if user does not provide caption
}
with torch.inference_mode():
output = pipeline(**inputs)
output_image = output.images[0]
for i, image in enumerate(output_image):
image.save(f"{i}.png")
部署 Qwen-Image-Layered
以下脚本将启动一个基于 Gradio 的网页界面,您可以在其中分解图像并将图层导出为 pptx、zip 和 psd 文件,以便灵活编辑和移动这些图层。
python src/app.py
分解完成后,您可能希望编辑特定的图层。以下脚本将启动一个基于 Gradio 的 Web 界面,您可以在其中使用 Qwen-Image-Edit 编辑带有透明度的图像。
python src/tool/edit_rgba_image.py
编辑好分解后的各个图层后,您可以使用以下脚本将它们合成为新图像。请记住按顺序上传图层——从最底层到最顶层。
python src/tool/combine_layers.py
vLLM-Omni
vLLM-Omni 现已支持 Qwen-Image-Layered。最新详情请参见 使用指南。
功能展示
分层分解的实际应用
给定一张图像,Qwen-Image-Layered 能够将其分解为多个 RGBA 图层:
分解完成后,编辑操作仅作用于目标图层,使其与其他内容在物理上相互隔离,从根本上确保编辑效果的一致性。
例如,我们可以为第一个图层重新着色,同时保持其他所有内容不变:
我们还能将第二个图层中的女孩替换为男孩(目标图层使用 Qwen-Image-Edit 进行编辑):
在此例中,我们将文本修改为“Qwen-Image”(目标图层使用 Qwen-Image-Edit 进行编辑):
此外,分层结构天然支持基础操作。例如,我们可以干净地删除不需要的对象:
我们也能在不失真的情况下调整对象大小:
图层分解后,我们可以在画布内自由移动对象:
灵活的迭代式分解
Qwen-Image-Layered 不受固定图层数量的限制。该模型支持可变图层分解。例如,我们可根据需要将一张图像分解为 3 个或 8 个图层:
此外,分解过程可递归进行:任何一个图层本身都能被进一步分解,从而实现无限层级的分解。
许可协议
Qwen-Image-Layered 采用 Apache 2.0 许可协议。
引用说明
如果您认为我们的研究工作对您有所帮助,我们诚挚地建议您引用相关成果。
@misc{yin2025qwenimagelayered,
title={Qwen-Image-Layered: Towards Inherent Editability via Layer Decomposition},
author={Shengming Yin, Zekai Zhang, Zecheng Tang, Kaiyuan Gao, Xiao Xu, Kun Yan, Jiahao Li, Yilei Chen, Yuxiang Chen, Heung-Yeung Shum, Lionel M. Ni, Jingren Zhou, Junyang Lin, Chenfei Wu},
year={2025},
eprint={2512.15603},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2512.15603},
}
