BD MP SAM3 Face Segment
MediaPipe guides, SAM3 refines — pixel-accurate face masks that finally fix the stylized brow
- 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
BD MP SAM3 Face Segment is the heavy hitter of this pack's face pipeline, and the name tells you exactly how it works: MediaPipe localizes each facial feature, then SAM3 segments that feature with pixel accuracy. MediaPipe gives the location; SAM3 gives the fidelity. The thing it's built to fix - stated right in the node description - is the stylized-brow offset: on anime and stylized renders, the painted eyebrow sits somewhere other than where MediaPipe's landmarks are, and a landmark-only band misses it entirely. This node lets SAM3 grow the brow to what's actually painted.
How it works
For each feature (brows, eyes, lips, nose), the node builds a SAM3 prompt from the MediaPipe localization: a bounding box, positive landmark points, and sibling negatives. So SAM3 knows roughly where to look, what is the feature, and what isn't. Then the SAM3 mask is clipped to a "bleed guard" - a dilated version of the MediaPipe zone - so precision can't wander off into the forehead. The guards are per-feature for a reason: brows need a large guard (~40–45) to grow out to the painted shape, while lips need a small one (~12) or they overflow onto the face.
The best part for setup: no wiring needed. The node auto-loads and auto-downloads the official SAM3 checkpoint in-house (you can wire a comfy-core SAM3 MODEL to override, but you don't have to). It also auto-downloads MediaPipe's model. For a pack whose other segmentation nodes assume you already have SAM3 loaded, this one is refreshingly turnkey.
The inputs that matter
do_brows/do_eyes/do_lips/do_nose- toggle which features SAM3 refines. Brows is the one you bought this for; the others default on too.bleed_guard/brow_bleed_guard/eye_bleed_guard/lips_bleed_guard- the per-feature clipping. If brows read thin, raisebrow_bleed_guard; if lips bleed onto the face, lowerlips_bleed_guard. These are the tuning knobs you'll actually turn.refine_iterations- defaults to 1, and the tooltip's warning is worth quoting: extra passes tend to shrink masks on stylized/non-photo renders. Raise only if SAM3 over-segments.edge_refine- optional edge snapping after cleanup:off/guided(fast, edge-aware) /matting(PyMatting, CPU) /vitmatte(deep matting, best on soft/hair edges, auto-downloads the model). On the ROI crop, so it stays cheap.remove_background- computes a clean head silhouette in-house (text-grounded SAM3, head prompts minus neck/clothing negatives), optionally withneck_cutusing an auto-downloaded SegFormer face parser for a real neck-removal instead of a jawline cut. When on, everything clips to that silhouette and it's emitted as thesilhouetteoutput.skin_color_filter- refines the skin output by colour (adaptive LAB or fixed HSV): drops non-skin pixels like a dark mustache from the skin mask.drop_facial_hairpunches uncolored facial hair out of the clean cutout for repainting.drop_eyes/drop_brows/drop_lips/drop_nose- control which features get punched out of thehead_cutout_cleanimage output, leaving holes forBD MP Face Infillto fill. Nose defaults to kept (it's usually skin).
Outputs
You get the full mask family (face_oval, skin, eyes, brows, irises, lips, nose, ears, forehead, hair) matching BD MP Face Mask's layout, plus head_mask, masked_skin, the silhouette, a debug_overlay, and two image outputs - head_cutout (head on transparent/black/white) and head_cutout_clean (features punched out, ready for infill). The rgba output is a zone map: R=lips, G=brows, B=eyes, A=face_oval.
Installing
Standard pack install - ComfyUI Manager search "BrainDead" or clone + pip install -r requirements.txt. Needs mediapipe, and it will fetch the SAM3 checkpoint and VitMatte model on first use. All V3 API.
The catch, honestly: this is a lot of machinery and a few auto-downloads. For a photoreal face you might get 90% of the way with BD MP Face Mask alone. The moment you're on stylized art and the brow or lip masks come back wrong, this node is the upgrade - and it's the reason the pack's FaceWrap and Face Segmentation templates exist.
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. |