Nodes/ComfyUI-API-DockerCPU/Replicate sczhou/codeformer
ComfyUI Node

Replicate sczhou/codeformer

The 'Restore Faces' toggle, but you pay Replicate instead of loading a model

By trustypangolinΒ·Created 5 months agoΒ·Updated about a month agoΒ· 0
Replicate sczhou/codeformer
  • IMAGE
  • IMAGE
  • API_JSON
β—„dry_runfalseβ–Ί
β—„force_rerunfalseβ–Ί
β—„codeformer_fidelity0.50β–Ί
β—„background_enhancetrueβ–Ί
β—„face_upsampletrueβ–Ί
β—„upscale2β–Ί

If you've ever ticked a "Restore faces" checkbox in an old tool, you already know what CodeFormer does - this node just hands that job to Replicate instead of running the model on your machine. It's the classic face-restoration model (from Tencent, alongside GFPGAN) as a paid cloud call: you feed it a photo, it cleans up the face, optionally upsamples it, and hands you back an image plus the JSON payload it sent. For anyone running ComfyUI on a CPU-only box - the whole reason this pack exists - it's the difference between fixing faces and not being able to at all.

Wire an image in and it works like you'd hope. The node takes a normal IMAGE tensor from a Load Image node, converts it to a base64 data URI, and calls Replicate's sczhou/codeformer endpoint. You get two outputs: IMAGE (the restored result, back as a tensor you can save or keep piping) and API_JSON (a string with the exact payload that went over the wire, base64 truncated - your debugging friend).

The inputs that actually matter, and there are only three:

  • codeformer_fidelity (default 0.5, range 0–1) - the knob everyone argues about. Low values stay faithful to the original face, high values let CodeFormer rebuild more aggressively. For an old blurry family photo, most people land around 0.5–0.7; crank it and faces start to look like cleanly rendered strangers.
  • upscale (default 2) - how much to enlarge the face region. Handy when the source is tiny, but it multiplies the "plastic" risk.
  • background_enhance and face_upsample (both default on) - leave them on unless you specifically don't want the background or the face touched.

Also present on every schema node in this pack: dry_run (skips the API call, returns a mock output so you can test wiring for free) and force_rerun (ComfyUI caches node outputs - flip this to force a real call instead of a stale cached result).

Here's the honest warning, because the community learned it the hard way with SUPIR and every generative restorer since: face restoration invents a plausible face, not the same face. The KB's upscaling essay calls this "the face problem" - it's design, not a settings issue. On a celebrity, a famous portrait, or a photo where identity matters, don't expect a preservation job; expect a cleanup that looks like the person. If identity is critical, keep faces out of this pass and fix them with something identity-aware.

Install is the standard pack flow - via ComfyUI Manager search for ComfyUI-API-DockerCPU, or:

cd ComfyUI/custom_nodes
git clone https://github.com/trustypangolin/ComfyUI-API-DockerCPU
cd ComfyUI-API-DockerCPU
pip install -r requirements.txt

Then set REPLICATE_API_TOKEN (required for every Replicate node) and restart ComfyUI. You'll find it under 🎨 DockerCPU API/🎨 Replicate.

Where people get burned: forgetting the token (you'll see Replicate client not available. Install replicate package and set REPLICATE_API_TOKEN. in the console), and forgetting this costs money per call - CodeFormer is cheap, but it's not free, and a batch of 500 old photos adds up. The other trap is over-restoration: set upscale too high with high fidelity and you get that waxy, AI-cleaned look that makes a photo read as fake. Dry-run a couple of settings first, eyeball the API_JSON, then let it loose.

Category🎨 DockerCPU API/🎨 Replicate

Inputs (7)

NameTypeDefaultDescription
dry_runBOOLEANfalseβ€”
force_rerunBOOLEANfalseβ€”
IMAGEIMAGEβ€”
codeformer_fidelityoptFLOAT0.500–1β€”
background_enhanceoptBOOLEANtrueβ€”
face_upsampleoptBOOLEANtrueβ€”
upscaleoptINT2β€”

Outputs (2)

NameTypeDescription
IMAGEIMAGEβ€”
API_JSONSTRINGβ€”