Nodes/WorkflowX-Configurator/Anything Crop (for Swap)
ComfyUI Node

Anything Crop (for Swap)

Segment an object, crop tightly around it, and emit a payload that Anything Stitch uses to put the result back exactly.

By haroonaslam·Created 3 months ago·Updated a day ago· 10
Anything Crop (for Swap)
  • image
  • mask
  • crop
  • crop_mask
  • swap_prompt
  • source_masked
  • stitch
  • detected
use_sam3true
sam3_promptface
sam3_checkpoint
threshold0.50
refine_iterations2
keep_model_loadedtrue
select_mode
object_index0
expand_factor1.40
expand_pixels0
force_squarefalse
padding16
edge_handling
resize_mode
target_size1024
upscale_method
downscale_method
mask_grow0
mask_blur3
swap_promptReplace the {target} with the reference. Match the original lighting direction, colour temperature, and perspective. Preserve everything outside the mask exactly. Blend the edges seamlessly with no visible seam or colour shift.
caption
CategoryWorkflowX/Anything Swap

Inputs (23)

NameTypeDefaultDescription
imageIMAGESource image. Single image only, not a batch.
use_sam3BOOLEANtrueOn: segment internally from sam3_prompt. Off: use the mask input.
sam3_promptSTRINGfaceWhat to segment. Short, concrete nouns work best: 'face', 'left hand', 'shoe', 'sunglasses'.
sam3_checkpointCOMBOSAM3 checkpoint in models/checkpoints. It carries its own text encoder.
thresholdFLOAT0.500–1Detection confidence floor. Lower finds more, and more junk.
refine_iterationsINT20–5SAM3 mask refinement passes. 0 is fastest, 2 is the core default.
keep_model_loadedBOOLEANtrueKeep SAM3 in memory between runs. Off reloads from disk each time.
select_modeCOMBOWhich object to crop when the prompt matches several.
object_indexINT00–63Used only when select_mode is 'index'.
expand_factorFLOAT1.401–4Grow the bounding box around its centre. 1.0 is a tight crop.
expand_pixelsINT00–512Extra pixels added per side after expand_factor.
force_squareBOOLEANfalseSquare the crop. Right for faces, wasteful for hands, shoes, bottles. Required if resize_mode is 'target_size'.
paddingCOMBO16Round crop dimensions up to this multiple.
edge_handlingCOMBOshift: slide the box inside. pad_replicate: edge-pad the source. clamp: truncate.
resize_modeCOMBOnone preserves native resolution and is lossless.
target_sizeINT102464–8192
upscale_methodCOMBO5 options: lanczos, bicubic, bilinear, area, nearest-exact
downscale_methodCOMBO4 options: area, lanczos, bicubic, bilinear
mask_growINT0-256–256Dilate (+) or erode (-) before the bbox is measured.
mask_blurINT30–256Softens only the mask handed downstream. Does not affect stitching.
swap_promptSTRINGReplace the {target} with the reference. Match the original lighting direction, colour temperature, and perspective. Preserve everything outside the mask exactly. Blend the edges seamlessly with no visible seam or colour shift.Passed to the output. Tokens: {target} {width} {height} {caption}
maskoptMASKUsed when use_sam3 is off.
captionoptSTRINGOptional VLM caption, substituted into {caption}.

Outputs (6)

NameTypeDescription
cropIMAGEThe cropped region, ready for your swap model or API.
crop_maskMASKThe object's mask inside the crop, blurred by mask_blur.
swap_promptSTRINGswap_prompt with tokens substituted.
source_maskedIMAGESource with the object blanked. Preview, or feed an inpaint model.
stitchSWAP_STITCHOpaque payload for Anything Stitch. Carries the clean original and exact geometry.
detectedBOOLEANFalse when nothing was segmented. Branch on this to skip work.