ComfyUI Node
BD MP SAM3 Face Segment
MediaPipe-guided SAM3 face segmentation: localizes each feature with MediaPipe, then prompts SAM3 per feature (box + positive landmark points + sibling negatives) for pixel-accurate masks. Solves the stylized-brow offset that landmark-only bands can't. Outputs RGBA zone map + individual masks. Wire a comfy-core SAM3 MODEL (same as SAM3 Detect).
BD MP SAM3 Face Segment
- image
- model
- silhouette_mask
- head_mask
- rgba
- face_oval
- skin
- left_eye
- right_eye
- eyes
- left_brow
- right_brow
- brows
- left_iris
- right_iris
- irises
- lips
- nose
- left_ear
- right_ear
- ears
- forehead
- hair
- head_mask
- masked_skin
- silhouette
- debug_overlay
- status
- head_cutout
- head_cutout_clean
◄anglefront►
◄do_browstrue►
◄do_eyestrue►
◄do_lipstrue►
◄do_nosetrue►
◄do_earsfalse►
◄detection_confidence0.30►
◄min_face_span0.35►
◄mask_threshold0.50►
◄refine_iterations1►
◄bleed_guard48►
◄brow_bleed_guard44►
◄lips_bleed_guard12►
◄eye_bleed_guard10►
◄cleanuptrue►
◄fill_holestrue►
◄lips_modemouth►
◄edge_smooth3►
◄edge_refineoff►
◄refine_radius8►
◄refine_eps0.0001►
◄refine_threshold0.50►
◄vitmatte_modelsmall►
◄remove_backgroundfalse►
◄head_promptshead
face
hair
ear►
◄exclude_promptsneck
shirt
clothing
shoulder►
◄neck_cuttrue►
◄cutout_bgtransparent►
◄drop_eyestrue►
◄drop_browstrue►
◄drop_lipstrue►
◄drop_nosefalse►
◄skin_color_filteroff►
◄skin_color_threshold0.30►
◄drop_facial_hairfalse►
Category🧠BrainDead/Segmentation
Inputs (39)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Full-color full-resolution face image. Only image[0] is used. | |
| modelopt | MODEL | Comfy-core SAM3 model (override). Leave UNWIRED to auto-load + auto-download the official SAM3 checkpoint in-house (bd_sam3) — no setup. | |
| angleopt | COMBO | front | Stored for downstream/context use only. |
| do_browsopt | BOOLEAN | true | Segment eyebrows with SAM3 (recommended — fixes the offset). |
| do_eyesopt | BOOLEAN | true | Segment eyes with SAM3. |
| do_lipsopt | BOOLEAN | true | Segment lips with SAM3. |
| do_noseopt | BOOLEAN | true | Segment nose with SAM3. |
| do_earsopt | BOOLEAN | false | Segment ears with TEXT-grounded SAM3 ('ear', split L/R at the face centre) instead of the weak MediaPipe approximation (the face mesh has no outer-ear points). Off = MediaPipe ears. Loads the SAM3 text encoder in-house. |
| detection_confidenceopt | FLOAT | 0.300.1–1 | MediaPipe face detection confidence. 0.3 works for stylized renders. |
| min_face_spanopt | FLOAT | 0.350–1 | Tiny-detection guard (see BD MP Face Export). 0 disables. |
| mask_thresholdopt | FLOAT | 0.500.05–0.95 | SAM3 mask probability cutoff. |
| refine_iterationsopt | INT | 10–5 | SAM decoder refinement passes. NOTE: extra passes tend to SHRINK masks on stylized/non-photo renders — 1 (no mask-refine) gives the fullest feature; raise only if SAM3 over-segments. |
| bleed_guardopt | INT | 480–200 | GENERAL bleed-guard: dilate the MediaPipe feature zone by this many px (at native res), then clip SAM3's mask to it. Used for NOSE + as the fallback. Brows/eyes/lips have their own (brow_/eye_/lips_bleed_guard). 0 = clip exactly to MediaPipe. |
| brow_bleed_guardopt | INT | 440–200 | Bleed-guard for BROWS only. Brows need a LARGE guard (~40-45): their MediaPipe landmarks sit inside/below the painted brow, so SAM3 must grow out to fill it. Raise if brows read thin; this won't loosen eyes/lips (they're separate). |
| lips_bleed_guardopt | INT | 120–200 | Bleed-guard for LIPS only — kept separate because brows need a LARGE guard (40-45) to fill while lips need a SMALL one or they overflow onto the face. Lower = tighter lips (12 hugs the lip contour; 0 = clip exactly to MediaPipe). |
| eye_bleed_guardopt | INT | 100–200 | Bleed-guard for EYES only. SAM3 grows to the whole eye (lid/lashes/sclera); a small guard clips it back toward the eyelid aperture so the mask hugs the eyeball — like BD Face Infill's eroded eyelid hull. Lower = tighter (0 = clip exactly to the MediaPipe eye contour). |
| cleanupopt | BOOLEAN | true | Clean SAM3 noise: keep only the connected component(s) the positive landmark seeds land in (drops stray chunks around eyes/lips). |
| fill_holesopt | BOOLEAN | true | Fill interior holes on NON-lip features (eyes/nose/etc.) so each is solid. Lips are controlled separately by lips_mode. |
| lips_modeopt | COMBO | mouth | Lips-specific: mouth — fill the whole mouth area (lips + teeth + tongue) into the lips mask (default; what the pipeline wants). lips_only — lip flesh only; color-aware edge_refine excludes teeth/tongue. Overrides fill_holes for the lips feature. |
| edge_smoothopt | INT | 30–15 | Morphological close+open radius (px @native) to smooth jagged SAM3 edges during cleanup. 0 = no smoothing. |
| edge_refineopt | COMBO | off | Snap the mask edge to image color/edges after cleanup. off — no refinement guided — guided filter (fast, edge-aware; good general snap) matting — PyMatting closed-form alpha matting (CPU, no model) vitmatte — VitMatte deep matting model (best on soft/hair edges; GPU; loads hustvl vitmatte-small). All run on the feature ROI crop. |
| refine_radiusopt | INT | 81–40 | Guided-filter radius / matting trimap band width (px @native). Larger = looks further for an edge / wider uncertain band. |
| refine_epsopt | FLOAT | 0.00010.000001–0.1 | Guided-filter edge sensitivity (smaller = sharper, hugs edges harder). Ignored by matting. |
| refine_thresholdopt | FLOAT | 0.500.05–0.95 | Binarize the refined alpha at this level. |
| vitmatte_modelopt | COMBO | small | VitMatte variant for edge_refine='vitmatte'. Auto-downloaded from the HF hub (hustvl/vitmatte-{small,base}-composition-1k) on first use — standalone, no other node pack required. base = higher quality, larger. |
| silhouette_maskopt | MASK | Optional head silhouette (white=head). When wired, ALL outputs are clipped to it and it becomes head_mask; masked_skin = skin within it. Overrides remove_background. (Or let remove_background compute it in-house.) | |
| head_maskopt | MASK | Optional inner head/face-plate mask used as the skin base (skin = head_mask − eyes − brows − lips). Falls back to face_oval. Echoed to the head_mask output. | |
| remove_backgroundopt | BOOLEAN | false | Compute a clean HEAD silhouette IN-HOUSE (text-grounded SAM3, no extra nodes): segment head_prompts as positive, exclude_prompts (neck/shirt/etc.) as negative → head minus neck/clothing/background. Clips every output to it, becomes head_mask, and is emitted as the `silhouette` output. Skipped if silhouette_mask is wired. Auto-downloads the SAM3 checkpoint if needed. |
| head_promptsopt | STRING | head face hair ear | remove_background positives — one per line. Union = the head. |
| exclude_promptsopt | STRING | neck shirt clothing shoulder | remove_background negatives — one per line. Their union is SUBTRACTED from the head (peels off neck / clothing / body). |
| neck_cutopt | BOOLEAN | true | With remove_background: remove the neck. PRIMARY = in-house SegFormer face parser (1038lab/segformer_face, auto-downloaded) — subtracts its real Neck/Clothing/Necklace classes (per-pixel, reliable). FALLBACK if it can't load = cut below the MediaPipe jawline contour. Off = keep the neck. |
| cutout_bgopt | COMBO | transparent | Background for the head_cutout / head_cutout_clean image outputs: transparent (RGBA alpha), or composited on black / white. |
| drop_eyesopt | BOOLEAN | true | head_cutout_clean: remove the eyes (punch-out — fill is left to BD MP Face Infill). |
| drop_browsopt | BOOLEAN | true | head_cutout_clean: remove the brows. |
| drop_lipsopt | BOOLEAN | true | head_cutout_clean: remove the lips/mouth. |
| drop_noseopt | BOOLEAN | false | head_cutout_clean: remove the nose (off by default — nose is usually kept skin). |
| skin_color_filteropt | COMBO | off | Refine the `skin`/`masked_skin` outputs by COLOUR (same engine as BD SAM3 Multi-Prompt / BD Mask Resolver): adaptive_lab samples the skin tone from the current skin region and keeps pixels within ΔE tolerance (works for any tone); fixed_hsv uses HSV skin ranges; both = stricter. Drops non-skin pixels (e.g. a dark mustache) from skin. Off = skin is purely geometric (head − features). |
| skin_color_thresholdopt | FLOAT | 0.300–1 | skin_color_filter cutoff: keep pixels with skin-likelihood ≥ this. Lower for stylized art (more permissive). |
| drop_facial_hairopt | BOOLEAN | false | head_cutout_clean: also punch out non-skin-coloured facial hair (mustache/beard) in the lower face, found via the skin colour filter (SAM3 text + face-parse can't segment facial hair on stylized art). Best-effort; uses skin_color_threshold. Wire the result to BD MP Face Infill to repaint it. |
Outputs (26)
| Name | Type | Description |
|---|---|---|
| rgba | IMAGE | RGBA zone map: R=lips, G=brows, B=eyes, A=face_oval. |
| face_oval | MASK | — |
| skin | MASK | — |
| left_eye | MASK | — |
| right_eye | MASK | — |
| eyes | MASK | — |
| left_brow | MASK | — |
| right_brow | MASK | — |
| brows | MASK | — |
| left_iris | MASK | — |
| right_iris | MASK | — |
| irises | MASK | — |
| lips | MASK | — |
| nose | MASK | — |
| left_ear | MASK | — |
| right_ear | MASK | — |
| ears | MASK | — |
| forehead | MASK | — |
| hair | MASK | — |
| head_mask | MASK | — |
| masked_skin | MASK | — |
| silhouette | MASK | The head silhouette used for clipping (head − neck/clothing/bg). When remove_background is on it's the in-house text-SAM3 head cutout; else the wired silhouette_mask, else face_oval. Wire this anywhere you need 'head but not neck' — replaces a separate background-removal + silhouette chain. |
| debug_overlay | IMAGE | Render with feature masks tinted (lips=R, brows=G, eyes=B, nose=Y). |
| status | STRING | — |
| head_cutout | IMAGE | The input image with the head silhouette applied, on cutout_bg (transparent RGBA / black / white) — head only, background+neck removed. |
| head_cutout_clean | IMAGE | Same as head_cutout but with the drop_* features (eyes/brows/lips/nose) punched out (holes empty / bg-filled). Wire into BD MP Face Infill to fill them, or use as the skin plate. |