File size: 2,782 Bytes
7059126
 
119075f
32a2d49
 
7059126
 
 
 
119075f
32a2d49
119075f
 
 
 
32a2d49
 
119075f
 
 
 
 
 
7059126
 
119075f
32a2d49
119075f
 
32a2d49
119075f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32a2d49
119075f
 
32a2d49
119075f
 
 
 
 
 
 
32a2d49
119075f
 
 
 
 
 
32a2d49
119075f
 
 
 
32a2d49
 
 
119075f
 
 
 
 
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
---
title: Stable Layers
emoji: ๐Ÿ—‚๏ธ
colorFrom: yellow
colorTo: purple
sdk: gradio
sdk_version: 6.22.0
app_file: app.py
pinned: false
short_description: Split an image into editable RGBA layers
python_version: "3.12"
startup_duration_timeout: 1h
license: other
license_name: stabilityai-community
license_link: https://stability.ai/license
models:
  - StabilityLabs/Stable-Layers
  - Qwen/Qwen-Image-Layered
tags:
  - layer-decomposition
  - rgba
  - image-editing
  - lora
---

# ๐Ÿ—‚๏ธ Stable Layers

Split any image into a stack of **editable RGBA layers** โ€” an inpainted background plus
one object per layer โ€” with
[StabilityLabs/Stable-Layers](https://huggingface.co/StabilityLabs/Stable-Layers), a LoRA
over the [Qwen/Qwen-Image-Layered](https://huggingface.co/Qwen/Qwen-Image-Layered)
pipeline (20.4B DiT).

## What you get

Layers come out **back-to-front**: layer 0 is the background, repainted behind everything
that was lifted off it; each higher layer is one object with real alpha. Stacking them all
reproduces the original image.

The viewer on the right is the point of the demo โ€” click a layer to select it, drag it
around the canvas, and toggle layers off to watch the composite fall apart and rebuild.
Every layer is downloadable as a genuine transparent PNG (single layer or the whole set
as a ZIP), ready to drop into an editor.

## Inference

Locked to the recipe the authors specify, because deviating from it garbles the
decomposition:

| Setting | Value |
|---|---|
| Sampler | Heun (2nd order) |
| Steps | 50 |
| CFG | 1.0 (off) |
| Max dimension | 640 px |
| Layers | 4 (2โ€“6 selectable) |

The `QwenImageLayeredPipeline.__call__` path (Euler + `true_cfg_scale=4.0`) is the *base
model's* recipe, so this Space reimplements the reference
[`decompose.py`](https://github.com/Stability-AI/Stable-Layers) denoise loop directly. The
adapter is a raw PEFT checkpoint on `QwenImageTransformer2DModel` whose keys carry no
`transformer.` prefix, so it is applied with `PeftModel.from_pretrained(...)` +
`merge_and_unload()` rather than `load_lora_weights` (which silently no-ops on it).

Runs on ZeroGPU at `size="xlarge"`: the transformer (40.9 GB), the Qwen2.5-VL text encoder
(16.6 GB) and the RGBA VAE total ~58 GB of bf16 weights, over the 48 GB `large` slice.
Transformer blocks are served from an ahead-of-time-compiled (AOTInductor) package when
one is available, with an automatic eager fallback.

## Credits

Model by [Stability AI](https://huggingface.co/StabilityLabs), released under the
[Stability AI Community License](https://stability.ai/license). Base pipeline by
[Qwen](https://huggingface.co/Qwen). Example images are from the
[Qwen/Qwen-Image-Layered](https://huggingface.co/spaces/Qwen/Qwen-Image-Layered) demo
Space (Apache-2.0).