Nodes/JNComfy/Face Restore With Model
ComfyUI Node

Face Restore With Model

Run CodeFormer/GFPGAN face restore inside ComfyUI

By jn-jairo·Created 2 years ago·Updated 2 years ago· 5
Face Restore With Model
  • facerestore_model
  • image
  • IMAGE
  • FACES_RESTORED_IMAGE
  • FACES_IMAGE
  • FACES_AREA_ARRAY
facedetection
strength0.50

This is the node that actually fixes a wrecked face - sharpens the mush a diffusion model leaves behind when a face only occupies a small patch of the frame. It's part of JNComfy, a big personal-toolbox pack from a single dev, jn-jairo, and this particular corner of it is a straight reimplementation of the well-known facerestore_cf node (the pack's own README credits mav-rik/facerestore_cf as the reference). If you've used face restore in Automatic1111 or seen "Restore faces" as a checkbox, this is that same idea - CodeFormer or GFPGAN - brought over as a proper ComfyUI node with real inputs instead of a toggle.

Why you'd use it

Diffusion models are bad at small faces. A face that's 80x80 pixels in a 1024-wide image gets almost no latent budget, so it comes out with dead eyes, mushy skin, or asymmetric features no matter how good your checkpoint is. The two standard fixes are ADetailer-style detect-and-reinpaint (regenerate the region) or face-restoration models like CodeFormer/GFPGAN (repair the region with a specialized network trained just for faces). This node is the second approach - it doesn't regenerate anything with your diffusion model, it runs a dedicated restoration model over detected face regions and blends the result back in.

How it works

Feed it an image and a loaded facerestore_model (from JN_FaceRestoreModelLoader, the companion node - read that one for how the model gets loaded). Internally it detects faces first - you pick which detector with facedetection, choosing from retinaface_resnet50, retinaface_mobile0.25, YOLOv5l, or YOLOv5n - then runs the restoration model on each detected face crop and composites the result back over the original image at a strength you control.

The inputs and outputs that matter

  • facerestore_model (FACERESTORE_MODEL) - from JN_FaceRestoreModelLoader. Required.
  • image (IMAGE) - the image to fix.
  • facedetection - pick a detector. retinaface_resnet50 is the accurate default most people reach for; the _mobile0.25 and YOLOv5 variants trade accuracy for speed on weaker hardware.
  • strength (default 0.5, range 0–1, step 0.05) - how hard the restoration is blended in. This is the one knob you'll actually touch: push it toward 1 for heavily damaged faces, pull it back toward 0 if restoration is making faces look plasticky or over-smoothed (a very real failure mode of CodeFormer/GFPGAN at full strength).

Four outputs, and it's worth knowing what each is for: IMAGE is your full composited result - wire this to Save/Preview like normal. FACES_RESTORED_IMAGE and FACES_IMAGE give you the restored and original face crops on their own, useful if you want to inspect or compare what the model actually changed. FACES_AREA_ARRAY hands back the detected face regions as data, handy if you want to feed the coordinates into something else downstream.

How to install it

Via ComfyUI Manager: search "JNComfy", install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/jn-jairo/jn_comfyui

then restart ComfyUI. Note this pack is genuinely obscure - there's no community chatter about it that we could find, and no listing in our knowledge base either, so if something goes sideways you're mostly reading the source, not a support thread.

Common issues & troubleshooting

"No models to select" / empty dropdown on the loader. This node depends on facerestore_model from JN_FaceRestoreModelLoader, and that loader only lists what's already on disk - see that article for where to put the .pth files.

Faces look worse, not better. Classic over-restoration: CodeFormer and GFPGAN both tend toward a smoothed, slightly generic look at strength 1.0. Drop strength to 0.3–0.5 and compare FACES_RESTORED_IMAGE against the original crop before deciding it's broken.

cv2/opencv import errors. The sibling project this is modeled on (facerestore_cf) is built on the facelib package, which pulls in opencv-python. If your ComfyUI environment is missing it, install it in the same venv ComfyUI runs in.

Apple Silicon / MPS crashes. The retinaface detection backend that this style of node uses has a documented history of device-mismatch errors on MPS in the sibling project - a real, previously-reported rough edge for this whole family of face-restore nodes, not something specific to your setup.

CategoryJN/Image/Face

Inputs (4)

NameTypeDefaultDescription
facerestore_modelFACERESTORE_MODEL
imageIMAGE
facedetectionCOMBO4 options: retinaface_resnet50, retinaface_mobile0.25, YOLOv5l, YOLOv5n
strengthFLOAT0.500–1

Outputs (4)

NameTypeDescription
IMAGEIMAGE
FACES_RESTORED_IMAGEIMAGE
FACES_IMAGEIMAGE
FACES_AREA_ARRAYARRAY