ComfyUI Node

Detect Faces (dlib)

ComfyUI Node Guide

By cdb-boop·Created 2 years ago·Updated 2 years ago· 510
Detect Faces (dlib)
  • dlib_model
  • image
  • face_count
  • cropped_faces
  • face_landmarks
face_size512

This is where face repair actually starts: find every face in the photo, crop each one out, and record exactly where and how it was positioned so later nodes can put an improved version back in the same spot. It's the detection half of the pack's Stage 2–4 face pipeline, feeding both Enhance Faces and, eventually, Blend Faces.

It runs on dlib, and it's worth knowing what that means because it's a genuinely different approach from most face tooling you'll run into elsewhere in ComfyUI. dlib's classic HOG+SVM detector finds face bounding boxes, then the 68-point landmark predictor (loaded via Load Face Detector Model) marks the eyes, brows, nose, mouth, and jawline for each one. That's it - no deep embeddings, no biometric vector, nothing that tries to recognize who the face belongs to. Compare that to InsightFace-based tools like IP-Adapter FaceID, InstantID, or ReActor, which generate an ArcFace embedding for identity matching and, as a consequence, inherit InsightFace's non-commercial licensing restriction on its pretrained weights. dlib's landmark model carries none of that baggage - it's older, purely geometric, and doesn't care about identity at all, just location and orientation.

Required inputs: dlib_model (from Load Face Detector Model), image, and face_size (256 or 512, default 512) - the resolution each cropped face gets output at. Outputs: face_count (FACE_COUNT), cropped_faces (IMAGE), and face_landmarks (FACE_LANDMARKS), all three of which travel together into Enhance Faces and then Blend Faces.

The setting that actually matters for a beginner is face_size, and it needs to match whatever model_face_size you set on Load Face Enhancer Model downstream - 256 or 512, pick one and keep it consistent through the chain, since a mismatch there is a more common source of bad output than anything about detection itself going wrong.

Documented behavior worth knowing up front: per the README's own Hints section, this node returns the original image unmodified if no face is found - quietly, not as an error. If your output looks completely untouched after running the pipeline, check whether a face was actually detected before assuming a downstream node is broken; there's a real chance nothing was ever found in the first place.

Installing this node's dependencies is the roughest part of the whole pack. Beyond the standard install - ComfyUI Manager search, or git clone into custom_nodes/ and restart, then pip install -r requirements.txt against ComfyUI's own Python - you also need the shape_predictor_68_face_landmarks.dat file from dlib.net, extracted into models/facedetection/ (a custom folder this pack creates, not one of ComfyUI's default model directories). The dlib package itself is the real friction point: it's a compiled C++ extension, and I checked, and it's a genuinely recurring problem in the wild - multiple r/comfyui and r/StableDiffusion threads show people stuck for days on install failures. The fix that actually works is almost always version-matching: grab a prebuilt dlib wheel for your exact Python version (ComfyUI portable's bundled Python is often a different minor version than your system Python, so a wheel that installs fine system-wide can fail inside ComfyUI), or install CMake and let it compile from source if no matching wheel exists.

If nothing gets detected on a photo that clearly has faces, it's worth trying a less degraded or better-contrast source image first - dlib's detector, being older and simpler than modern deep-learning detectors, is noticeably less forgiving of heavy noise, low contrast, or very small faces than what you might be used to from newer tools.

Categorybringing old photos back to life/image

Inputs (3)

NameTypeDefaultDescription
dlib_modelDLIB_MODEL
imageIMAGE
face_sizeCOMBO5122 options: 256, 512

Outputs (3)

NameTypeDescription
face_countFACE_COUNT
cropped_facesIMAGE
face_landmarksFACE_LANDMARKS