Nodes/ComfyUI-Inpaint-CropStitch-NB2/SAM 3 Image Segmenter (FAL API)
ComfyUI Node

SAM 3 Image Segmenter (FAL API)

SAM 3 Image Segmenter — 'garment' and nothing else comes back

By amortegui84·Created 5 months ago·Updated 3 months ago· 3
SAM 3 Image Segmenter (FAL API)
  • image
  • mask
  • mask_image
  • info
  • center_x
  • center_y
  • crop_width
  • crop_height
promptgarment
selection_modelargest
padding_percent0.0
return_rect_maskfalse
api_key
api_key_env_varFAL_KEY
mask_blur_percent0.0
upload_max_dimension2048
return_multiple_maskstrue
max_masks3
include_scorestrue
include_boxestrue
point_prompts_json
box_prompts_json

Florence-2 knows region categories. SAM 3 knows how to segment whatever you name. This node is the second one: it sends your image to FAL's fal-ai/sam-3/image endpoint with a text prompt - default garment - and gets back a clean semantic mask of that thing, ready to drive the pack's crop and stitch nodes.

Where it shines is object-level isolation for garment detail passes. The README's recommended flow puts it in front of Smart Object Isolate Crop:

SAM 3 "bra"   -> Smart Object Isolate Crop -> Seedream 4.5 Edit \
SAM 3 "pants" -> Smart Object Isolate Crop -> Seedream 4.5 Edit  -> Smart Mask Multi Stitch -> final

And because it shares the exact same output contract as the Florence selector - mask, mask_image, info, center_x, center_y, crop_width, crop_height - you can swap one for the other without rewiring anything downstream. That's deliberate, and it's the most useful property of this node.

Inputs

Required: image and prompt (the thing to segment - "bra", "pants", "glasses", "wheel", anything). Then:

  • selection_mode - largest (default), first, or merge_all when SAM returns multiple masks.
  • return_multiple_masks + max_masks (up to 32) - ask SAM for several candidates and pick; useful when the model keeps grabbing a whole outfit when you wanted one piece.
  • include_scores / include_boxes - on by default; they give you confidence scores and boxes in the info payload.
  • point_prompts_json / box_prompts_json - raw SAM point/box prompts as JSON lists, for when a text prompt isn't precise enough. This is the power-user escape hatch; most people never touch it.
  • padding_percent, return_rect_mask, mask_blur_percent, upload_max_dimension, and the api_key / api_key_env_var pair - same as the Florence selector.

The one thing to remember

SAM masks are already at exact source resolution, and the pack's crop nodes are built around Florence's quirk of letterboxing to a square. So on the downstream crop nodes - NB2 Smart Region or Smart Mask Crop - set depad_florence = False for SAM masks. The README is explicit about it: keep depad_florence = true only for Florence-style masks that need letterbox correction. Get this wrong and your crop lands shifted.

Install & keys

Search comfyui-inpaint-cropstitch-nb2 in ComfyUI Manager, or:

cd ComfyUI/custom_nodes
git clone https://github.com/amortegui84/comfyui-inpaint-cropstitch-nb2

Restart. This node calls FAL, so you need a key - api_key field or FAL_KEY env var set before launching ComfyUI (fully restart, not a browser refresh). A 401 on first call is the key not reaching the process. And if you run huge source images and FAL keeps dropping the connection, lower upload_max_dimension to 1536 or 1024 - that's the documented fix.

Categoryinpaint/api

Inputs (15)

NameTypeDefaultDescription
imageIMAGE
promptSTRINGgarment
selection_modeoptCOMBOlargest3 options: largest, first, merge_all
padding_percentoptFLOAT0.00–100
return_rect_maskoptBOOLEANfalse
api_keyoptSTRING
api_key_env_varoptSTRINGFAL_KEY
mask_blur_percentoptFLOAT0.00–100Soft blur applied to the returned SAM mask.
upload_max_dimensionoptINT2048512–4096
return_multiple_masksoptBOOLEANtrue
max_masksoptINT31–32
include_scoresoptBOOLEANtrue
include_boxesoptBOOLEANtrue
point_prompts_jsonoptSTRING
box_prompts_jsonoptSTRING

Outputs (7)

NameTypeDescription
maskMASK
mask_imageIMAGE
infoSTRING
center_xINT
center_yINT
crop_widthINT
crop_heightINT