Nodes/ComfyUI_Lam/多人面部裁剪
ComfyUI Node

多人面部裁剪

Crop every face in a photo into clean squares, masks and boxes included

By yanlang0123·Created 2 years ago·Updated 11 days ago· 77
多人面部裁剪
  • analysis_models
  • image
  • IMAGE
  • MASKS
  • BOXS
crop_padding_factor0.25

ImageCropFaces (多人面部裁剪, "multi-person face cropping") finds every face in an image and gives you three things for each one: a square crop, a mask showing where that face was, and the bounding-box coordinates. This is the plumbing behind a "crop each face, fix it, paste it back" workflow - the same detect-crop-refine idea Impact Pack made famous with FaceDetailer, minus the resampling itself.

Why you'd reach for it: group photos, batch portraiture, any image where faces are too small to sample well. The standard trick in the ecosystem is exactly this pattern - crop the face region, run a fresh sampling pass on it at proper resolution, composite it back - and this node is the crop half. It's genuinely useful for batch face detailing in ComfyUI.

How it works

It needs a face-analysis model bundle, which comes from the pack's LamFaceAnalysisModels node (the ANALYSIS_MODELS input). You can pick the insightface or auraface analysis backend there, plus the compute provider. This node then runs detection over the image, and for each face:

  • computes a square crop centered on the face, padded by crop_padding_factor,
  • resizes it to a multiple-of-64 size (faces get upscaled/downscaled to match each other, so a batch of faces is one consistent tensor),
  • builds a mask marking the crop's position in the original image,
  • records the box coordinates (height, width, left, top) so you can paste back exactly where it came from.

Small detections (under 50px) are skipped, and if it finds no faces it still returns a 64x64 placeholder so your graph doesn't crash on empty.

The inputs and outputs

  • analysis_models (ANALYSIS_MODELS) - from LamFaceAnalysisModels. This is the non-obvious dependency: nothing happens without it wired in.
  • image (IMAGE) - the input photo.
  • crop_padding_factor (FLOAT, default 0.25) - how much slack around each face. 0.25 is a sane starting point; raise it if crops are clipping ears, lower it if you want tighter faces.

Outputs:

  • IMAGE - the batched face crops, all the same size.
  • MASKS - one mask per crop, positioned in the original image's coordinates.
  • BOXS - the coordinates, for paste-back or logging.

Install

Standard pack install:

cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam

and restart. The heavyweight dependency is the face-analysis backend: the pack bundles an insightface.rar that the README wants extracted into python_embeded\Lib\site-packages, and insightface is famously one of the fiddlier installs in local generation (source builds, Visual Studio on Windows - though the 1.0 release finally dropped the C++ requirement). If the analysis model won't load, that extraction step is the first suspect, and the auraface backend exists as the pack's alternative if insightface fights you.

Common issues

  • "ANALYSIS_MODELS" input is red - you forgot LamFaceAnalysisModels, or wired a plain image into it. This node only accepts the analysis-model bundle.
  • Face not detected - faces under 50px are intentionally skipped. Raise the face size in the source image (upscale first) rather than fighting the detector.
  • Crops look zoomed or clipped - tune crop_padding_factor. The default is a middle ground; edge cases swing either way.
  • insightface won't import - the .rar extraction or the build step failed. Try the auraface backend.

It's a helper node, not a headline - but it's the one that makes per-face detail passes actually tractable, and it does the crop/mask/box bookkeeping so you don't have to.

Categorylam

Inputs (3)

NameTypeDefaultDescription
analysis_modelsANALYSIS_MODELS
imageIMAGE
crop_padding_factorFLOAT0.250–2

Outputs (3)

NameTypeDescription
IMAGEIMAGE
MASKSMASKS
BOXSBOXS