Nodes/ComfyUI-FeiHou-Toolbox/多参图像自动拼接
ComfyUI Node

多参图像自动拼接

SAM3 builds the collage

By FX-FeiHou·Created 2 months ago·Updated 4 days ago· 127
多参图像自动拼接
  • model
  • clip
  • image_1
  • image_2
  • image_3
  • image_4
  • image_5
  • collage
  • alpha_mask
promptperson
width1280
height1280
detection_threshold0.50
backgroundwhite

Multi-character workflows have a boring bottleneck: getting all your reference people into one image. The usual route is opening a photo editor, cutting each person out by hand, and pasting them onto a shared canvas so your model can actually see everyone at once. AutoRefCollage is the "stop doing that" node. It runs SAM3 over up to five reference images, cuts the people out automatically, and composes them into a single collage on the canvas size you specify. One node, one run, a ready-made multi-reference image to feed your generator.

It ships in the ComfyUI-FeiHou-Toolbox pack, from the same author who put out the popular wan2.2-Remix workflow on HuggingFace. This is a new, single-maintainer pack - don't expect a huge support community behind it, but the code is straightforward and the node does exactly what it says.

How it works

The mechanism leans entirely on SAM3's promptable concept segmentation (covered in the KB's SAM panel: point a short noun phrase at an image and it returns masks for every matching instance in one pass - the old GroundingDINO-plus-SAM two-step folded into one model). Each connected image input gets segmented with the internal prompt - default person - the subject is cut out on an alpha mask, and all cutouts are auto-arranged onto a width × height canvas with your chosen background. Only the first frame of each input batch is used, so feeding a video still works.

Because this is SAM3, the two model inputs matter more than anything else in the schema. model and clip come from a CheckpointLoaderSimple - but they must be a SAM3/SAM3.1 checkpoint, not your SDXL or Flux model. The node encodes its prompt with the supplied CLIP, so if you feed it the wrong checkpoint, nothing segments correctly. Worth knowing up front: SAM3 ships under Meta's custom SAM License, not Apache, so it has its own acceptable-use terms.

The inputs and outputs that matter

  • prompt - the SAM3 detection phrase. Default person. Keep it short and specific: woman, character, or an object name beats a sentence. This is the single thing you'll tune.
  • detection_threshold (default 0.5) - mask threshold after segmentation. Lower keeps more edge detail, higher strips weak regions. If hair comes out ragged, nudge it down.
  • width / height (default 1280×1280, step 8) - the collage canvas size, in the model's preferred step increments.
  • background - white or black behind the cutouts.
  • image_1 through image_5 - your references. All optional; connect one and it still works.

Outputs: collage (the RGB IMAGE) and alpha_mask (a MASK of the composited subjects). alpha_mask is handy if you want to composite the result over something else later rather than accept the node's background.

Install

ComfyUI Manager - search ComfyUI-FeiHou-Toolbox, install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/FX-FeiHou/ComfyUI-FeiHou-Toolbox

Then restart ComfyUI and hard-refresh the browser (Ctrl+Shift+R). No extra Python dependencies - the pack ships zero requirements - but you do need a reasonably current ComfyUI build, since the whole pack is written against the newer comfy_api.latest node API. And you need a SAM3 checkpoint on disk (e.g. a Comfy-Org/SAM3* model) loadable through CheckpointLoaderSimple.

Common issues

  • Blank or empty collage - no image inputs connected, or every input was bypassed. The node returns a blank canvas of your chosen size; wire at least one image.
  • Wrong subjects cut - the prompt is picking up everything or nothing. Shorten it or change the detection phrase.
  • Ragged edges - detection_threshold too high. Lower it toward 0.4–0.3 and the mask keeps more detail.

AutoRefCollage trades control for speed: you get zero say in where each person lands. When the auto-layout isn't good enough - usually with poses that overlap - grab its sibling ManualRefCollage, which gives you a drag-and-drop canvas over the same SAM3 pipeline.

Categoryimage/compositing

Inputs (12)

NameTypeDefaultDescription
modelMODELSAM3/SAM3.1 model from CheckpointLoaderSimple.
clipCLIPSAM3/SAM3.1 CLIP from CheckpointLoaderSimple. The node encodes its internal prompt with this input.
promptSTRINGpersonText prompt used internally for SAM3 detection. Use a short object phrase, e.g. person or woman.
widthINT128064–8192Output collage width.
heightINT128064–8192Output collage height.
detection_thresholdFLOAT0.500–1SAM3 mask threshold after segmentation. Lower values keep more edge/detail; higher values remove weak regions.
backgroundCOMBOwhiteBackground color for the RGB collage image output.
image_1optIMAGE
image_2optIMAGE
image_3optIMAGE
image_4optIMAGE
image_5optIMAGE

Outputs (2)

NameTypeDescription
collageIMAGE
alpha_maskMASK