Nodes/ComfyUI_LayerStyle_Advance/LayerMask: PersonMaskUltra(Advance)
ComfyUI Node Runs on cloud

LayerMask: PersonMaskUltra(Advance)

PersonMaskUltra — ComfyUI Node Guide

By chflame163·Created 2 years ago·Updated 4 months ago· 696
LayerMask: PersonMaskUltra(Advance)
  • images
  • image
  • mask
facetrue
hairfalse
bodyfalse
clothesfalse
accessoriesfalse
backgroundfalse
confidence0.40
detail_range16
black_point0.01
white_point0.99
process_detailtrue

Most background-removal nodes give you one thing: subject versus not-subject. PersonMaskUltra is more specific - it segments a person into parts (face, hair, body skin, clothes, accessories) and lets you pick which parts you actually want masked, as separate on/off switches rather than one blob. That's the whole appeal: if you only want a hair mask to feed into a hair-color edit, or just the clothing region for an outfit swap, you don't have to segment everything and then hand-carve out the piece you need.

The model behind it is a-person-mask-generator, credited in the README, with the edge-refinement code borrowed from ComfyUI-Image-Filters. It's built specifically for people, not general objects - don't expect it to do anything useful on a product shot or a landscape.

The inputs that decide what gets masked: six boolean switches - face, hair, body, clothes, accessories, background - each defaulting off except face, which is on by default. Toggle whichever combination you want; any of the "on" categories get merged into the output mask. confidence (default 0.4, range 0.05–0.95) is the detection threshold - lower it if the node is missing parts it should be catching, raise it if it's grabbing too much.

The rest of the inputs are the edge-refinement pass this pack uses across most of its "Ultra" segmentation nodes: detail_range controls how much area around the detected edge gets fine-tuned, and black_point/white_point set the sampling thresholds that decide how aggressively edge pixels get pulled toward fully opaque or fully transparent. process_detail (default true) is the master switch for that whole refinement pass - set it false if you want a faster, rougher mask and don't need pixel-perfect edges.

Outputs are image (the source image, generally used as a pass-through for chaining) and mask - the combined mask covering whichever categories you enabled, ready to feed into compositing, inpainting, or a background-removal chain.

Installing it: the usual path - ComfyUI Manager, search "ComfyUI Layer Style Advance," or git clone https://github.com/chflame163/ComfyUI_LayerStyle_Advance into custom_nodes, then install_requirements.bat (or Aki variant) / pip install -r requirements.txt, then repair_dependency.bat, restart. Then grab the model files from the BaiduNetdisk link in the README (or the umbrella HuggingFace repo, chflame163/ComfyUI_LayerStyle, which hosts most of this pack's models) and copy them into ComfyUI/models/mediapipe.

Where this trips people up: if the mask is missing regions you'd expect it to catch (say, hair on a subject with unusual lighting), the fix is almost always confidence before anything else - this model was trained on fairly typical portrait conditions, and it can undershoot on tricky lighting or unusual poses. If detection looks broadly right but edges are ragged, that's detail_range/black_point/white_point territory, not a detection problem - don't waste time tweaking confidence for an edge-quality issue. And a reminder if you're coming from the pack's PersonMaskUltraV2 documentation: this is the original PersonMaskUltra, which doesn't expose the VITMatte/PyMatting/GuidedFilter method choice that V2 added - you get one fixed refinement method here, tuned through detail_range rather than a method selector.

Category😺dzNodes/LayerMask

Inputs (12)

NameTypeDefaultDescription
imagesIMAGE
faceBOOLEANtrue
hairBOOLEANfalse
bodyBOOLEANfalse
clothesBOOLEANfalse
accessoriesBOOLEANfalse
backgroundBOOLEANfalse
confidenceFLOAT0.400.05–0.95
detail_rangeINT161–256
black_pointFLOAT0.010.01–0.98
white_pointFLOAT0.990.02–0.99
process_detailBOOLEANtrue

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK