Nodes/ComfyUI-DonutNodes/Face Detailer (Max Faces)
ComfyUI Node

Face Detailer (Max Faces)

The crowd-of-clones fix

By DonutsDelivery·Created 2 years ago·Updated a day ago· 26
Face Detailer (Max Faces)
  • image
  • model
  • clip
  • vae
  • positive
  • negative
  • bbox_detector
  • sam_model_opt
  • segm_detector_opt
  • detailer_hook
  • scheduler_func_opt
  • edit_model
  • face_reference
  • face_reference_b
  • nag_negative
  • nag_ref_boost_mask
  • image
  • cropped_refined
  • cropped_enhanced_alpha
  • mask
  • detailer_pipe
  • cnet_images
◄resolution1024►
◄max_resolution0►
◄guide_size_fortrue►
◄seed0►
◄steps20►
◄cfg8.00►
◄sampler_name▾►
◄scheduler▾►
◄denoise0.50►
◄feather5►
◄noise_masktrue►
◄force_inpainttrue►
◄bbox_threshold0.50►
◄bbox_dilation10►
◄bbox_crop_factor3.0►
◄sam_detection_hint▾►
◄sam_dilation0►
◄sam_threshold0.93►
◄sam_bbox_expansion0►
◄sam_mask_hint_threshold0.70►
◄sam_mask_hint_use_negative▾►
◄drop_size10►
◄wildcard—►
◄cycle1►
◄max_faces2►
◄inpaint_modelfalse►
◄noise_mask_feather20►
◄edit_modefalse►
◄edit_prompt—►
◄edit_negative_prompt—►
◄grounding_px768►
◄vary_seed_per_facefalse►
◄turbo_modefalse►
◄nag_enabledfalse►
◄nag_phi4.0►
◄nag_tau2.50►
◄nag_alpha0.25►
◄nag_sigma_start1000.0►
◄nag_sigma_end0.0►
◄nag_ref_boost1.00►
◄nag_ref_boost_a1.00►
◄nag_fit_modefit►
◄nag_auto_phifalse►
◄nag_phi_scale1.00►
◄vae_damage_correctionfalse►
◄vae_damage_strength1.00►
◄nag_alpha_scheduleconstant►
◄nag_alpha_start0.25►
◄nag_alpha_end0.25►

Every face detailer does the same four things: detect, crop, re-render at a sane resolution, paste back. The whole category is automatic inpainting, and it exists because a face occupying 70 pixels of a 1024 frame has no latent budget and comes out as a smear no matter how good the checkpoint is.

Impact Pack's FaceDetailer owns this loop in ComfyUI, and it works. It also has two long-standing annoyances: two dozen inputs, and the clone problem - every detected region re-renders on the same seed, so a crowd of twelve people comes back as a room of the same person. Donut's DonutFaceDetailer is a fork that keeps the Impact machinery and changes the parts people complain about. Crucially, it still is Impact Pack underneath - it imports impact.core and friends at execution time, and raises a clear error if the pack is missing rather than quietly disappearing from the node list.

What's different

Three things, and they're the reason to pick it over stock FaceDetailer:

max_faces. Detection returns everything the YOLO found, including the blurry strangers in the background. This node filters to segments with a non-empty mask, sorts them by bounding-box area, and keeps only the top max_faces - largest first, default 2. max_faces: 1 is the single-portrait case; raise it when you actually have a group shot and know how many faces are in it.

Megapixel sizing. resolution is an equivalent square target, not an edge length: the crop is scaled to hit that total pixel count with its aspect preserved, then the canvas is snapped to 64-pixel multiples. max_resolution caps the long edge (0 = no cap). This is more predictable VRAM-wise than edge-based guide sizing, which is what the docstring says it's for.

Edit mode and NAG. With edit_mode on, each detected face gets Krea 2 identity-edit conditioning instead of a plain img2img pass; face_reference supplies the identity, face_reference_b swaps to extracting from a second subject image, and vary_seed_per_face gives each face its own seed offset. NAG - a ComfyUI extension that restores negative prompting on guidance-distilled models by intervening in attention - is available through the nag_* inputs and needs the separate krea2-nag pack installed.

Inputs that matter

Wire image, model, clip, vae, positive, negative, and bbox_detector (an UltralyticsDetectorProvider from Impact Subpack). Then:

  • resolution - 1024 default. For a face crop, that's generous; 768 is fine for most work.
  • denoise - 0.5 default. This is the dial that decides "sharpen" versus "new face." 0.3–0.4 if the face was already decent.
  • max_faces - as above.
  • bbox_threshold - 0.5. Raise it if the detector is chasing faces in clouds.
  • bbox_crop_factor - 3.0, how much context around the box goes into the crop. More context means a more coherent re-render and a more visible seam.
  • feather (5) and, in the optional group, noise_mask_feather (20) - the seam dials.
  • guide_size_for, cycle, drop_size, sampler_name/scheduler/steps/cfg/seed - inherited Impact semantics; cycle runs multiple refinement rounds, and the implementation keeps intermediate rounds in latent space, decoding once at the end.

Optional extras worth knowing: sam_model_opt and segm_detector_opt refine the bbox into a polygon (fewer rectangular seams), detailer_hook, inpaint_model, scheduler_func_opt, wildcard, turbo_mode, and the nag_* family.

Outputs

image is the recomposited full frame - that's the one you chain onward. cropped_refined and cropped_enhanced_alpha are lists of the individual processed crops (the alpha version has the paste mask baked in), mask is the combined detection mask, detailer_pipe feeds other Impact nodes, and cnet_images is Impact's ControlNet-compatible crop list. Most workflows only use image.

Install

ComfyUI Manager, search DonutNodes, or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/DonutsDelivery/ComfyUI-DonutNodes.git donutnodes
cd donutnodes
python -m pip install -r requirements.txt

You also need ComfyUI Impact Pack and Impact Subpack, and the detector weights: face_yolov8m.pt into models/ultralytics/bbox/, plus sam_vit_b_01ec64.pth in models/sams/ if you use the SAM path. Those are the same Bingsu/adetailer YOLO weights A1111's ADetailer uses - nothing exotic, but nothing bundled either.

Troubleshooting

"DonutFaceDetailer requires a working ComfyUI Impact Pack." That's the execution-time import check firing. Repair Impact Pack through Manager and restart.

"DonutFaceDetailer found no face in face_reference." Edit mode is on and the detector couldn't find a face in your identity image. Use a clear, front-facing shot; bbox_threshold down if it's a hard one.

Clones. If you have more than one face in frame and they're converging, turn on vary_seed_per_face, or prompt for distinct faces before the pass.

Rectangular seams. Swap the bbox path for a segmentation detector and raise noise_mask_feather.

Order of operations. Detail at native resolution, then upscale. Doing it the other way bakes the mangled face into more pixels and then costs you more to fix.

One last thing, straight from the Impact Pack's history: the Ultralytics package that powers every YOLO detector in this pipeline is AGPL-3.0 and had a poisoned release in December 2024 that shipped a cryptominer to ComfyUI users through exactly this style of node. Pin your version.

CategoryImpactPack/Simple

Inputs (65)

NameTypeDefaultDescription
imageIMAGE—
modelMODEL—
clipCLIP—
vaeVAE—
resolutionINT1024256–4096Equivalent square target size. Sampling canvases are snapped to 64-pixel multiples.
max_resolutionINT00–4096Maximum edge length (0 = no limit).
guide_size_forBOOLEANtrue—
seedINT00–18446744073709550000—
stepsINT201–10000—
cfgFLOAT8.000–100—
sampler_nameCOMBO44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38
schedulerCOMBO9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3
positiveCONDITIONING—
negativeCONDITIONING—
denoiseFLOAT0.500.0001–1—
featherINT50–100—
noise_maskBOOLEANtrue—
force_inpaintBOOLEANtrue—
bbox_thresholdFLOAT0.500–1—
bbox_dilationINT10-512–512—
bbox_crop_factorFLOAT3.01–10—
sam_detection_hintCOMBO9 options: center-1, horizontal-2, vertical-2, rect-4, diamond-4, mask-area, +3
sam_dilationINT0-512–512—
sam_thresholdFLOAT0.930–1—
sam_bbox_expansionINT00–1000—
sam_mask_hint_thresholdFLOAT0.700–1—
sam_mask_hint_use_negativeCOMBO3 options: False, Small, Outter
drop_sizeINT101–16384—
bbox_detectorBBOX_DETECTOR—
wildcardSTRING—
cycleINT11–10—
max_facesINT21–20Maximum number of faces to process (largest by area)
sam_model_optoptSAM_MODEL—
segm_detector_optoptSEGM_DETECTOR—
detailer_hookoptDETAILER_HOOK—
inpaint_modeloptBOOLEANfalse—
noise_mask_featheroptINT200–100—
scheduler_func_optoptSCHEDULER_FUNC—
edit_modeoptBOOLEANfalseUse Krea2 identity edit conditioning for each detected face.
edit_promptoptSTRING—
edit_modeloptMODELOptional Krea2 model with the Identity Edit LoRA already applied. Falls back to model.
face_referenceoptIMAGERequired in edit mode. The bbox detector extracts the identity face from this image.
edit_negative_promptoptSTRING—
grounding_pxoptINT7680–4096—
vary_seed_per_faceoptBOOLEANfalseUse a unique seed offset for each detected face.
turbo_modeoptBOOLEANfalseSnap denoise to a valid Turbo scheduler point.
face_reference_boptIMAGEOptional subject/identity image for two-reference edits. Faces are extracted from this image when possible; if it has no detectable face, the detailer falls back to face_reference.
nag_enabledoptBOOLEANfalseApply Krea2 NAG inside sampling (requires krea2-nag). Uses CFG 1; Turbo negative conditioning stays zeroed.
nag_negativeoptCONDITIONINGUnzeroed negative prompt for NAG. Fusion Rebalance/taps are applied to match the positive stream. Defaults to edit_negative_prompt in edit mode, otherwise negative.
nag_phioptFLOAT4.00–20—
nag_tauoptFLOAT2.500.01–20—
nag_alphaoptFLOAT0.250–1—
nag_sigma_startoptFLOAT1000.00–1000—
nag_sigma_endoptFLOAT0.00–1000—
nag_ref_boostoptFLOAT1.000–1000—
nag_ref_boost_aoptFLOAT1.000–1000—
nag_fit_modeoptCOMBOfit2 options: fit, crop (legacy)
nag_ref_boost_maskoptMASK—
nag_auto_phioptBOOLEANfalseDerive phi from alpha so alpha*phi keeps the upstream default linear guidance strength (0.25*4 = 1.0).
nag_phi_scaleoptFLOAT1.000–4Multiplier for auto phi. 1.0 keeps upstream-default linear guidance strength; higher/lower scales it.
vae_damage_correctionoptBOOLEANfalseSubtract estimated VAE damage after decoding, using the selected VAE's encoder and decoder for one extra round trip per image or face crop. The 2x VAE filters back to the current image size before subtraction. No original reference is needed.
vae_damage_strengthoptFLOAT1.000–40 skips correction; 1 is one-pass VAE damage subtraction. Values above 1 strengthen the same correction and can amplify artifacts. Does not add more iterations.
nag_alpha_scheduleoptCOMBOconstantNAG alpha over this stage's executed denoising steps. The global Settings / Configuration panel mirrors the same curve to every NAG stage; each stage spans its own effective step range.
nag_alpha_startoptFLOAT0.250–1First executed step's NAG alpha for the shared dynamic schedule.
nag_alpha_endoptFLOAT0.250–1Last executed step's NAG alpha for the shared dynamic schedule.

Outputs (6)

NameTypeDescription
imageIMAGE—
cropped_refinedIMAGE—
cropped_enhanced_alphaIMAGE—
maskMASK—
detailer_pipeDETAILER_PIPE—
cnet_imagesIMAGE—