Nodes/Facefusion_comfyui/FF: Face Detector
ComfyUI Node

FF: Face Detector

Detect and pick a face once, reuse it everywhere

By huygiatrng·Created 9 months ago·Updated 25 days ago· 89
FF: Face Detector
  • image
  • reference_image
  • face_data
face_detector_modelscrfd
face_selector_modeone
face_position0
sort_orderlarge-small
score_threshold0.30
reference_face_distance0.60

Most of the swap nodes in this pack do detection and swapping in one step. This one does only detection, and it's the front door for the pack's other tools - FaceSwapApplier, FaceMaskVisualizer, and FaceDataVisualizer all expect a FACE_DATA object as input, and this is the node that produces one. Point it at an image, tell it which face(s) you care about, and it hands back a package the rest of the pack can consume without re-running detection.

The reason to reach for this instead of letting AdvancedSwapFaceImage do detection internally: once you've detected and selected a face, you can reuse that exact selection across a preview node, a mask check, and an actual swap - without the risk of the detector picking a slightly different face each time you re-run a step.

How it works

Detection and selection are two separate jobs bundled into one node. Detection is which detector model finds faces in the frame at all (face_detector_model, score_threshold). Selection is which of the detected faces you actually want, and this pack gives you three ways to answer that: pick one by position (face_selector_mode: one, ordered by sort_order, indexed by face_position), take every face found (many), or match against a reference photo (reference, using reference_image and reference_face_distance to control how loose the match is).

Reference mode is worth understanding on its own - instead of relying on where a face sits in the frame, you hand it a clear photo of the person you want and it finds faces that resemble that identity. That's the fix for the classic multi-person problem where positional sorting flips between two similarly-sized faces from one frame to the next.

Inputs and outputs that matter

  • image (IMAGE) - what to detect faces in.
  • face_detector_model (default scrfd, 5 choices) - leave at default unless detection is unreliable.
  • face_selector_mode (default one) - one + sort_order (default large-small, so the biggest face wins ties) for simple cases; reference + reference_image + reference_face_distance (default 0.6 - lower is stricter, higher pulls in more matches) when position alone won't reliably pick the right person.
  • score_threshold (default 0.3) - the confidence floor for a detection to count at all.

Output is a single face_data (FACE_DATA) - wire it into FaceSwapApplier, FaceMaskVisualizer, or FaceDataVisualizer.

Installing it

ComfyUI Manager: search Facefusion_comfyui. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/huygiatrng/Facefusion_comfyui.git
cd Facefusion_comfyui
pip install -r requirements.txt

Full restart afterward - new nodes won't show up from a browser refresh alone. First use downloads whichever detector model you've selected into custom_nodes/Facefusion_comfyui/models/; the detector files are small (a few MB) compared to the swapper models, so this is a quick fetch.

Common issues

No faces detected. This is the most common complaint with any face detector, and the pack's own troubleshooting notes cover it directly: lower score_threshold toward 0.3–0.4 (or lower), check the image isn't too dark or the face too small in frame, and confirm the face isn't heavily obscured.

The wrong face gets picked in a crowd or a multi-person shot. sort_order is doing positional sorting, not identity matching, so large-small will happily pick a stranger who happens to be closer to the camera. Switch to face_selector_mode: reference and feed a clean photo of the actual person you want.

Install issues (missing nodes, ONNX errors). Confirm pip install -r requirements.txt completed inside ComfyUI's own Python environment (on portable Windows installs that's python_embeded's pip, not your system one), then do a full restart. A model that won't load with an ONNX runtime error is almost always a partial or locked download - delete it from custom_nodes/Facefusion_comfyui/models/ and let it re-download.

CategoryFaceFusion

Inputs (8)

NameTypeDefaultDescription
imageIMAGE
face_detector_modelCOMBOscrfd5 options: scrfd, retinaface, yolo_face, yunet, many
face_selector_modeCOMBOone3 options: one, many, reference
face_positionINT00–100
sort_orderCOMBOlarge-small8 options: large-small, small-large, left-right, right-left, top-bottom, bottom-top, +2
score_thresholdFLOAT0.300–1
reference_imageoptIMAGE
reference_face_distanceoptFLOAT0.600–1

Outputs (1)

NameTypeDescription
face_dataFACE_DATA