Nodes/ComfyUI-FaceChain/FC FaceDetectCrop
ComfyUI Node

FC FaceDetectCrop

The node that finds the face and cuts it out — FC FaceDetectCrop

By THtianhao·Created 3 years ago·Updated about a year ago· 147
FC FaceDetectCrop
  • source_image
  • IMAGE
  • MASK
  • BOX
  • KEY_POINT
face_index0
crop_ratio1.0
mode

FC FaceDetectCrop is where every FaceChain workflow starts. It finds faces in an image, crops one out for generation, and hands you the metadata - the box, the mask, the landmarks - that the rest of the pack needs to put the result back. If you're building a face-inpaint graph from scratch, this is the first node you'll place.

The engine is a ModelScope face-detection pipeline (damo/cv_ddsar_face-detection_iclr23-damofd), downloaded on first use from Alibaba's hub. That's worth flagging now because it means the very first run is slow and needs network access to modelscope.cn - and because it's not InsightFace. The pack imports insightface and installs it (with a bundled Windows cp311 wheel, no less), but the actual detection work is done by the ModelScope model. So the usual "insightface install pain" horror stories mostly don't apply here; the pain is just a big download instead.

The inputs that matter

  • source_image (IMAGE) - the photo to search. Required.
  • mode - normal crops tight around the detected face; square 512 width height pads the crop out into a 512×512 square centered on the face. This second mode is load-bearing: FC CropToOrigin (the paste-back node) only works with it. The README says so explicitly.
  • face_index (INT, default 0) - which face, when there are several. 0 is the first detected, not necessarily the biggest.
  • crop_ratio (FLOAT, default 1.0) - how much margin around the face. Only active in normal mode; 1.0 is exactly the face, higher values include more context (hair, shoulders).

That's the whole public surface - no other knobs on this node.

Outputs

Four of them: the cropped IMAGE, a MASK (the region that was cropped), the BOX (the face bounding box in original-image coordinates), and a KEY_POINT array (five facial landmarks). The box and mask are exactly what FC CropToOrigin consumes on the way back, so don't drop them on the floor.

Typical graph and gotchas

Load Image → FC FaceDetectCrop → (crop) → KSampler → FC CropToOrigin, with the box/mask wired straight across. In square 512 mode the crop is already sampler-ready at 512×512.

Two things trip people up. First, don't resize the crop between nodes - the paste-back geometry assumes nothing changed. Second, the face-index behavior: with multiple faces it picks by detection order, so if it crops the "wrong" person, bump face_index rather than re-cropping by hand.

Install

ComfyUI Manager (search "ComfyUI-FaceChain") or:

cd ComfyUI/custom_nodes
git clone https://github.com/THtianhao/ComfyUI-FaceChain

Restart, then wait through the pack's startup dependency install (onnxruntime-gpu, mmdet, mmcv via openmim, modelscope, insightface, transformers…) - first launch after install is slow, and it's normal. The node itself is one of the most used in the pack, and it's the one whose outputs everything else orbits around.

Categoryfacechain/model

Inputs (4)

NameTypeDefaultDescription
source_imageIMAGE
face_indexINT00–10
crop_ratioFLOAT1.00–10
modeCOMBO2 options: normal, square 512 width height

Outputs (4)

NameTypeDescription
IMAGEIMAGE
MASKMASK
BOXBOX
KEY_POINTKEY_POINT