LayerMask: PersonMaskUltra V2(Advance)
PersonMaskUltra V2 — pick which part of a person you want masked
- images
- image
- mask
Most background-removal nodes give you one thing: foreground versus everything else. PersonMaskUltra V2 is more specific - it's built on top of Google's MediaPipe person-segmentation model (via the a-person-mask-generator project, with the edge-refinement code borrowed from ComfyUI-Image-Filters) and it lets you toggle exactly which category of "person" you want in the mask: face, hair, body skin, clothes, accessories, or even the background by itself. That's the whole point of reaching for this over a generic BiRefNet or SAM cutout - you don't have to segment-then-filter, you just flip the switches for the parts you want.
The category toggles (face, hair, body, clothes, accessories, background) are all booleans and you can combine as many as you like - want just hair and clothes, leave face and body off. confidence controls the detection threshold; lower it and you get more generous, looser mask coverage, raise it and the model gets stricter about what counts. The rest of the inputs are the same edge-refinement stack used across most of this pack's masking nodes: detail_method picks how the mask boundary gets cleaned up (VITMatte for the best hair/edge quality, PyMatting or GuidedFilter as lighter options), detail_erode/detail_dilate shrink or grow the mask inward/outward from the edge, black_point/white_point are the sampling thresholds for that edge cleanup, and process_detail is your on/off switch for the whole refinement pass - turn it off if you just need a fast, rough mask and don't care about hair strands. max_megapixels caps how large an image VITMatte will process at full detail, which matters because that method gets expensive fast on big images. Outputs are image and mask, same pattern as the rest of the family.
This is the V2 revision specifically because V1 (PersonMaskUltra) didn't have the VITMatte option - V2 added it, along with device to control whether that refinement pass runs on CUDA or CPU. If you're masking a lot of portraits and hair quality matters, V2 with VITMatte is the meaningful upgrade over the original.
Install through ComfyUI Manager (search "ComfyUI Layer Style Advance") or git clone https://github.com/chflame163/ComfyUI_LayerStyle_Advance into custom_nodes/, restart, and run the requirements installer for your ComfyUI flavor. Model-wise this one's lighter than the SAM or BiRefNet nodes in the pack - you need the MediaPipe model files, which chflame163 has bundled on Baidu Netdisk, copied into ComfyUI/models/mediapipe. If you're using VITMatte as the detail method you'll also want the vitmatte model in ComfyUI/models/vitmatte; everything's also available in one place on the author's HuggingFace repo.
Common friction here is the same as the rest of the "Ultra" family: if VITMatte throws an import error about VitMatteImageProcessor not existing in transformers, your transformers version is too old - update it. If a cv2.ximgproc guidedFilter error shows up instead, that's a bad opencv-contrib-python install, usually caused by a different opencv package clobbering it; running repair_dependency.bat in the plugin folder handles both of these automatically rather than you chasing pip versions by hand. And if you're feeding in very large source images with VITMatte enabled and process crashes or hangs, that's memory pressure - either drop max_megapixels or switch detail_method to something lighter for that pass.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| face | BOOLEAN | true | — |
| hair | BOOLEAN | false | — |
| body | BOOLEAN | false | — |
| clothes | BOOLEAN | false | — |
| accessories | BOOLEAN | false | — |
| background | BOOLEAN | false | — |
| confidence | FLOAT | 0.400.05–0.95 | — |
| detail_method | COMBO | 5 options: VITMatte, VITMatte(local), vitmatte-base-composition-1k, PyMatting, GuidedFilter | |
| detail_erode | INT | 61–255 | — |
| detail_dilate | INT | 61–255 | — |
| black_point | FLOAT | 0.010.01–0.98 | — |
| white_point | FLOAT | 0.990.02–0.99 | — |
| process_detail | BOOLEAN | true | — |
| device | COMBO | 2 options: cuda, cpu | |
| max_megapixels | FLOAT | 2.01–999 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |