← All models

image-to-image (super-resolution) · vision · WASM · ~67 MB

Real-ESRGAN — enlarge a small image 4×

Give this model a small or compressed image and it reconstructs a 4× larger one with real detail — sharp edges, recovered texture, cleaned-up JPEG blocking. Real-ESRGAN (ICCVW 2021) is a GAN trained on real-world degradation, so it does far more than a bicubic enlargement: it synthesises plausible high-frequency detail. It's a different architecture from the built Swin2SR (a GAN, not a transformer, and 4× not 2×). Runs entirely on your device via ONNX Runtime Web; the image never leaves the tab.

At a glance

ModelSceneWorks/real-esrgan-onnx — an ONNX export of Real-ESRGAN x4plus (RRDBNet)
Taskimage-to-image (super-resolution / upscaling) — run via raw ONNX Runtime Web (see note below)
Runtimeonnxruntime-web 1.21 (transformers.js has no Real-ESRGAN / RRDBNet class)
Input[1, 3, h, w] float32 — the low-res image, values 0–1 (no normalisation); we bound the input so 4× stays feasible on WASM
Output[1, 3, 4h, 4w] float32 — the 4× upscaled image
Quantizationfp32 ONNX — runs on the plain WASM execution provider, no WebGPU needed
BackendWebAssembly (single-threaded on GitHub Pages) — a 4× pass on a small thumbnail is a few seconds
Download~67 MB, cached after first load (auto-inits on return)
LicenseBSD-3-Clause (ONNX export) · Real-ESRGAN (BSD-3-Clause)
Web APIsWebAssembly, Web Workers, OffscreenCanvas, ImageBitmap — all Baseline widely available

Run it

Pick a photo and shrink it to a small, low-quality source so you can watch Real-ESRGAN enlarge it — or drop your own small/compressed image. The divider wipes between a plain bicubic upscale and the Real-ESRGAN upscale, both at the same 4× resolution, so the comparison is honest.

◀ bicubic (naive)Real-ESRGAN ▶
Drop / choose your own small or low-res image

Everything runs on your device — the image and every upscaled pixel never leave the tab. Gallery images are rights-cleared samples (see each caption for the source).

See inside

What did the model actually add? This is the detail-gain map: the per-pixel difference between the Real-ESRGAN result and a plain bicubic upscale of the same thumbnail, amplified. It lights up along edges, text, and fine texture — the high-frequency detail a GAN synthesises and a naive enlargement can never produce. Flat areas (sky, walls) stay dark: bicubic already gets those right.

Upscale an image to see what detail the model added.

Why it matters

Low-resolution is usually a dead end — you can't re-shoot the source. On-device super-resolution means you can enlarge it privately, with no upload and no per-image cloud cost:

Real-ESRGAN reconstructs plausible detail; it can't recover information the downscaling erased entirely. On faces it may over-smooth — pair it with a face-restoration model (see the multi-model demo). It's an enhancement, not a source of ground truth.

Use cases

Basics

Shrink a photo to a thumbnail, then watch Real-ESRGAN enlarge it 4× — wipe between bicubic and Real-ESRGAN and see the sharpness jump.

Practical

Rescue an over-compressed image so it's usable at display size again, then download the 4× result.

Wild

Push it: shrink the source tiny and find where the GAN starts inventing detail that isn't in the original.

Multi-model

Enlarge → colourise: upscale a tiny old photo with Real-ESRGAN, then run DDColor on the result.

How the API works

transformers.js has no Real-ESRGAN (RRDBNet) class, so we run the ONNX graph directly with ONNX Runtime Web. In goes the small image, out comes a 4× larger one:

import * as ort from "onnxruntime-web";

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

// small image → [1,3,h,w] float32 in [0,1] (plain RGB, no normalisation)
const input = new ort.Tensor("float32", toNCHW(small, h, w), [1, 3, h, w]);
const { [session.outputNames[0]]: big } = await session.run({ [session.inputNames[0]]: input });

// big is [1,3,4h,4w] in [0,1] → clamp to RGBA (a 4× larger image)
const upscaled = tensorToImage(big.data, 4 * w, 4 * h);

Inference and the whole output composite (clamp, bicubic baseline, detail-gain map) run in a Web Worker so the UI never blocks, and the 67 MB model is fetched through Cache Storage, so a returning visit auto-initialises with no re-download.

References