Nodes/ComfyUI FRED Nodes v2/πŸ‘‘ FRED Crop Face
ComfyUI Node

πŸ‘‘ FRED Crop Face

Crop a face out of an image, with margins you control

By PoukpalaovaΒ·Created about a year agoΒ·Updated 7 months agoΒ· 3
πŸ‘‘ FRED Crop Face
  • image
  • face_image
  • preview
  • bbox
  • face_pixel_ratio
  • face_w_margin_pixel_ratio
  • help
β—„confidence0.80β–Ί
β—„left_margin_factor0.60β–Ί
β—„right_margin_factor0.60β–Ί
β—„top_margin_factor0.40β–Ί
β—„bottom_margin_factor1.00β–Ί
β—„face_id0β–Ί
β—„min_face_ratio2.00β–Ί
β—„max_size1536β–Ί
β—„bbox_modex0y0x1y1β–Ί

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 -1 returns 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 (x0y0x1y1 or xywh), 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_ratio and face_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.

CategoryπŸ‘‘FRED/image/postprocessing

Inputs (10)

NameTypeDefaultDescription
imageIMAGEβ€”
confidenceFLOAT0.800–1β€”
left_margin_factorFLOAT0.60β€”
right_margin_factorFLOAT0.60β€”
top_margin_factorFLOAT0.40β€”
bottom_margin_factorFLOAT1.00β€”
face_idINT0β€”
min_face_ratioFLOAT2.000–100β€”
max_sizeINT1536β€”
bbox_modeCOMBOx0y0x1y12 options: x0y0x1y1, xywh

Outputs (6)

NameTypeDescription
face_imageIMAGEβ€”
previewIMAGEβ€”
bboxBBOXβ€”
face_pixel_ratioFLOATβ€”
face_w_margin_pixel_ratioFLOATβ€”
helpSTRINGβ€”