Nodes/Region Edit Toolkit/图像分区 · 选择人脸
ComfyUI Node

图像分区 · 选择人脸

Pick the right face out of a crowd — and refuse the ones too small to edit

By Liu-Bot24·Created 2 months ago·Updated about a month ago· 1
图像分区 · 选择人脸
  • image
  • face_landmarks
  • selection
  • automatic_face_mask
  • selection_preview
  • report_json
face_index0
minimum_face_short_side512

The Region Edit Toolkit's face pipeline starts here. Before any of the clever eye-restore, difference-mask, or semantic-crop nodes can do anything, you need one thing decided: which face, and is it even worth editing? RegionEditFaceSelect takes your FACE_LANDMARKS output (from MediaPipe-style detection), ranks the detected faces, and hands you a FACE_LOCAL_SELECTION object that the rest of the face nodes trust - plus the automatic face mask, a preview, and a hard quality gate.

The gate is the part that separates this from a dumb "first face" picker. minimum_face_short_side defaults to 512px - if the face you selected is smaller than that, the node throws. That's not pedantry; it's the single most common face-edit failure, and the KB on detailing hammers it: a face occupying 80px of a 1024px frame has no latent budget, and no amount of prompt magic fixes what the model physically can't resolve. This node refuses to let you waste a run on it.

How it works

It sorts the detected faces by a ranking policy - valid bbox and complete landmarks first, then detection confidence, then landmark geometry, then area - and exposes them as a numbered list (0, 1, 2…) both in the selection_preview image (green box = selected, yellow = the rest) and in report_json. You pick with face_index. The automatic_face_mask output is a polygon mask built from the face-oval landmark ring, which you can feed straight into the mask-compose steps.

The FACE_LOCAL_SELECTION output is the workhorse: it bundles the face bbox, the chosen index, the detected count, and the image dimensions, and every downstream face node in the pack validates against it - RegionEditFaceContextCrop, for instance, refuses to crop if the selection's recorded dimensions don't match the image it's given. That's the pack's whole "strict coordinates" religion in miniature.

Inputs that matter

  • face_landmarks - required. Whatever detection chain you use (SAM3 has face modes, MediaPipe, Impact Pack detectors), it must emit FACE_LANDMARKS.
  • face_index - the ranked pick. Start at 0 (the best candidate); bump it only after looking at the preview.
  • minimum_face_short_side - the gate. 512 for portrait work; if you're editing a distant face you genuinely want, you may lower it, but then you're on the hook for the mushy result.

Outputs: selection, automatic_face_mask, selection_preview, report_json (with the full candidate ranking - great for debugging why it picked what it picked).

Install

ComfyUI Manager → search "Region Edit Toolkit" (package ID native-region-tile-planner-merge) → install → restart. Or git clone https://github.com/Liu-Bot24/ComfyUI-Region-Edit-Toolkit.git into ComfyUI/custom_nodes, pip install -r requirements.txt into ComfyUI's Python environment, restart. Python 3.10+, deps numpy/Pillow/scipy/argostranslate. Face detection itself is a separate concern - this node consumes its output.

Gotchas

The 512px default gate will absolutely stop you on group shots where the person you want is mid-frame. That's working as intended - check the preview first, and if the face is genuinely small, crop the region wider upstream so the face itself is bigger in the frame. Also note the ranking is by detection quality, not by left-to-right order or size; face 0 is "best landmarks + confidence," not "biggest." Read the preview, don't guess.

CategoryRegion Edit Toolkit/Selection

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
face_landmarksFACE_LANDMARKS
face_indexINT00–15
minimum_face_short_sideINT51264–4096

Outputs (4)

NameTypeDescription
selectionFACE_LOCAL_SELECTION
automatic_face_maskMASK
selection_previewIMAGE
report_jsonSTRING