Spaces:
Running on Zero
Running on Zero
multimodalart HF Staff
Rebuild: reference Heun recipe + interactive layer-stack viewer
119075f verified | 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). | |