Nodes/ComfyUI-BFSNodes/BFS Paste Back
ComfyUI Node

BFS Paste Back

BFS Head Swap Paste Back — bringing a refined crop home

By alisson-anjos·Created 6 months ago·Updated 18 days ago· 111
BFS Paste Back
  • cropped_images
  • original_images
  • crop_bboxes
  • confine_mask
  • images
feather16

BFS Head Swap Paste Back is the second half of the crop-and-composite head swap, and on its own it's about the simplest node in this pack: processed crops in, original frames in, crop boxes in, composite out. You reach for it after you've refined a swap in a second pass - which is exactly what the BFS Head Swap Sampler's paste_back toggle is for.

Why it exists

When the sampler runs with paste_back on (the default), it composites the crop into the original frames internally and you never see this node. Turn paste_back off and the sampler returns images and a latent that stay in the crop's own space. That matters because the crop is where the face actually has pixels: you can upscale it 2x, run a refinement or detailing pass, fix a bad eye in the close-up - then bring the result home with Paste Back. It's the difference between swapping a face at 25 pixels tall and swapping one at 200.

How it works

Feather, then place. Each crop gets alpha-blended into its frame with an edge-aware feather ramp (default feather of 16 px). Sides of the crop that sit on the image edge aren't feathered at all - there's nothing outside to blend into, and fading there just leaves a washed band along the frame border. If your refined crop no longer matches the box size, it's lanczos-resized back before blending, so you don't have to obsess over keeping the second pass at the exact same resolution. Pass an optional confine_mask and the paste is restricted to that mask in the crop's space, so anything the model changed in the crop's background never reaches the original frames.

Inputs

  • cropped_images - your processed crops, at any resolution.
  • original_images - the frames to paste into.
  • crop_bboxes - connect the sampler's crop_bboxes output. One box per frame. This is a socket, not a field to fill in: typing a single box by hand would paste every frame into the same fixed rectangle.
  • feather - blend width in pixels (0–256, default 16).
  • confine_mask (optional) - restrict the paste to a mask, in the crop's space.

Output is a single images socket with the composited frames.

Install

Same pack, same install as the sampler: install ComfyUI-BFSNodes via ComfyUI Manager (search "ComfyUI-BFSNodes") or

cd ComfyUI/custom_nodes
git clone https://github.com/alisson-anjos/ComfyUI-BFSNodes.git
cd ComfyUI-BFSNodes && pip install -r requirements.txt

then restart ComfyUI. The node itself has no extra dependencies beyond the pack - the heavy lifting (LTX model, VAE, head-swap LoRA, crop planning) happens in the sampler before this node ever sees a frame.

Gotchas

The two things that bite: keep crop_bboxes wired straight from the sampler (a mismatched box list pastes crops into the wrong spots), and remember the feather only blends inward - if the crop sits fully inside the frame with no margin, a soft blend is doing less than you think it is. If you're getting a hard rectangle outline on the paste, raise feather; if you're getting a washed-out band along the frame edge, that side of the crop touches the border and feathering there is intentionally skipped.

CategoryBFS/video

Inputs (5)

NameTypeDefaultDescription
cropped_imagesIMAGEProcessed crops, at any resolution.
original_imagesIMAGEThe frames to paste into.
crop_bboxesBOUNDING_BOXConnect the sampler's crop_bboxes output -- one box per frame. This is a socket, not something to fill in: typing a single box by hand would paste every frame into the same fixed rectangle.
featherINT160–256
confine_maskoptMASKConfines the paste to the mask instead of the whole box, in the crop's space.

Outputs (1)

NameTypeDescription
imagesIMAGE