Nodes/SameFace/SameFace Face Mask
ComfyUI Node

SameFace Face Mask

One person's face or head mask, for Measure's before_mask or after_mask: the faces are counted in the order chosen, and the one at index is masked (Grounded SAM 2, as Measure does). A head mask takes the hair in, so its shape is measured too - for an edit that left the hair alone.

By fixed-42·Created 7 days ago·Updated 2 days ago· 8
SameFace Face Mask
  • image
  • mask
  • faces_found
◄regionface►
◄orderleft to right►
◄index0►
◄earstrue►
◄confidence0.50►
◄gap4►
◄ear_confidence0.25►
CategorySameFace

Inputs (8)

NameTypeDefaultDescription
imageIMAGEThe image, or a batch of them.
regionCOMBOfaceThe face (and its ears), or the whole head, hair and ears included. Measure the head only when the edit left the hair alone: hair the edit changed reads as drift. Hair also measures noisier than skin, and the noise floor in the report was measured on faces.
orderCOMBOleft to rightHow the faces are counted: left to right by the middle of each face, or surest first by the detector's confidence. Left to right stays put when two faces score nearly the same.
indexINT00–63Which face, counting from 0 in that order. Use the same person on the before and the after - if the edit moved people around, the index may differ.
earsBOOLEANtrueLook for the ears beside the face and join them to the mask, face or head. Without this a head has its ears only where its hair outline happens to cover them, which can differ between the before and the after.
confidenceFLOAT0.500.05–0.95The detector's score a face or head needs to be counted, 0 to 1. Real faces usually score 0.55 or more; a face in a picture on the wall can score 0.3 to 0.55. Raise it to drop a face you don't want counted, lower it for one that is missed. It changes the index of everyone after it, and the same face can score differently in the before and the after - check faces_found on both sides. A head's face and ears are found by where they sit, so this does not affect them.
gapINT40–25How wide a gap between the face and its ears, or the face and its hair, is bridged, in % of the face's diagonal. Widen it when a head mask stops at the hairline; a head whose hair is further off is an error, not a face alone. It also fills notches in the edge narrower than the gap.
ear_confidenceFLOAT0.250.05–0.95The detector's score an ear needs to be found. Ears score low, often 0.2 to 0.3, so lower this a little if an ear is missed. A false ear is mostly harmless: only one beside the face, and much smaller than it, is taken, and only if it joins the face across the gap.

Outputs (2)

NameTypeDescription
maskMASKThe chosen face's or head's mask, one per image.
faces_foundINTHow many faces (or heads) the detector saw at this confidence (first image).