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.
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)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Source image. Single image only, not a batch. | |
| use_sam3 | BOOLEAN | true | On: segment internally from sam3_prompt. Off: use the mask input. |
| sam3_prompt | STRING | face | What to segment. Short, concrete nouns work best: 'face', 'left hand', 'shoe', 'sunglasses'. |
| sam3_checkpoint | COMBO | SAM3 checkpoint in models/checkpoints. It carries its own text encoder. | |
| threshold | FLOAT | 0.500–1 | Detection confidence floor. Lower finds more, and more junk. |
| refine_iterations | INT | 20–5 | SAM3 mask refinement passes. 0 is fastest, 2 is the core default. |
| keep_model_loaded | BOOLEAN | true | Keep SAM3 in memory between runs. Off reloads from disk each time. |
| select_mode | COMBO | Which object to crop when the prompt matches several. | |
| object_index | INT | 00–63 | Used only when select_mode is 'index'. |
| expand_factor | FLOAT | 1.401–4 | Grow the bounding box around its centre. 1.0 is a tight crop. |
| expand_pixels | INT | 00–512 | Extra pixels added per side after expand_factor. |
| force_square | BOOLEAN | false | Square the crop. Right for faces, wasteful for hands, shoes, bottles. Required if resize_mode is 'target_size'. |
| padding | COMBO | 16 | Round crop dimensions up to this multiple. |
| edge_handling | COMBO | shift: slide the box inside. pad_replicate: edge-pad the source. clamp: truncate. | |
| resize_mode | COMBO | none preserves native resolution and is lossless. | |
| target_size | INT | 102464–8192 | — |
| upscale_method | COMBO | 5 options: lanczos, bicubic, bilinear, area, nearest-exact | |
| downscale_method | COMBO | 4 options: area, lanczos, bicubic, bilinear | |
| mask_grow | INT | 0-256–256 | Dilate (+) or erode (-) before the bbox is measured. |
| mask_blur | INT | 30–256 | Softens only the mask handed downstream. Does not affect stitching. |
| swap_prompt | STRING | Replace 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} |
| maskopt | MASK | Used when use_sam3 is off. | |
| captionopt | STRING | Optional VLM caption, substituted into {caption}. |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| crop | IMAGE | The cropped region, ready for your swap model or API. |
| crop_mask | MASK | The object's mask inside the crop, blurred by mask_blur. |
| swap_prompt | STRING | swap_prompt with tokens substituted. |
| source_masked | IMAGE | Source with the object blanked. Preview, or feed an inpaint model. |
| stitch | SWAP_STITCH | Opaque payload for Anything Stitch. Carries the clean original and exact geometry. |
| detected | BOOLEAN | False when nothing was segmented. Branch on this to skip work. |