π FRED Crop Face
Crop a face out of an image, with margins you control
- image
- face_image
- preview
- bbox
- face_pixel_ratio
- face_w_margin_pixel_ratio
- help
Face detail passes are one of the most reliable quality upgrades in ComfyUI - detect a face region, crop it out, run a fresh sampling pass at a decent resolution, paste it back. The detect-and-crop step is exactly what FRED_CropFace does, using RetinaFace under the hood. It's not a detailer itself; it's the front half of one, plus a useful standalone face extractor.
How it works
It loads RetinaFace via the facexlib library, which the pack bundles as a fallback or pulls from pip. On first run it downloads the detection weights into models/facexlib, so expect a one-time network fetch. It scans your image, finds faces, and crops the one you ask for.
The inputs that matter:
confidence(default 0.8) - how sure the detector has to be before a face counts. If it's missing real faces, drop it toward 0.5; if it's finding faces in your fabric texture, raise it.face_id- which face to crop when there are several. 0 is the first (largest/most confident), and-1returns all faces as a batch. That's your "extract every portrait from this group photo" mode.left/right/top/bottom_margin_factor- how much extra around the bounding box to include, per side. Defaults of 0.6/0.6/0.4/1.0 mean a bit more room at the bottom, which keeps chins and necks from getting chopped - the classic auto-crop failure. Bump these up if your detailer is cropping off foreheads.min_face_ratio(default 2) - skip faces smaller than this percentage of the image. Stops the node from "finding" a 40-pixel face that's useless for a detail pass.max_size(default 1536) - cap on the crop's long edge, so a huge 4K frame doesn't hand you a 3000px crop that's wasteful to sample.bbox_mode- output format for the bounding box (x0y0x1y1orxywh), matched to whatever you're feeding downstream.
The outputs
face_image- the cropped, margin-expanded face. For a detailer workflow you'd img2img this at moderate denoise, then paste it back.bbox- a BBOX output in your chosen format, ready for nodes that consume Impact Pack-style BBOX data (like pasting a crop back into place).preview- the original image with every detection and its margin box drawn on. Check this once and you'll instantly trust (or distrust) your margin settings.face_pixel_ratioandface_w_margin_pixel_ratio- how big the face is as a fraction of the image, before and after margins. Useful as a sanity check and for automating "only detail if the face is small enough to matter" logic.
What it isn't
This is not a one-click face enhancer. There's no sampling, no inpainting - it detects and crops. The canonical loop is: CropFace β img2img the face at higher resolution β paste the result back with something like FRED_ImageUncropFromBBox or a mask composite. That split is actually the good design; it keeps the heavy lifting in nodes you can swap.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/Poukpalaova/ComfyUI-FRED-Nodes_v2.git
Restart (or ComfyUI Manager β "ComfyUI FRED Nodes v2"). The pack's requirements include facexlib, so pip installs it; the RetinaFace weights download on first run to models/facexlib.
Gotchas
If crops keep cutting the top of the head, raise top_margin_factor - it defaults low (0.4) because foreheads are wasted pixels in a detail pass, but your model may disagree. If the node throws on a weird image and facexlib is behaving, check the weights folder actually populated; that first-run download is the usual suspect.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| confidence | FLOAT | 0.800β1 | β |
| left_margin_factor | FLOAT | 0.60 | β |
| right_margin_factor | FLOAT | 0.60 | β |
| top_margin_factor | FLOAT | 0.40 | β |
| bottom_margin_factor | FLOAT | 1.00 | β |
| face_id | INT | 0 | β |
| min_face_ratio | FLOAT | 2.000β100 | β |
| max_size | INT | 1536 | β |
| bbox_mode | COMBO | x0y0x1y1 | 2 options: x0y0x1y1, xywh |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| face_image | IMAGE | β |
| preview | IMAGE | β |
| bbox | BBOX | β |
| face_pixel_ratio | FLOAT | β |
| face_w_margin_pixel_ratio | FLOAT | β |
| help | STRING | β |