CodeFormer API for Python

Python client for the CodeFormer API — blind face restoration for old photos and AI faces through a hosted endpoint

Run CodeFormer in the browser → View on GitHub

Install

pip install git+https://github.com/codeformer-dev/codeformer-api.git
export SYNEXA_API_KEY="sk-..."

Quickstart

import codeformer_api

output = codeformer_api.run({
    "image": "https://example.com/input.png"
})
print(output)

Hosted models

About CodeFormer

CodeFormer is a blind face restoration model from S-Lab at Nanyang Technological University, published at NeurIPS 2022. It restores blurred, noisy, compressed or low-resolution faces by predicting codes from a learned codebook of high-quality facial features, and a single fidelity weight lets you trade sharpness against likeness to the original. Optional Real-ESRGAN background enhancement and face upsampling complete the pipeline. This client calls the hosted sczhou/codeformer endpoint on Synexa, the same model as the official release, with Tencent's GFPGAN available on the same interface as a lighter alternative.

FAQ

Is there a CodeFormer API?

The authors publish CodeFormer as code and weights, not as a hosted service. This package is a Python client for the sczhou/codeformer endpoint on Synexa, which serves the released model behind an HTTPS API, alongside tencentarc/gfpgan.

How much does the CodeFormer API cost?

sczhou/codeformer is $0.0025 per run and tencentarc/gfpgan is $0.0008 per run. Billing is per prediction with no idle charge; new Synexa accounts receive a free trial credit.

Can I run CodeFormer without a GPU?

Yes. With this client the restoration runs on Synexa's GPUs and you receive an image URL; your environment needs only Python 3.8+ and httpx. Self-hosting needs a CUDA GPU plus PyTorch, facexlib and Real-ESRGAN weights.

Does this client work with the sczhou/CodeFormer repo or ComfyUI?

No. It does not load local weights or ComfyUI nodes; it is an HTTP client for the hosted endpoint. Use the official repository or its ComfyUI ports for offline inference, video frames or custom fidelity schedules.

What input formats does it accept?

image (CodeFormer) or img (GFPGAN) must be a publicly reachable image URL, typically JPEG or PNG. CodeFormer's optional fields are codeformer_fidelity (0-1), upscale (integer), background_enhance and face_upsample (booleans). GFPGAN takes scale (number) and version (v1.3 or v1.4). Output is a URL to the restored image.

Is this the official CodeFormer SDK?

No. This is an independent, MIT-licensed client and is not affiliated with S-Lab, NTU or the CodeFormer authors. The official project is at https://github.com/sczhou/CodeFormer.

Get an API key and run CodeFormer →