File size: 7,125 Bytes
f839049
 
 
 
 
 
 
 
 
 
 
 
 
 
71cf4a8
 
 
 
f839049
 
 
71cf4a8
 
 
 
f839049
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ad098bd
f839049
ad098bd
f839049
 
 
ad098bd
 
 
 
 
f839049
 
 
71cf4a8
f839049
71cf4a8
f839049
71cf4a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f839049
71cf4a8
 
 
f839049
 
 
 
 
 
71cf4a8
 
 
 
 
 
f839049
ad098bd
f839049
 
71cf4a8
f839049
 
 
 
71cf4a8
 
 
 
f839049
 
 
 
71cf4a8
f839049
71cf4a8
 
 
f839049
 
71cf4a8
 
 
 
 
 
 
 
 
f839049
ad098bd
f839049
ad098bd
 
 
 
 
 
 
 
f839049
 
ad098bd
 
f839049
ad098bd
f839049
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71cf4a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
---

license: apache-2.0
language:
- en
- zh
base_model:
- Qwen/Qwen-Image-Layered
pipeline_tag: image-text-to-image
library_name: ggml
tags:
- gguf
- quantized
- unsloth
- qwen
- lora
- psd
- photoshop
- image-decomposition
---


> [!NOTE]
> This repository features **Qwen-Image-Layered (Designer PSD Fine-Tune)** โ€” adapted and quantized for designer workflows.
> - **Custom LoRA Fine-Tuning**: Trained on paired designer PSD layouts to deliver clean object separation, distinct text/graphics isolation, and reliable alpha channels.
> - **End-to-End PSD Packaging**: Bundled with a packaging pipeline that exports generated layers directly into a multi-layer Adobe Photoshop (`.psd`) file.
> - **GGUF Quantization & Web Studio**: Optimized with [Unsloth Dynamic 2.0](https://docs.unsloth.ai/basics/unsloth-dynamic-2.0-ggufs) GGUFs for lightweight local inference, accompanied by a local **Layer Studio** web UI.

<div>
  <div style="display: flex; gap: 5px; align-items: center; ">
    <a href="https://github.com/unslothai/unsloth/">

      <img src="https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png" width="133">

    </a>

    <a href="https://discord.gg/unsloth">

      <img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">

    </a>

    <a href="https://docs.unsloth.ai/basics/unsloth-dynamic-2.0-ggufs">

      <img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">

    </a>

  </div>

</div>


---

<p align="center">
    <img src="https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Image/layered/layered.JPG" width="1024"/>

</p>


<p align="center">
  ๐Ÿค— <a href="https://huggingface.co/Qwen/Qwen-Image-Layered">Original Base Model</a> &nbsp;|&nbsp; 
  ๐Ÿ“‘ <a href="https://arxiv.org/abs/2512.15603">Research Paper</a> &nbsp;|&nbsp; 
  ๐Ÿ“‘ <a href="https://qwenlm.github.io/blog/qwen-image-layered/">Blog</a> &nbsp;|&nbsp; 
  ๐Ÿค— <a href="https://huggingface.co/spaces/Qwen/Qwen-Image-Layered">Official Demo</a>
</p>

## Introduction

This model is a **custom-adapted, designer-focused version of Qwen-Image-Layered**, enhanced to convert flat visual designs into fully editable, production-ready layered assets. 

While the base Qwen-Image-Layered model introduces the ability to decompose an image into multiple RGBA layers, we have tailored and extended the ecosystem with several key custom additions:

### ๐ŸŽจ Custom Modifications & Key Features

1. **Designer-Layer LoRA Fine-Tuning**:
   - **Targeted Training**: Fine-tuned using a transformer LoRA adapter on curated, permissioned multi-layer graphic designs and campaign materials.
   - **Semantic Separation**: Specialized in distinguishing foreground text, product imagery, badges, decorative elements, and clean background plates into separate, logical layers.
   - **Edge Quality & Transparency**: Focuses on preserving crisp alpha masks and canvas alignment, minimizing artifact bleeding when individual layers are moved or hidden.

2. **Automated Photoshop PSD Packaging**:
   - Includes custom downstream packaging tools (`package_psd.py` / `run_layered_diffusers.py`) that bundle decomposed RGBA layers into standard, editable **Adobe Photoshop (`.psd`)** documents.
   - Preserves layer stack order, naming conventions, exact canvas coordinates, and blend properties ready for professional editing workflows.

3. **GGUF Quantization & Local Inference**:
   - Provides quantized GGUF weights (Q5_0, Q5_1, Q5_K_M, Q5_K_S, Q6_K) leveraging the **Unsloth Dynamic 2.0** methodology to enable fast, low-VRAM local execution on consumer GPUs.



4. **Interactive Layer Studio UI**:

   - Accompanied by a lightweight local web interface (**Editable-Image-Layers-REA**) and REST API, allowing users to upload images, preview live decompositions, inspect individual layers, and export PSD or ZIP archives with a single click.



---



## Quick Start



### 1. Using Diffusers with the Designer LoRA Adapter



```python

from diffusers import QwenImageLayeredPipeline

import torch

from PIL import Image



# Load base pipeline

pipeline = QwenImageLayeredPipeline.from_pretrained("Qwen/Qwen-Image-Layered", torch_dtype=torch.bfloat16)

pipeline = pipeline.to("cuda")



# (Optional) Load custom designer LoRA adapter

# pipeline.load_lora_weights("path/to/designer-lora")



image = Image.open("input_design.png").convert("RGBA")
inputs = {
    "image": image,

    "generator": torch.Generator(device='cuda').manual_seed(42),

    "true_cfg_scale": 4.0,

    "negative_prompt": " ",

    "num_inference_steps": 50,

    "num_images_per_prompt": 1,

    "layers": 4,            # Number of layers to extract

    "resolution": 640,      # Recommended resolution bucket (640 or 1024)

    "cfg_normalize": True,

    "use_en_prompt": True,

}


with torch.inference_mode():

    output = pipeline(**inputs)

    layers = output.images[0]



# Save individual layer PNGs

for i, layer in enumerate(layers):

    layer.save(f"layer_{i:02d}.png")

```



### 2. Exporting to Layered Photoshop PSD



You can package the exported layer PNGs directly into a layered `.psd` file:



```bash

python package_psd.py --composite source.png --layers layer_00.png layer_01.png layer_02.png layer_03.png --output decomposition.psd

```



---



## Capabilities



### Layer Decomposition in Application

Given an input design, the model decomposes it into several RGBA layers:

- **Independent Manipulation**: Edits can be applied exclusively to targeted layers, physically isolating changes from the rest of the canvas.

- **Subject & Text Replacement**: Replace specific layer elements (e.g. swap subjects or text) without altering backgrounds.

- **Recoloring & Styling**: Recolor specific graphics, badges, or backgrounds while preserving unaffected elements.

- **Elementary Operations**:

  - **Clean Object Removal**: Erase elements cleanly by simply hiding or deleting layers.

  - **Repositioning & Resizing**: Move or resize objects freely on the canvas without distortion or background hole-filling issues.



### Flexible and Iterative Decomposition

- **Variable Layer Counts**: Supports decomposing images into arbitrary layer counts (e.g., 2, 4, 6, 8+ layers) depending on complexity.

- **Recursive Decomposition**: Any decomposed layer can be recursively passed back into the model to break it down further into sub-components.



---



## License Agreement



Qwen-Image-Layered is licensed under Apache 2.0. 



## Citation



```bibtex

@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}, 

}

```