Jalen-BrunsonandClaude Fable 5 4e67f82076 Add Sapiens2SegContours, MouthStripCrop, PersonBboxesFromMasks nodes
Sapiens2SegContours renders semantic class-boundary line art from a
Sapiens2 seg class-id mask (e.g. lips/tongue/teeth outlines) —
flicker-free alternative to per-frame Canny for mouth control guides.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-10 18:01:18 +00:00

Lip Mask from Pose Keypoints

A ComfyUI custom node that generates precise mouth and lip masks from DWPose POSE_KEYPOINT output.

Installation

Copy this folder into your ComfyUI/custom_nodes/ directory:

ComfyUI/custom_nodes/lip_mask_from_pose/
├── __init__.py
├── lip_mask_node.py
└── README.md

Restart ComfyUI. The node appears under mask/pose → Lip Mask from Pose Keypoints.

Requirements

No additional dependencies — uses only numpy, cv2, and torch (already in ComfyUI).

Inputs

Input Type Description
pose_keypoint POSE_KEYPOINT Connect from DWPreprocessor's POSE_KEYPOINT output
mask_mode Dropdown Which mouth region to mask (see below)
blur_radius INT (0-100) Gaussian feathering radius. 0 = hard edge
grow_pixels INT (0-200) Dilate mask outward by N pixels
person_index INT (0-99) Which detected person (0 = first)
confidence_threshold FLOAT (0-1) Skip frames with low keypoint confidence

Mask Modes

  • inner_mouth — Only the mouth cavity (teeth, tongue, dark interior). Leaves lips completely untouched during inpainting. Best for replacing teeth/smile without changing lip shape.

  • outer_lips — Full lip region including lip skin. Use when you want to regenerate both lips and mouth.

  • lips_only — Just the lip flesh (outer contour minus inner mouth). Regenerates lip shape/color while preserving the mouth interior.

  • outer_expanded — Same as outer_lips but designed to be used with grow_pixels for a wider mask with soft falloff.

Typical Workflow

[Load Video] → [DWPreprocessor (detect_face=enable)]
                        ↓
                  POSE_KEYPOINT
                        ↓
              [Lip Mask from Pose Keypoints]
                        ↓
                      MASK → [WAN 2.2 VACE Inpaint / KSampler]

Face Landmark Reference (iBUG 300-W 68-point)

Outer lip contour:  indices 48-59  (12 points)
Inner lip contour:  indices 60-67  (8 points)

        48                         54
         49                       53
          50    51    52    53   52
    
    60                                 64
       61                           63
          62          63          62
             (inner mouth opening)
    
        67                         65
           66                   66

Tips

  • For teeth-only inpainting: use inner_mouth + grow_pixels=3 + blur_radius=5
  • For lip reshaping: use outer_lips + blur_radius=8 for soft blend
  • Combine with SAM-2 for even more precise boundaries: use this mask as a coarse region, then refine with SAM point prompts placed at the mask centroid
S
Description
No description provided
Readme
62 KiB
Languages
Python 100%