π Image Face Crop
Auto-crop faces before the detailer pass (and know when one failed)
- image
- IMAGE
- MASK
- FACE_DETECTED
If you've ever built a "detect face β crop β img2img β paste back" pipeline by hand, you know the boring 80% is not the model - it's the bookkeeping around it. This node is that bookkeeping: it finds every face in an image, crops each one to a fixed size you set, and hands you the crop plus a mask plus a "did we actually find anything" boolean. It's the face-detection half of a poor-man's ADetailer, and it's genuinely handy in batch work.
It's part of π
Ace Nodes (hay86/ComfyUI_AceNodes), a grab-bag of ~40 small utilities from one author. The pack has basically no community footprint worth citing - it's the kind of repo you clone for one node and keep for the other fifteen. Nothing here needs a key or a cloud account.
How it works
You pick a detector: retinaface (from the retina-face package, runs anywhere) or insightface (the FaceAnalysis app, tried on CUDA first, CPU as fallback). Both are face-detection models, not identity models - they find bounding boxes, they don't care who's in them. The node sorts detections by area, biggest first, so face #1 in the batch is the largest face in the image.
Each detected box is then expanded to hit your target aspect ratio and resized to crop_width Γ crop_height (LANCZOS). You get one cropped IMAGE per face, stacked into a batch; the MASK is a full-image mask marking where each crop came from (handy for pasting results back); and FACE_DETECTED tells you whether the detector found anything at all.
The inputs that matter
There are only three you set:
model-retinafaceif you want zero fuss and CPU-friendliness,insightfaceif you want better detections on tricky angles and don't mind the extra dependency.crop_width/crop_height- the output size, default 512Γ512. If you're feeding a face detailer, match this to what that model expects.
Outputs: IMAGE (the crops), MASK (positions), and FACE_DETECTED (boolean).
Installing
ComfyUI Manager β search ComfyUI_AceNodes β Install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/hay86/ComfyUI_AceNodes
Then restart ComfyUI. Heads up: the pack's requirements.txt is a kitchen sink - rembg, transformers, soundfile, insightface, retina-face, openai, boto3, oss2 and friends all get pulled whether you use them or not. On Windows, insightface can be the pain point (it wants a compiled onnxruntime and matching MSVC bits); if the pack installs but the insightface option crashes, run the retinaface path instead. Insightface's pretrained models are also not commercially licensed, so if this feeds a product, stick with retinaface.
Where people get burned
First run with insightface downloads its models into ComfyUI/models/insightface - allow for that. And the failure mode that catches everyone: if no face is found, you get a black placeholder crop and FACE_DETECTED = false. Don't wire the crop straight into a detailer and hope - wire FACE_DETECTED into a switch (this pack even ships ACE_AnyInputSwitchBool for exactly that) so the no-face case goes around the detailer instead of through it. Black crops through an img2img pass is how you "fix" a face into a void.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| model | COMBO | 2 options: retinaface, insightface | |
| crop_width | INT | 5121β16384 | β |
| crop_height | INT | 5121β16384 | β |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | β |
| MASK | MASK | β |
| FACE_DETECTED | BOOLEAN | β |