Nodes/lip_mask_from_pose/Person BBoxes From Masks
ComfyUI Node

Person BBoxes From Masks

Paint a person, get a Sapiens2 pose crop

By Jalen-Brunson·Created 5 months ago·Updated 10 days ago· 1
Person BBoxes From Masks
  • mask_1
  • mask_2
  • bboxes
  • info
pad_percent15.0
threshold0.50

Multi-person shots are where face-and-lip work gets painful. You've got two people in frame, you want per-person pose for each, and a single whole-frame pose pass is a mess. That's what this node is for: it turns the masks you paint into per-person bounding boxes that a Sapiens2 pose node can crop to, so each person gets their own clean pose pass instead of one crowded one. It's a small node with a narrow job, but it's the bridge that makes the two-mask workflow work.

What it does

You hand it up to two masks - mask_1 and the optional mask_2 - the kind of thing you'd paint by hand in Impact Pack's PreviewBridge. It looks at frame 0 of each mask, finds every pixel above the threshold (default 0.5), and computes that mask's bounding box. Then pad_percent (default 15) grows the box on every side by that percentage of its own size, so the eventual pose crop gets a little margin around the person. The result is one BOUNDING_BOX per non-empty mask.

Two behaviors in the source are worth knowing because they make the graph robust instead of fragile:

  • Empty masks are skipped. Paint only one person and leave the other mask blank? You get one box, not a crash.
  • No masks at all yields an empty list - and per the author's docstring, that empty list makes Sapiens2Pose fall back to whole-image mode. So the same graph handles one person, two people, or a forgotten paint job without you rewiring anything.

The inputs and outputs

Only the two inputs you actually set matter: mask_1 / mask_2 (painted masks) and pad_percent if you want more or less margin. threshold is set-and-forget unless your masks are soft-edged.

Outputs are the useful pair: bboxes (the BOUNDING_BOX type - the same structure core ComfyUI's PrimitiveBoundingBox emits, so anything that eats that type can eat these) and info, a STRING that tells you exactly what it computed, e.g. mask_1: (312,120) 480x260; mask_2: empty (skipped). That info output is surprisingly handy for debugging; read it once and you'll know instantly whether a mask was empty or the pad ate your person.

Wire bboxes into Sapiens2Pose's bboxes input, and that node crops each box, runs its pose pass per person, and warps the results back.

Install & notes

It ships in Jalen-Brunson/lip_mask_from_pose. ComfyUI Manager (search "lip_mask_from_pose") or:

cd ComfyUI/custom_nodes
git clone https://github.com/Jalen-Brunson/lip_mask_from_pose

Restart, and you'll find it under mask/pose. No extra dependencies.

The one limitation to plan around: it reads frame 0 only, so it's a per-image tool, not a video-batch tool. And it takes exactly two masks - if you have three people, you'll want a second instance or a different batching approach. pad_percent clamps to frame bounds, so a huge margin won't throw an error, just a tighter-than-asked crop.

Categorymask/pose

Inputs (4)

NameTypeDefaultDescription
mask_1MASK
pad_percentFLOAT15.00–100Grow each box by this % of its size on every side, so the pose crop sees a margin around the person.
thresholdFLOAT0.500–1
mask_2optMASK

Outputs (2)

NameTypeDescription
bboxesBOUNDING_BOX
infoSTRING