Nodes/comfyui-face-beauty/Face Crop Square
ComfyUI Node

Face Crop Square

The face-cropping half of a DIY FaceDetailer

By FeiJiu518·Created 4 months ago·Updated 4 months ago· 0
Face Crop Square
  • image
  • segs
  • preview
  • face_crops
  • crop_data
dilation32

"I want to fix every face, but not with FaceDetailer's fixed recipe"

Sooner or later you stare at a group photo with four decent faces and one that's mangled, and you realize the reason is pixel budget. A face occupying 80×80 pixels of a 1024×1024 frame gets 80×80 worth of model attention, and it comes out as mush. The standard fix is Impact Pack's FaceDetailer, which automates detect → crop → re-sample → paste-back inside a single node. It's great. It's also opinionated - the middle step is a fixed sampling pass whose settings you fight inside one crowded node.

Face Crop Square is the "detect" and "crop" half of that loop, split open so you can put literally anything in the middle. Want your faces run through a GFPGAN-style restorer, a ControlNet-guided img2img pass, a dedicated upscaler, or some bespoke photo node you like better? This node hands you each face as a clean square image, and its sibling Face Paste Back stitches the results back on. That's the whole pitch: it's FaceDetailer minus the locked-in middle.

How it works

It's a one-two punch with Impact Pack. You wire a detector chain - UltralyticsDetectorProvider feeding a BboxDetectorSEGS - and that segs output plus your original image go into this node. For each detected face it takes the bounding box, centers a square on it, and expands it by dilation pixels. If the square runs past the image edge it just crops what exists and pads to a perfect square with black.

Then the part that makes it actually useful: every crop is resized into the [1024, 2048] range. A tiny 80px face gets upscaled to 1024×1024 - exactly the native resolution an SDXL-class model wants for an img2img pass. A huge close-up gets capped at 2048 so you don't blow up your sampler's VRAM. Small face + big pixel budget is the entire reason this family of nodes exists, and it's built right in.

The outputs:

  • preview - your image with boxes drawn: red is the raw detection, green is the expanded square crop. One glance tells you whether dilation is doing what you think.
  • face_crops - a list of square face images, one per detected face, ready to feed whatever refinement you've built.
  • crop_data - a FACE_CROP_DATA blob that only Face Paste Back can read. Don't try to inspect it; it's a private contract between the two nodes so your face coordinates survive whatever you do in between.

The only input you'll meaningfully touch is dilation (default 32, range 0–512, step 4). More padding means more context around the face - hair, neck, background - and your refinement model sees all of it. If your step keeps chopping off foreheads, raise it. If the processed face clashes with the scene's lighting, you probably want less, so the model doesn't invent context to match.

Installing it

This pack is tiny - two nodes, no model downloads of its own. The real dependency is Impact Pack, so make sure that's in first. Then either:

ComfyUI-Manager → Install Custom Nodes → search "comfyui-face-beauty"

or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/FeiJiu518/comfyui-face-beauty
# restart ComfyUI - nodes appear under the FaceBeauty category

One trap: since Impact Pack v8.0, UltralyticsDetectorProvider lives in the separate Impact Subpack, which is not auto-installed. If your detector node simply doesn't exist, that's why - install the Subpack and grab a YOLO face model (face_yolov8m.pt is the usual pick).

Where people get burned

  • Zero detections still emits a face. If segs comes back empty, the node passes a black 1024×1024 dummy through so the list stays non-empty. Downstream nodes run, and paste-back silently drops a black square where no face was. Check the preview whenever the result looks wrong.
  • The 1024 minimum is aggressive. An 80px face is being upscaled thirteen-fold. If the output looks soft, that's usually not this node's fault - it's the upscale interacting with a refinement step that can't fabricate real detail. The square crop is the enabler, not the fixer.
  • Order is everything downstream. Faces get matched back by list index. Reorder, filter, or merge face_crops and you'll land improved face #2 on head #3 with a straight face.

It's not flashy. It's plumbing - the kind that makes a custom face pipeline possible, and the one to reach for when FaceDetailer's fixed recipe isn't yours.

CategoryFaceBeauty

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
segsSEGS
dilationINT320–512

Outputs (3)

NameTypeDescription
previewIMAGE
face_cropsIMAGE
crop_dataFACE_CROP_DATA