Nodes/ComfyUI-KGnodes/Face(s) Detector & Cropper
ComfyUI Node

Face(s) Detector & Cropper

Prepping clean face crops for FaceID, PuLID, and ReActor

By shahkoorosh·Created 2 years ago·Updated about a year ago· 8
Face(s) Detector & Cropper
  • Image
  • IMAGE
â—„Output Size1024x1024â–º
â—„Sharpening0.00â–º
â—„Zoom0.4â–º
â—„Face Detection Accuracy0.50â–º
â—„Face Concatfalseâ–º
â—„DirectionRightâ–º

A lot of identity-preservation workflows - IP-Adapter FaceID, PuLID, ReActor face swaps - quietly assume you're feeding them a clean, tightly-framed face, not a full-body photo with a face somewhere in it. Get the crop wrong and you're feeding the model background noise it has to fight through, or a crop so tight it clips the jaw and hairline the identity encoder actually relies on. This node exists to do that prep step properly: find the face (or faces), crop it to a clean square, and hand you something worth plugging into whatever face tool you're actually using.

How it works

You feed it an image, it detects any faces present, and it crops each one out to a square canvas at your chosen resolution. It's not a one-size-fits-all crop, either - there's real control here over how much surrounding context each crop keeps and how confidently the node has to believe something is a face before it bothers cropping it. If your image has multiple faces, you can either get them back as a batch or have the node stitch them together into a single collage image, which is genuinely handy for building a multi-shot reference set (the FaceID Portrait variant, for instance, wants several reference images of the same person rather than just one).

The inputs and outputs that matter

  • Image - required, the source image to scan for faces.
  • Output Size - a square resolution for each crop: 1024×1024, 768×768, 512×512, or 256×256. Per the tooltip, this is "the final square resolution of the cropped face image."
  • Zoom (0–1, default 0.4) - how much padding to keep around the detected face. The tooltip is direct about it: lower values crop tight to the face, higher values pull in more surrounding area. Too tight and you lose hairline/jaw context that identity models lean on; too loose and you're diluting the signal with shoulders and background. 0.4 is a reasonable middle ground to start from.
  • Face Detection Accuracy (0–1, default 0.5) - the confidence threshold. Lower catches more faces but risks false positives; higher is stricter and may miss partially-obscured or angled faces.
  • Sharpening (0–1, default 0) - applies bilateral filtering plus unsharp masking to the crop. Off by default; a small bump can help if your source face is a little soft.
  • Face Concat (boolean, default off) and Direction (Right/Down/Left/Up) - when Face Concat is on, multiple detected faces get stitched into one image in the direction you pick, instead of coming back as a batch.

Single output: IMAGE - either your batch of cropped faces, or the concatenated collage.

How to install it

Search KGnodes in ComfyUI Manager, or by hand:

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

Restart, then find it under Add Node → 🎨KG. Face detection is heavier than the pack's other pure-image-math nodes, so the pip install -r requirements.txt step actually matters here - don't skip it and assume this one will "just work" off ComfyUI's base dependencies the way, say, the overlay node does.

Common issues & troubleshooting

Faces aren't being detected. Start by lowering Face Detection Accuracy. That's exactly what the tooltip says it's for - a stricter threshold means faces at odd angles, partially obscured, or small in frame get skipped rather than false-positived.

Crop looks too tight - missing hair, chin, or ears. Raise Zoom. This is the one setting that matters most for downstream identity work: IPAdapter FaceID and PuLID are working off the geometry and texture of the whole face region, and a crop that clips it starves them of signal even if the detection itself was accurate.

Feeding this into IP-Adapter FaceID or PuLID and identity still isn't landing. Remember this node only detects and crops - it isn't producing the identity embedding itself. If the crop looks clean but results are still off, the problem is more likely downstream in your FaceID/PuLID setup (weight, LoRA strength) than in this node. This node's job ends at "here's a clean face image," not "here's an identity vector."

Multiple faces, unexpected batch behavior downstream. If your source photo has several people and you didn't turn on Face Concat, you'll get a batch of crops back - plan your downstream nodes for that, or turn concatenation on and pick a Direction if you specifically wanted one combined reference image instead.

Category🎨KG

Inputs (7)

NameTypeDefaultDescription
ImageIMAGE—
Output SizeCOMBO1024x1024Final square resolution of the cropped face image (e.g., 1024x1024). Determines the output size after face detection and cropping.
SharpeningFLOAT0.000–1Controls the intensity of image sharpening applied to the cropped face. 0.0 means no sharpening, 1.0 is maximum sharpening using bilateral filter and unsharp masking.
ZoomFLOAT0.40–1Adjusts the padding around the detected face. Lower values (e.g., 0.0) crop tightly to the face, higher values (e.g., 1.0) include more surrounding area.
Face Detection AccuracyFLOAT0.500–1Sets the confidence threshold for face detection. Lower values (e.g., 0.0) detect more faces but may include false positives; higher values (e.g., 1.0) are stricter, detecting only high-confidence faces.
Face ConcatBOOLEANfalseIf True, concatenates all detected faces into a single image instead of returning a batch.
DirectionCOMBORightDirection to concatenate faces when Face Concat is True.

Outputs (1)

NameTypeDescription
IMAGEIMAGE—