Nodes/comfyui-fvmtools/Person Selector SAM3
ComfyUI Node

Person Selector SAM3

Person masks from plain text — SAM3 does the segmenting

By ping1979ping·Created 5 months ago·Updated about a month ago· 0
Person Selector SAM3
  • sam3_model
  • current_image
  • reference_1
  • outfit_palettes
  • depth_map
  • sam_model
  • reference_2
  • reference_3
  • reference_4
  • reference_5
  • reference_6
  • reference_7
  • reference_8
  • reference_9
  • reference_10
  • person_data
  • face_masks
  • head_masks
  • body_masks
  • aux_masks
  • preview
  • similarities
  • matches
  • matched_count
  • face_count
  • report
auto_thresholdtrue
threshold0.40
guaranteed_refs0
aggregation
det_size
aux_presetnone
aux_custom_prompt
aux_threshold0.30
match_weights50/15/15/20
depth_sort_orderfront_last
aux_yolo_modelNone
aux_yolo_confidence0.30
aux_yolo_label_filter
aux_yolo_sam_refinetrue
aux_yolo_sam_bbox_expansion0

PersonSelectorMulti can build body masks a few ways - SAM2, seed-growing, YOLO-driven carving. This node throws out most of that machinery and does the whole mask job with SAM3's text grounding. You supply the concept - "person", "face", "head", "upper body", even "backpack" - and SAM3 segments it. Non-overlapping masks by design, because text grounding produces them that way. No SAM2, no BiRefNet, no depth-overlap resolution needed.

It slots into the same position as PersonSelectorMulti: takes reference images, does the ArcFace matching with the same appearance-blend (match_weights, default 50/15/15/20), and emits PERSON_DATA for Person Detailer. The difference is entirely in how masks get made. Instead of a segmentation model plus carving tricks, SAM3 grounds each mask type with its own text prompt and confidence threshold - body at 0.15, face at 0.40, head at 0.30, hair at 0.40. BiSeNet still runs per-face for the fine facial subtypes (skin, eyes, mouth, neck, accessories), because those aren't SAM3-groundable.

The aux system is the fun part

aux_preset gives you upper_body / lower_body, clothing, hands / feet / arms / legs, headless_body, or custom - and custom takes any noun phrase. Want a "shoes" mask? Type "shoes". Regional detailing with zero extra model downloads beyond SAM3 itself. There's also an optional YOLO path (aux_yolo_model) that overrides the text-prompt aux pathway, with aux_yolo_sam_refine turning bbox-only detections into real pixel masks via SAM3 with SAM2 as fallback.

The inputs that matter

  • sam3_model - from the LoadSAM3Model node. Note the pack doesn't ship the loader; you need whichever SAM3 pack provides it.
  • current_image - supports batch input.
  • auto_threshold, threshold, guaranteed_refs, match_weights - the same matching controls as Multi.
  • aux_preset + aux_custom_prompt - the text-driven aux masks.
  • aux_threshold - confidence cutoff for aux detection.

Outputs

person_data, face_masks, head_masks, body_masks, aux_masks, an annotated preview, plus similarities, matches, matched_count, face_count, and report.

Install

Same face deps as the rest of the pack, plus the SAM3 model and its loader:

cd ComfyUI/custom_nodes
git clone https://github.com/ping1979ping/comfyui-FVMtools
pip install insightface>=0.7.3 onnxruntime-gpu>=1.17.0 opencv-python>=4.8.0 numpy>=1.24.0

Common issues

Empty or mushy masks usually mean the threshold for that mask type is off - the per-type config is fixed internally, so for aux masks adjust aux_threshold and lean on a well-lit reference for the rest. If you connect both aux_yolo_model and a preset, YOLO wins - it overrides the text pathway entirely. And if the selector errors at load, the SAM3 model config isn't connected or the loader pack isn't installed; the pack happily tells you sam3_model is required.

CategoryFVM Tools/Face

Inputs (30)

NameTypeDefaultDescription
sam3_modelSAM3_MODEL_CONFIGSAM3 model from LoadSAM3Model node
current_imageIMAGEImage(s) to process. Supports batch input.
auto_thresholdBOOLEANtrueAuto: optimal 1:1 face-reference assignment. Off: manual threshold.
thresholdFLOAT0.400–1Minimum similarity for matching. Ignored when auto is on.
guaranteed_refsINT00–10Force-assign first N references to best face.
aggregationCOMBOHow to combine similarity scores across reference images.
det_sizeCOMBOFace detection resolution.
aux_presetCOMBOnonePreset aux mask type: - upper_body / lower_body: body halves - clothing: all clothing (no shoes/socks) - hands / feet / arms / legs: body parts - headless_body: body minus head (computed) - custom: uses aux_custom_prompt below
aux_custom_promptSTRINGCustom SAM3 text prompt for aux mask (only used when aux_preset='custom'). Any noun phrase works: 'shoes', 'necklace', 'backpack', etc.
aux_thresholdFLOAT0.300.05–1Confidence threshold for aux detection.
match_weightsSTRING50/15/15/20Face/hair/head/outfit blend: '50/15/15/20'
reference_1optIMAGEReference image(s) for person 1.
outfit_palettesoptIMAGEPalette preview images for outfit matching.
depth_mapoptIMAGEDepth map for render order sorting.
depth_sort_orderoptCOMBOfront_lastRendering order for PersonDetailer.
aux_yolo_modeloptCOMBONoneOptional Ultralytics YOLO model for aux detection. Overrides the SAM3 text-prompt aux pathway when set. Bbox-only models are refined to pixel masks via SAM3/SAM when aux_yolo_sam_refine is on.
aux_yolo_confidenceoptFLOAT0.300.05–1YOLO detection confidence threshold.
aux_yolo_label_filteroptSTRINGComma-separated class-name substrings to keep (empty = all). Example: 'shoe,boot' or 'glasses'.
aux_yolo_sam_refineoptBOOLEANtrueOn (default): refine bbox-only YOLO detections into pixel masks using SAM3 (priority) → SAM2 (fallback). Off: use raw bbox rectangles as aux masks (today's bbox-only behavior).
sam_modeloptSAM_MODELOptional SAM2 model from Impact Pack SAMLoader. Used as fallback when sam3_model isn't suitable for refinement.
aux_yolo_sam_bbox_expansionoptINT00–64Pixels to expand bbox before SAM refinement (helps thin objects).
reference_2optIMAGE
reference_3optIMAGE
reference_4optIMAGE
reference_5optIMAGE
reference_6optIMAGE
reference_7optIMAGE
reference_8optIMAGE
reference_9optIMAGE
reference_10optIMAGE

Outputs (11)

NameTypeDescription
person_dataPERSON_DATA
face_masksMASK
head_masksMASK
body_masksMASK
aux_masksMASK
previewIMAGE
similaritiesSTRING
matchesSTRING
matched_countINT
face_countINT
reportSTRING