Instructions to use StabilityLabs/Stable-Layers with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use StabilityLabs/Stable-Layers with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,30 +1,50 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
> ### **Heun sampler · 50 steps · CFG 1.0 · 640 px · 4 layers**
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
| **Steps** | **50** | `--steps 50` |
|
| 19 |
-
| **CFG / guidance** | **1.0 (off)** | `--guidance-scale 1.0` |
|
| 20 |
-
| Resolution | 640 px (max dim) | `--size 640` |
|
| 21 |
-
| Layers | 4 | `--num-layers 4` |
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
##
|
| 28 |
|
| 29 |
```bash
|
| 30 |
pip install torch diffusers transformers peft pillow numpy
|
|
@@ -34,16 +54,22 @@ Tested with `torch 2.11`, `diffusers 0.37`, `transformers 5.5`, `peft 0.18`.
|
|
| 34 |
Requires **one GPU** — the base model is ~40 GB in bf16, so an 80 GB-class card
|
| 35 |
(A100-80 / H100 / H200) is comfortable.
|
| 36 |
|
| 37 |
-
|
| 38 |
|
| 39 |
-
##
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
-
|
|
|
|
| 45 |
|
| 46 |
-
##
|
| 47 |
|
| 48 |
```bash
|
| 49 |
# single image
|
|
@@ -59,9 +85,7 @@ python decompose.py --input images/ --output results/ --transparent
|
|
| 59 |
python decompose.py --input photo.png --output results/ --lora ./model
|
| 60 |
```
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
## Output
|
| 65 |
|
| 66 |
```
|
| 67 |
results/<image_name>/
|
|
@@ -81,9 +105,7 @@ By default layers are composited onto **white** (easy to eyeball). Pass
|
|
| 81 |
`--transparent` to get **RGBA with real alpha**, which is what you want when
|
| 82 |
importing into an editor or compositing them yourself.
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
## Notes
|
| 87 |
|
| 88 |
- **Reproducible:** noise is seeded per image as `seed + image_index`
|
| 89 |
(`--seed 42` by default), so the same inputs give the same outputs.
|
|
@@ -92,3 +114,25 @@ importing into an editor or compositing them yourself.
|
|
| 92 |
override with `--prompt` if you want.
|
| 93 |
- **Aspect ratio** is preserved; the longest side is scaled to `--size` and both
|
| 94 |
dimensions are rounded to multiples of 16.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: stabilityai-community
|
| 4 |
+
license_link: https://stability.ai/license
|
| 5 |
+
base_model: Qwen/Qwen-Image-Layered
|
| 6 |
+
library_name: peft
|
| 7 |
+
pipeline_tag: image-to-image
|
| 8 |
+
---
|
| 9 |
|
| 10 |
+
<h1 align="center">Stable Layers</h1>
|
| 11 |
|
| 12 |
+
<p align="center">
|
| 13 |
+
<strong>Decomposing Images into Editable RGBA Layers</strong>
|
| 14 |
+
</p>
|
| 15 |
+
|
| 16 |
+
<!-- Add a teaser image to the repo and it will render here. -->
|
| 17 |
+
<!--
|
| 18 |
+
<p align="center">
|
| 19 |
+
<img src="stable_layers_teaser.jpg" alt="Stable Layers Teaser" width="100%" />
|
| 20 |
+
</p>
|
| 21 |
+
-->
|
| 22 |
|
| 23 |
+
<p align="center">
|
| 24 |
+
<span><a href="https://arxiv.org/abs/2605.30257">Paper</a></span>
|
| 25 |
+
<span><a href="https://stability-ai.github.io/stable-layers.github.io/">Project Page</a></span>
|
| 26 |
+
<span><a href="https://huggingface.co/StabilityLabs/Stable-Layers">Model (Hugging Face)</a></span>
|
| 27 |
+
<span><a href="https://github.com/Stability-AI/Stable-Layers">Code</a></span>
|
| 28 |
+
</p>
|
| 29 |
|
| 30 |
+
## About
|
| 31 |
|
| 32 |
+
**Stable Layers** decomposes a single RGB image into a small stack of back-to-front
|
| 33 |
+
RGBA layers (background plus object layers) suitable for compositing and editing.
|
|
|
|
| 34 |
|
| 35 |
+
This repository hosts the LoRA adapter over `Qwen/Qwen-Image-Layered`. Note: whilst
|
| 36 |
+
the paper used Gemini, this model was retrained using an open VLM, and we found no
|
| 37 |
+
performance loss.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
## Model Artifacts
|
| 40 |
|
| 41 |
+
This repository **is** the LoRA adapter (`adapter_config.json`,
|
| 42 |
+
`adapter_model.safetensors`). The base model is pulled from Hugging Face
|
| 43 |
+
automatically (`Qwen/Qwen-Image-Layered`). See the
|
| 44 |
+
[code repository](https://github.com/Stability-AI/Stable-Layers) for the inference
|
| 45 |
+
script.
|
| 46 |
|
| 47 |
+
## Installation
|
| 48 |
|
| 49 |
```bash
|
| 50 |
pip install torch diffusers transformers peft pillow numpy
|
|
|
|
| 54 |
Requires **one GPU** — the base model is ~40 GB in bf16, so an 80 GB-class card
|
| 55 |
(A100-80 / H100 / H200) is comfortable.
|
| 56 |
|
| 57 |
+
## Recommended Inference Settings
|
| 58 |
|
| 59 |
+
> ### **Heun sampler · 50 steps · CFG 1.0 · 640 px · 4 layers**
|
| 60 |
|
| 61 |
+
| Setting | Value | Flag |
|
| 62 |
+
|---|---|---|
|
| 63 |
+
| **Sampler** | **Heun (2nd order)** | always used — not configurable |
|
| 64 |
+
| **Steps** | **50** | `--steps 50` |
|
| 65 |
+
| **CFG / guidance** | **1.0 (off)** | `--guidance-scale 1.0` |
|
| 66 |
+
| Resolution | 640 px (max dim) | `--size 640` |
|
| 67 |
+
| Layers | 4 | `--num-layers 4` |
|
| 68 |
|
| 69 |
+
**Note:** using a higher resolution, lower steps, or a non-Heun sampler will garble
|
| 70 |
+
the results.
|
| 71 |
|
| 72 |
+
## Quickstart
|
| 73 |
|
| 74 |
```bash
|
| 75 |
# single image
|
|
|
|
| 85 |
python decompose.py --input photo.png --output results/ --lora ./model
|
| 86 |
```
|
| 87 |
|
| 88 |
+
## Outputs
|
|
|
|
|
|
|
| 89 |
|
| 90 |
```
|
| 91 |
results/<image_name>/
|
|
|
|
| 105 |
`--transparent` to get **RGBA with real alpha**, which is what you want when
|
| 106 |
importing into an editor or compositing them yourself.
|
| 107 |
|
| 108 |
+
**Notes:**
|
|
|
|
|
|
|
| 109 |
|
| 110 |
- **Reproducible:** noise is seeded per image as `seed + image_index`
|
| 111 |
(`--seed 42` by default), so the same inputs give the same outputs.
|
|
|
|
| 114 |
override with `--prompt` if you want.
|
| 115 |
- **Aspect ratio** is preserved; the longest side is scaled to `--size` and both
|
| 116 |
dimensions are rounded to multiples of 16.
|
| 117 |
+
|
| 118 |
+
## License
|
| 119 |
+
|
| 120 |
+
This code and model usage are subject to Stability AI Community License terms.
|
| 121 |
+
|
| 122 |
+
For individuals or organizations generating annual revenue of USD 1,000,000 (or local
|
| 123 |
+
currency equivalent) or more, commercial usage requires an enterprise license from
|
| 124 |
+
Stability AI.
|
| 125 |
+
|
| 126 |
+
- License details: https://stability.ai/license
|
| 127 |
+
- Enterprise request: https://stability.ai/enterprise
|
| 128 |
+
|
| 129 |
+
## Citation
|
| 130 |
+
|
| 131 |
+
```
|
| 132 |
+
@article{stablelayers2026,
|
| 133 |
+
author = {},
|
| 134 |
+
title = {Stable Layers: Decomposing Images into Editable RGBA Layers},
|
| 135 |
+
journal = {arXiv preprint arXiv:2605.30257},
|
| 136 |
+
year = {2026}
|
| 137 |
+
}
|
| 138 |
+
```
|