← All models

image-to-image (face restoration) Β· vision Β· WASM Β· ~340 MB

GFPGAN β€” restore an old or degraded face

Give this model an old, low-resolution or degraded portrait and it reconstructs a clean, sharp face: defined eyes, smooth skin, recovered hair and expression. GFPGAN (CVPR 2021) is a blind face-restoration network built on a StyleGAN2 face prior β€” it learned what real faces look like and rebuilds the detail degradation destroyed. It works on a single, roughly front-facing, aligned face. Runs entirely on your device via ONNX Runtime Web; the photo never leaves the tab.

At a glance

ModelNeus/GFPGANv1.4 β€” an ONNX export of GFPGAN v1.4 (StyleGAN2-prior face restorer)
Taskimage-to-image (blind face restoration) β€” run via raw ONNX Runtime Web (see note below)
Runtimeonnxruntime-web 1.21 (transformers.js has no GFPGAN class / no face-restoration task)
Input[1, 3, 512, 512] float32 β€” an aligned face resized to 512Γ—512, normalised to [-1, 1] (not [0,1])
Output[1, 3, 512, 512] float32 in [-1, 1] β€” the restored face; mapped back to RGB
Quantizationfp32 ONNX β€” runs on the plain WASM execution provider, no WebGPU needed
BackendWebAssembly (single-threaded on GitHub Pages) β€” a 512Γ—512 pass is ~10–20 s
Download~340 MB, cached after first load (auto-inits on return). A large download β€” expect a wait on first use.
LicenseApache-2.0 (GFPGAN weights, TencentARC upstream). The ONNX re-export repo declares no explicit licence; the underlying weights are Apache-2.0.
Web APIsWebAssembly, Web Workers, OffscreenCanvas, ImageBitmap β€” all Baseline widely available

Run it

Pick a genuinely old, degraded portrait and restore it as-is β€” or add extra degradation to a cleaner face to watch GFPGAN undo a known amount. Drag the divider to compare the degraded input vs the restored face.

β—€ degraded inputrestored β–Ά
Drop / choose your own face photo (a single, front-facing, roughly aligned face)

Everything runs on your device β€” the photo and every restored pixel never leave the tab. Gallery images are rights-cleared samples (see each caption for the source).

See inside

Where did the model actually do something? This is the restoration delta: the per-pixel difference between the degraded input and the restored face, amplified. It lights up on the eyes, mouth, skin, and hairline β€” the facial structure a StyleGAN2 prior knows how to rebuild β€” and stays dark on flat background: nothing to restore there.

Restore a face to see where the model rebuilt it.

Why it matters

Old and low-quality portraits are everywhere β€” family archives, scanned documents, low-res avatars, video-call stills. On-device face restoration means you can rescue them privately, with no upload and no per-image cloud cost:

GFPGAN synthesises a plausible face from a learned prior; it can invent detail that wasn't there and can subtly change identity, so it's an enhancement, not forensic evidence. It expects a single, roughly aligned, front-facing face β€” group shots or profiles need a face detector/aligner first.

Use cases

Basics

Restore a genuinely old portrait as-is β€” wipe between the degraded original and the reconstructed face.

Practical

Rescue a small, compressed avatar or scan so the face is clean again, then download the result.

Wild

Push it: crank the degradation up and find where honest restoration turns into invented identity.

Multi-model

Restore β†’ upscale: reconstruct the face with GFPGAN, then enlarge the whole photo 4Γ— with Real-ESRGAN.

How the API works

transformers.js has no GFPGAN class and no face-restoration task, so we run the ONNX graph directly with ONNX Runtime Web. In goes an aligned face, out comes the restored one:

import * as ort from "onnxruntime-web";

const session = await ort.InferenceSession.create(gfpganBytes, { executionProviders: ["wasm"] });

// aligned face β†’ [1,3,512,512] float32 normalised to [-1,1]:  (x/255 - 0.5) / 0.5
const input = new ort.Tensor("float32", toNCHW(face, 512, 512), [1, 3, 512, 512]);
const { [session.outputNames[0]]: out } = await session.run({ [session.inputNames[0]]: input });

// out is [1,3,512,512] in [-1,1] β†’ map back to RGB:  (v + 1) / 2
const restored = tensorToImage(out.data, 512, 512);

Inference and the whole output composite run in a Web Worker so the UI never blocks, and the 340 MB model is fetched through Cache Storage, so a returning visit auto-initialises with no re-download.

References