Staged Background Composite
The photo-compositor that remembers your cutouts
- background
- foreground_images
- background_removal_model
- background_options
- image
- mask
- Boxes
- Layer Masks
Most "composite" nodes are one-shot: background in, foreground in, composite out, and if you want to move the subject you rerun everything including the background removal. This one is a whole different architecture. UC_StagedLayeredBackgroundComposite runs background removal once, retains the cutouts, and lets you place and re-place your subjects in a built-in scene editor without ever touching the removal model again. It's the closest ComfyUI has to a real photo-compositing session.
How it works
You give it a background image and a stack of foreground_images sockets (autogrowing from foreground_0 - the backmost layer - up to 50). Each foreground is run through a background-removal model to become a soft cutout, and the cutouts are cached. Then the node's execution_mode decides what happens:
run_staging- run the removal, retain the cutouts, and populate the placement editor so you can drag subjects around.run_staged- composite the retained cutouts without loading any model or evaluating the foreground branches. This is the fast loop: move a subject, re-run, instant.full_run- restage and composite in one queue, for when you've changed the foreground pixels themselves.
The placement editor is a LiteGraph scene managed through placement_data (a versioned JSON string the node's own editor widget writes - you don't hand-edit it). Outputs: image (the composite), mask, Boxes (bounding boxes per layer, type BOUNDING_BOX), and Layer Masks - a mask batch in layer order that downstream nodes can consume.
The removal model defaults to birefnet (the KB's panel calls BiRefNet the default cutout model, now shipped in ComfyUI core), selectable via background_removal_model_name; connect an external Core background_removal_model and it overrides the internal selector. Optional background_options plug in threshold, feather, cleanup, and border settings.
The gotcha you must remember
Retained cutouts live in server memory. Restart ComfyUI and they're gone - you have to re-run staging before run_staged will work again. The README says this in so many words, and it's the number-one "why is my composite empty" moment. Get in the habit: after a restart, kick off run_staging once, then switch to run_staged.
Where it shines
Product shots, character-on-background scenes, "same background, different subjects" work. The killer workflow is a background you like plus subjects you've already cut out - you stop paying the removal cost and start iterating on placement, scale, and order in seconds.
Install
Part of ComfyUI-UtilsCollection:
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection
Restart, or use ComfyUI Manager (search "UtilsCollection"). opencv-python and typing-extensions auto-install. BiRefNet weights come from ComfyUI core's background-removal model handling - if the internal model can't be found, check models/background_removal for the expected checkpoint filename or connect an external background_removal_model yourself.
Notes
If you want one full composite per foreground instead of a stacked scene, the pack ships UC_StagedIndividualComposites for exactly that. And because the foreground sockets are lazy, disconnected branches don't run - wire only the subjects you're staging.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| background | IMAGE | Single image used as the scene canvas. | |
| execution_mode | COMBO | run_staged | Frontend-managed staging request. Ordinary composition fingerprints foregrounds and reuses valid cutouts; the editor's Run Staging action forces a preview refresh. |
| placement_data | STRING | {"version":2,"workspace_padding":0.5,"layers":{}} | Versioned per-layer placement data managed by the LiteGraph scene editor. |
| background_removal_model_name | COMBO | birefnet | Internal model used when background_removal_model_opt is disconnected. Requires the exact checkpoint filename under models/background_removal. |
| foreground_images | COMFY_AUTOGROW_V3 | Foregrounds staged and composited from foreground_0 at the back to the highest socket at the front. | |
| background_removal_modelopt | BACKGROUND_REMOVAL | Optional external Core background-removal model. When connected it overrides the internal BiRefNet/Lucida selector. | |
| background_optionsopt | UC_STAGED_LAYERED_BACKGROUND_OPTIONS | Optional Staged Composite Options. Uses the option node defaults when disconnected. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| Boxes | BOUNDING_BOX | — |
| Layer Masks | MASK | — |