LC Person Mask π§
Face, hair, clothes, skin β one person, six checkboxes
- image
- cutout
- mask
- raw_mask
Most person masking in ComfyUI goes through a YOLO face detector, and for faces that's the right call - face_yolov8 finds faces faster and more reliably than anything open-vocabulary. But a face detector gives you a face. It doesn't give you hair, or the skin on someone's arms, or the hat they're wearing. And the YOLO route drags in Ultralytics, which is AGPL-3.0 and has a supply-chain incident behind it - a poisoned release in December 2024 that shipped a cryptominer to ComfyUI users.
This node is the other route. A person-parsing model gives you the parts, and you tick the ones you want.
How it works
Two engines, and the choice changes your results more than any slider on the node.
segformer (the default) runs mattmdjaga/segformer_b2_clothes at higher resolution. Its part definitions are the quirk to know about: body is arms and legs only. Bare torso and neck get read as clothes, because the model was trained on a clothes-parsing dataset where skin on the trunk wasn't in its vocabulary. That's not a bug you can tune away - it's the taxonomy.
mediapipe runs Google's selfie multiclass model, the same one LayerStyle's PersonMaskUltra uses. Lower resolution, but its body class includes torso and neck skin. It's also Apache-2.0, which is the license-clean answer to "I want to avoid Ultralytics on something I intend to sell." The catch: the mediapipe Python package is not installed by this pack. If you pick that engine without it, the node tells you in the console what to run - python -m pip install mediapipe - or you switch back to segformer.
The inputs that matter
Six booleans: face (on by default), hair, body, clothes, accessories (hats, glasses, shoes, bags, and whatever else the model files as an accessory), and background. Ticked parts get combined into a single mask. That's the design decision to internalize: you don't get one output per part, you get the union. Want the face and the hair as separate masks for separate treatments? Two nodes, two different tick patterns.
confidence (0.4 default, 0.05β0.95) is the model's must-be-sure threshold. Lower grows the selection, higher shrinks it, and 0.4 is a reasonable middle. If you're getting ragged stray regions, raise it; if edges are getting eaten, lower it.
refine then runs the trimmed-mask machinery this pack uses everywhere: none, guided_filter (fast, no model, snaps the edge to image features), or vitmatte (the default, a real matting model - Apache-2.0 weights pulled into models/vitmatte on first run, and the one that keeps hair). edge_erode / edge_dilate (10/10) define how wide the uncertain band is; shrink both toward 3 for a tight edge, and remember these are real pixels, so 10 means something different at 4K than at 1K. black_point / white_point crush the extremes to clean up hesitation, and max_megapixels (2) caps what vitmatte actually runs on.
Outputs: cutout (RGBA, mask as alpha), mask (the refined mask), and raw_mask (before refinement). Raw is the one to wire when you're debugging a bad edge - if raw is fine and mask is wrong, it's your refine settings, not the model.
What people do with it
Skin work is the classic: tick face and body, and you have a mask for a face-and-skin detailing pass without rebuilding it every render. Tick clothes for a garment swap. Tick hair plus vitmatte refine and you have the mask LC Mask Refine's detail_region input was built for. And for inpainting any of it - this is the mask-painting half of a masked pass, so all the usual inpainting rules apply: generous overlap, feather via the node or downstream, and don't expect the re-render to keep the surrounding pixels byte-identical.
There's no preview on this node - it isn't one of the pack's PreviewImage subclasses. Chain LC Mask Refine after it, or preview the mask output directly, if you want eyes on the result.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/lonecatone23/ComfyUI_LC_MaskMaker_nodes
# restart ComfyUI
Manager β search LC MaskMaker. Both engines' models come down on demand: the segformer weights (saved to models/segformer_b2_clothes) and MediaPipe's selfie_multiclass_256x256.tflite (to models/mediapipe). Note the license label on the segformer entry - its Hugging Face card says other, and it's built on NVIDIA's SegFormer, so the author flags it as not cleared for commercial use until you've checked. That's a real constraint if you're shipping output.
Gotchas
- Hair is a fringe again. You picked vitmatte for refine but left the band narrow. Widen
edge_dilate, or hand the hair mask to LC Mask Refine'sdetail_region. - Bare skin on the torso reads as clothes. segformer's taxonomy. Switch to mediapipe (and install the package) if the torso matters.
ImportError: mediapipe.python -m pip install mediapipein the environment ComfyUI runs in - or use segformer, which needs no extra package.- A group of people produces one merged blob. The mask is the union of everything the model parsed as a person. There's no per-person split here.
- You only got one mask but wanted three. Build three nodes and union or subtract them yourself; this node deliberately combines.
Inputs (18)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Image with a person in it. | |
| engine | COMBO | segformer | segformer: higher resolution. Body = arms and legs only (bare torso and neck read as clothes). mediapipe: body includes torso and neck skin. Needs the mediapipe package. |
| segformer_model | COMBO | Used by the segformer engine. Entries marked 'Download' are fetched the first time you run. | |
| face | BOOLEAN | true | β |
| hair | BOOLEAN | false | β |
| body | BOOLEAN | false | Skin below the face. See engine for what counts. |
| clothes | BOOLEAN | false | β |
| accessories | BOOLEAN | false | Hats, glasses, shoes, bags (and whatever else the model calls an accessory). |
| background | BOOLEAN | false | β |
| confidence | FLOAT | 0.400.05β0.95 | How sure the model must be. Lower grows the selection, higher shrinks it. |
| refine | COMBO | vitmatte | Edge refinement of the raw mask. vitmatte is best for hair, guided_filter is fast, none keeps the raw mask. |
| vitmatte_model | COMBO | Only used when refine is vitmatte. | |
| edge_erode | FLOAT | 10.00β1024 | Trimap: how far the sure-foreground is pulled in from the mask edge (pixels). |
| edge_dilate | FLOAT | 10.00β1024 | Trimap: how far the unknown band reaches out past the mask edge (pixels). |
| black_point | FLOAT | 0.0100β0.999 | Mask values at or below this become 0. |
| white_point | FLOAT | 0.9900.001β1 | Mask values at or above this become 1. |
| max_megapixels | FLOAT | 2.000.25β16 | vitmatte only. Larger images are matted at this size, then scaled back. |
| remove_features | BOOLEAN | false | Cut the eyes, eyebrows, lips and teeth out of the face, using SAM 3 (the model LC Segment Anything and LC Smart Detailer use). With engine mediapipe and face + body on, this is a skin-only mask for LC Skin Beauty, LC Skin Upscale or LC Sharpen Pro. Only runs when face is on. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| cutout | IMAGE | β |
| mask | MASK | β |
| raw_mask | MASK | β |