ComfyUI Node

Anything Stitch

Put the swapped object back so the seam disappears

By haroonaslam·Created 4 months ago·Updated 7 days ago· 10
Anything Stitch
  • stitch
  • swapped
  • mask_override
  • image
  • changed_mask
size_mismatchresize
mask_mode
feather6
color_matchtrue
color_match_methodmkl
color_match_strength1.00

The third act of object swapping is where most pipelines die: you've got the replacement crop back from your model or API, and now it has to go back into the original photo without a visible border. Anything Stitch is the node for that. It takes the geometry payload from Anything Crop (for Swap) and the edited crop, and composites the swap back in - with feathering, color matching, and the promise that pixels outside the mask come back bit-identical to the original.

That last part is the differentiator. Because the crop node embeds the clean original and exact geometry in the SWAP_STITCH payload, the stitch node can work from ground truth, not from whatever the swap model happened to produce. Nothing outside the changed region gets touched, which is exactly what you want when you're swapping a face in a photo where the rest of the frame must survive untouched.

How it works

Anything Stitch reads stitch (the payload from Anything Crop), takes swapped (the crop your model generated), and composites. The flow is defensive by design:

  • If detected in the payload was false, it returns the original untouched - no fake stitching.
  • If the swapped image has an alpha channel (some APIs hand back RGBA), it drops it with a warning.
  • It only accepts a single image; a batch throws.

The geometry comes from the payload: crop bbox, pre/post-resize sizes, and source padding all travel inside stitch, so the node doesn't re-derive anything. When the swap model returns a different resolution, size_mismatch decides - resize rescales but rejects an aspect-ratio change, stretch rescales regardless (distorting), error demands an exact match.

The seam handling is where quality lives. feather softens the mask edge, color_match runs a weighted color transfer (reinhard, mkl, or hm) that - cleverly - matches against the original pre-swap crop and weights by the mask, so background pixels in the crop don't drag the correction away from skin tones. changed_mask output tells you exactly which pixels changed at source resolution, handy for a refinement pass.

Inputs and outputs

  • stitch (SWAP_STITCH) - from Anything Crop. Required.
  • swapped (IMAGE) - your edited crop. Required.
  • mask_override (MASK, optional) - replaces the payload mask if you want control.
  • Outputs: image (IMAGE) - the full stitched result; changed_mask (MASK) - the changed region.

Install

Same pack: WorkflowX-Configurator via Manager (WorkflowX Configurator) or:

cd ComfyUI/custom_nodes
git clone https://github.com/haroonaslam/WorkflowX-Configurator

Restart, hard-refresh. No model downloads for the stitch side - the SAM3 model requirement lives with the crop node.

Common issues

  • "stitch is not connected" - wire the stitch output from Anything Crop, not something you built yourself. The payload is opaque; you can't hand-assemble it.
  • Swapped image looks stretched. Your swap model changed the aspect ratio and size_mismatch was resize. Switch to stretch only if the distortion is acceptable, or regenerate at the right aspect.
  • Seams still visible. Raise feather, and make sure color_match is on. If the color still drifts, lower color_match_strength rather than killing the match - full-strength transfer can overcorrect.

For a genuinely seamless result, the discipline is: feed the crop node good geometry (a hair of expand_factor so the model has context), then let the stitch node's feathering and weighted color match do their job instead of stacking a bunch of post-processing. This pair is the part of WorkflowX that most deserves a try.

CategoryWorkflowX/Anything Swap

Inputs (9)

NameTypeDefaultDescription
stitchSWAP_STITCHPayload from Anything Crop. Carries the clean original and exact geometry.
swappedIMAGEThe edited crop, straight back from your model or API.
size_mismatchCOMBOresizeWhat to do when the swap model returns a different resolution. resize: rescale, but reject a changed aspect ratio. stretch: rescale regardless, distorting. error: demand an exact match.
mask_modeCOMBO3 options: payload_mask, full_rect, override
featherINT60–256
color_matchBOOLEANtrue
color_match_methodCOMBOmkl3 options: reinhard, mkl, hm
color_match_strengthFLOAT1.000–1
mask_overrideoptMASK

Outputs (2)

NameTypeDescription
imageIMAGEThe full source image with the swapped region composited back in.
changed_maskMASKWhich pixels changed, at source resolution. Feed a refiner pass.