Decompose an image into stacked RGBA layers inside ComfyUI — Stability AI's Stable-Layers adapter on top of Qwen-Image-Layered. Background plus objects, back to front, with the hidden parts painted back in.
View on GitHub →Reproduces Stability's own published grouping for this image: room / sofa / table / bouquet. Layer 0 has the sofa removed and the wall and carpet behind it painted back in.
Flat illustration, four layers: the model separates sky, cliffs and foreground trees even though nothing is photographically distinct.
Background, figure, then the clothing-and-bag group. Each layer carries its own alpha, so any of them can be moved or recoloured independently.
Drag example_workflows/stable_layers_decompose.json from the repo onto the ComfyUI canvas. Load the diffusion model, apply the adapter, encode the input image as a reference latent for both conditionings, sample into a layered latent, cut the layer axis into a batch, decode, then split and save with alpha intact.
Mid-run: per-node timings across the top, the input image on the left, and the four decoded layers previewed in Save Layers (RGBA) on the right — 91 s end to end at 640 px. Click to open full size.
PEFT saves tensors as
base_model.model.transformer_blocks.0.attn.to_q.lora_A.weight. ComfyUI's QwenImage key
map accepts the bare form, transformer. and lycoris — not this one. The stock
LoraLoaderModelOnly matches 0 of 840 tensors and silently applies nothing.
PEFT keeps lora_alpha in
adapter_config.json; ComfyUI reads it from an .alpha tensor and otherwise
assumes alpha = rank. That is scale 1.0 instead of the intended 2.0.
Core SaveImage converts to RGB and
drops the alpha channel, which makes it useless for a layer stack. This pack writes real RGBA.
A correct load prints 420 patches attached (60 blocks × 7 modules) and no
lora key not loaded warnings.
| base Qwen-Image-Layered | + Stable-Layers | |
|---|---|---|
| sampler | euler | heun |
| steps | 20 | 50 |
| CFG | 2.5 | 1.0 |
| input size | 640 px | 640 px max |
| LoRA strength | — | 1.0 shipped; 0.75 keeps one subject in one layer |
The adapter's recipe is not the base model's recipe — a non-Heun sampler, fewer steps or a higher
resolution garble the output. At full strength the adapter chases its "spread content across layers"
reward hard enough to split a lone figure into torso, legs and arms: useful when you want per-limb
depth, and what the Merge Layer Range node undoes when you don't.
ComfyUI's own execution_start → execution_success, RTX 5090, 640 px, 4 layers,
one variable at a time.
| recipe | text encoder | time |
|---|---|---|
| euler 20 · CFG 2.5 | GPU | 44 s |
| euler 20 · CFG 2.5 | CPU | 62 s |
| euler 20 · CFG 1.0 | CPU | 48 s |
| heun 50 · CFG 1.0 | CPU | 95 s |
| heun 50 · CFG 1.0 + Stable-Layers | CPU | 97 s |
The adapter itself costs about two seconds; the recipe is what you pay for. Do not time this from a client — a queue wait or the first 20.5 GB weight load dwarfs the run.