Nodes/Face Restorer for ComfyUI/🤩 Face Restorer
ComfyUI Node

🤩 Face Restorer

Fix busted faces in ComfyUI without a second sampler pass

By tungdop2·Created 2 years ago·Updated 2 years ago· 1
🤩 Face Restorer
  • input_image
  • face_restore_model
  • IMAGE
â—„has_alignedfalseâ–º
â—„only_center_facefalseâ–º
â—„paste_backtrueâ–º

ComfyUI has two very different ways to fix a ruined face, and it pays to know which one you're grabbing. The famous one is FaceDetailer-style regeneration: detect the face, mask it, and run a whole new sampling pass over just that region with a prompt. The other is what the old A1111 "Restore faces" checkbox did - hand the detected face to a model trained to undo degradation. FaceRestorer is the second kind. It needs no sampler, no prompt, no checkpoint, and no API key. The name is slightly misleading: nothing about your ComfyUI install is being restored. Your picture is.

Face restoration fell out of fashion for a reason. Once latent upscaling and detailer passes got good, the "fix the main portrait" job moved to regeneration, and running a restore on an already-upscaled image just glosses over the detail the upscaler added. But that leaves a niche the detailers are bad at: small faces in the background of a photo-real scene, or a quick cleanup when you don't want the sampler re-rolling the identity. That's the niche this node owns. It runs in a fraction of the time of a detailer pass because it's a single forward pass through a transformer, not a diffusion loop.

How it works

Under the hood it's the RestoreFormer / RestoreFormer++ pipeline from wzhouxiff's repo, wrapped for ComfyUI. The flow per image: a RetinaFace ResNet-50 detector from facexlib finds faces, landmark alignment warps each one to a 512×512 crop, and a VQ-GAN + multi-head transformer reconstructs a clean face from the degraded one. Then the restored crop is pasted back onto the original with an inverse affine transform. Crucially, the background is untouched - the bg_upsampler branch in the code is commented out - so this never upscales anything. It's face-only surgery.

The inputs that matter

Most of the wiring is two cables: input_image (an IMAGE from whatever you generated) and face_restore_model (from the pack's loader node). Then three booleans:

  • paste_back (default true) - composite the restored face back onto the original. Set it false and you get the raw restored face crops back as a batch instead, handy if you want to inspect or process them further.
  • has_aligned (default false) - set true when you're feeding already-cropped, aligned faces and want to skip detection entirely.
  • only_center_face (default false) - true is the right call for a single portrait where background faces are noise you don't want touched.

The output is a single IMAGE, ready to wire into Save Image or anything downstream.

Install

ComfyUI Manager → search "Face Restorer" (the pack is titled "Face Restorer for ComfyUI"), or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/tungdop2/Comfyui_face_restorer
# restart ComfyUI

First run downloads the weights automatically: RestoreFormer++.ckpt lands in ComfyUI/models/facerestorer and the RetinaFace detector in models/facexlib. The README is famously thin - one intro line and an example image - so the code is doing all the explaining.

Where people get burned

The requirements.txt pins museum-grade versions: basicsr==1.4.2, pytorch-lightning==1.0.8, test-tube, omegaconf. Here's the thing - the shipped runtime code doesn't import pytorch-lightning, test-tube, or omegaconf at all; the pack vendors its own trimmed basicsr. The dependency that actually matters at runtime is facexlib (the helper imports it directly), which you usually already have. If a Manager install starts downgrading your lightning to 1.0.8 and other packs throw a fit, that's why - and pip install facexlib alone may be all you actually need.

Other real gotchas: a RuntimeError during inference is caught and the node silently falls back to the un-restored crop (you'll see "Failed inference for RestoreFormer" in the console), and the detector skips faces whose eye distance is under 5 pixels - so tiny background faces can be ignored entirely, despite the author's own TODO comment admitting wrong detections still slip through. And since RestoreFormer is autoregressive, a crowd shot of faces means one crop at a time. Slow, but honest work.

Categoryface_restorer

Inputs (5)

NameTypeDefaultDescription
input_imageIMAGE—
face_restore_modelFACE_RESTORE_MODEL—
has_alignedBOOLEANfalse—
only_center_faceBOOLEANfalse—
paste_backBOOLEANtrue—

Outputs (1)

NameTypeDescription
IMAGEIMAGE—