Nodes/ComfyUI LC MaskMaker Nodes/LC Face Crop πŸ“
ComfyUI Node

LC Face Crop πŸ“

One render, every social format β€” and nobody's head cut off

By lonecatone23Β·Created about a month agoΒ·Updated a day agoΒ· 18
LC Face Crop πŸ“
  • image
  • mask
  • image
  • width
  • height
β—„aspect_ratioInstagram Portrait (4:5) - 1080x1350β–Ί
β—„custom_width1080β–Ί
β—„custom_height1350β–Ί
β—„framingwidestβ–Ί
β—„facesallβ–Ί
β—„output_sizepreset sizeβ–Ί
β—„sam3_modelβ–Ύβ–Ί
β—„threshold0.50β–Ί

You made a good picture. It's 1024x1536-ish and it's going on Instagram, TikTok and your Civitai model page. A centre crop gives you a chin and no eyes, because the interesting thing in your render is not in the middle of the frame. LC Face Crop finds the faces first, then chooses the crop window around them.

How it actually works

The node lives in lonecatone23's LC MaskMaker pack, the model-backed half of his LC node family - the LC123 repo next door stays import-free, this one is where anything needing weights lives.

Faces come from SAM 3, the open-vocabulary segmenter that folded the old GroundingDINO-then-SAM pipeline into one model (kg/entities/sam.json). This pack calls ComfyUI's own built-in SAM 3 support rather than a third-party extension, and asks for several instances per word, so a crowded frame doesn't get you one lonely face.

From the boxes it computes a crop window three ways. Every face found is unioned, then the window is sized by your framing pick - widest just takes the biggest window the format allows and drops the face mass a third of the way down. The tighter settings are measured in face heights, which is where the "character dataset" idea comes from: upper body is about 5.5 face-heights with the face centre 28% from the top, head & shoulders is about 3.2 at 38%, and face is about 1.7 at 47%. Then the window is clamped inside the frame and slid so the faces sit at that spot rather than hard-centred. Nothing found? You get a plain centre crop and the console says so, out loud.

That's it. No diffusion, no resampling of the geometry - just arithmetic on boxes, then one Lanczos resize if you asked for preset size.

The inputs you'll touch

  • aspect_ratio - eleven presets lifted from lonecatone23's LC Aspect Ratio Simplifier (Instagram 4:5, TikTok 9:16, Widescreen 16:9, a 4:1 Civitai cover, 2:3, 3:2, 21:9 …) or custom, which switches on custom_width / custom_height. The preset name carries the target pixel size, e.g. Instagram Portrait (4:5) - 1080x1350.
  • framing - widest for social posts, head & shoulders for face LoRA datasets, face when you want crops that are basically all cheekbones.
  • faces - all keeps every face in the window; largest frames the main one. If posters or background people keep getting grabbed, largest is the fix.
  • output_size - preset size resizes to the format's pixels; keep pixels leaves the crop at your render's own resolution, which is what you want for a dataset.
  • threshold - SAM 3's confidence floor, 0.5 by default. Raise it if you get phantom faces, and near 0.05 you'll believe anything.
  • mask (optional) - wire a mask and SAM is skipped entirely: the crop frames that. Cars, products, pets, whatever your segmenter found.

Outputs are image, plus width and height as INTs - handy for a matching empty latent or a resize farther down the graph. The node also previews its result (it saves under a lc_face_crop prefix), so you can just run it and look.

Install

ComfyUI Manager, search ComfyUI LC MaskMaker Nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/lonecatone23/ComfyUI_LC_MaskMaker_nodes

Restart. The pack ships an install.py that adds transformers, huggingface_hub and timm only if they're missing - it never upgrades or pins an existing one, which is the polite way to do it.

You need a SAM 3 checkpoint for the automatic path. The dropdown offers a one-click download, sam3.1_multiplex_fp16.safetensors (about 1.7 GB, from Comfy-Org's ungated SAM 3.1 copy) into models/sam3; Meta's original facebook/sam3 is gated, so a copy you already have in models/sam3 or ComfyUI's models/detection is picked up instead. Weights are never bundled.

Where people get burned

  • "It just centre-cropped." No face cleared the threshold, or your ComfyUI is too old to have built-in SAM 3 - the node tells you to update in that case. A mask input sidesteps the whole question.
  • SAM 3 licensing. It's Meta's custom SAM Licence, not the Apache 2.0 that SAM and SAM 2 carry - check the KB panel before you ship something commercial.
  • The Windows/SAM 3 wart. The widely reported Triton dependency belongs to ComfyUI-RMBG's SAM 3 node specifically (docs/knowledge/masking-detection-detailing.md), not this pack's path, but it's where most SAM 3 install pain comes from.
  • Batching. With keep pixels, frames of different sizes are resized to match the first crop, because an IMAGE batch has to be uniform.
  • A 4:1 cover from a portrait render is going to be a thin band. widest and a smaller custom_height is about as good as that gets.
CategoryLC MaskMaker/image

Inputs (10)

NameTypeDefaultDescription
imageIMAGEβ€”
aspect_ratioCOMBOInstagram Portrait (4:5) - 1080x1350The format to crop to (the same list as LC Aspect Ratio Simplifier).
custom_widthINT108064–16384Used when aspect_ratio is custom.
custom_heightINT135064–16384Used when aspect_ratio is custom.
framingCOMBOwidestwidest: as much of the picture as the format allows, faces placed well. upper body / head & shoulders / face: tighter, sized from the face (datasets).
facesCOMBOallall: every face found stays in the crop. largest: frame the main face only.
output_sizeCOMBOpreset sizepreset size: resized to the format's size (e.g. 1080x1350). keep pixels: the crop at the picture's own resolution.
sam3_modelCOMBOSAM 3 model that finds the faces.
thresholdFLOAT0.500.05–0.95How sure SAM 3 has to be that it is a face.
maskoptMASKOptional. Frame this mask instead of searching for faces (any subject: a car, a product, a pet).

Outputs (3)

NameTypeDescription
imageIMAGEβ€”
widthINTβ€”
heightINTβ€”