image-to-image (super-resolution) · vision · WASM · ~67 MB
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.
| Model | SceneWorks/real-esrgan-onnx — an ONNX export of Real-ESRGAN x4plus (RRDBNet) |
|---|---|
| Task | image-to-image (super-resolution / upscaling) — run via raw ONNX Runtime Web (see note below) |
| Runtime | onnxruntime-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 |
| Quantization | fp32 ONNX — runs on the plain WASM execution provider, no WebGPU needed |
| Backend | WebAssembly (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) |
| License | BSD-3-Clause (ONNX export) · Real-ESRGAN (BSD-3-Clause) |
| Web APIs | WebAssembly, Web Workers, OffscreenCanvas, ImageBitmap — all Baseline widely available |
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.
The wipe above is the real evidence — slide it to see Real-ESRGAN's detail against a plain bicubic enlargement at the same size. “Sharpness” is the Laplacian variance (the standard detail measure) of the bicubic → the Real-ESRGAN result; it rises sharply as the GAN reconstructs edges and texture a naive upscale can't.
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).
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.
Bright indigo = big gain (an edge or texture the GAN rebuilt); dark = the two upscales agree. A simple sharpen filter would just amplify existing contrast; Real-ESRGAN invents structurally-plausible detail, which is why the map traces objects and textures, not uniform noise.
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.
Shrink a photo to a thumbnail, then watch Real-ESRGAN enlarge it 4× — wipe between bicubic and Real-ESRGAN and see the sharpness jump.
Rescue an over-compressed image so it's usable at display size again, then download the 4× result.
Push it: shrink the source tiny and find where the GAN starts inventing detail that isn't in the original.
Enlarge → colourise: upscale a tiny old photo with Real-ESRGAN, then run DDColor on the result.
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.