image-to-image (deblur / restoration) Β· vision Β· WASM Β· ~92 MB
Give this model a blurred photo β camera shake, motion, a soft focus β and it reconstructs the sharp one: crisp edges, readable text, recovered texture. NAFNet is a restoration network (ECCV 2022) from the OpenCV Model Zoo, trained on real motion blur. It's not a sharpen filter β it learned what un-blurred scenes look like and rebuilds the detail. Runs entirely on your device via ONNX Runtime Web; the photo never leaves the tab.
| Model | opencv/deblurring_nafnet β NAFNet (Nonlinear-Activation-Free Network), OpenCV Model Zoo |
|---|---|
| Task | image-to-image (deblurring / restoration) β run via raw ONNX Runtime Web (see note below) |
| Runtime | onnxruntime-web 1.21 (transformers.js has no NAFNet class / no deblurring task) |
| Input | [1, 3, 512, 512] float32 β the blurred image resized to 512Γ512, values 0β1 (no normalisation) |
| Output | [1, 3, 512, 512] float32 β the restored image; resized back to your photo's aspect |
| Quantization | fp32 ONNX β runs on the plain WASM execution provider, no WebGPU needed |
| Backend | WebAssembly (single-threaded on GitHub Pages) β a 512Γ512 pass is a few seconds |
| Download | ~92 MB, cached after first load (auto-inits on return) |
| License | MIT (ONNX export) Β· NAFNet (MIT) |
| Web APIs | WebAssembly, Web Workers, OffscreenCanvas, ImageBitmap β all Baseline widely available |
Pick a sharp photo and add a known blur so you can watch NAFNet undo it β or drop your own genuinely blurry photo. Drag the divider to compare blurred vs restored.
The wipe above is the real evidence β slide it to see the detail come back. βSharpnessβ is the Laplacian variance (the standard focus measure, high-frequency energy) before β after; it rises as NAFNet rebuilds detail, though a directional blur that spares vertical edges moves it only modestly even when the picture looks far crisper.
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).
Where did the model actually do something? This is the restoration delta: the per-pixel difference between the blurred input and the restored output, amplified. It lights up along edges, text, and fine texture β exactly the high-frequency detail a blur destroys and NAFNet puts back. Flat areas (sky, walls) stay dark: nothing to restore there.
Bright indigo = big change (an edge or letter the model re-sharpened); dark = untouched. A pure sharpening filter would light up everywhere it found contrast; NAFNet concentrates on the structure that the blur actually smeared, which is why the delta traces objects, not noise.
A blurred shot is usually a lost shot β you can't re-take the moment. On-device restoration means you can rescue it privately, with no upload, no per-image cloud cost:
NAFNet reconstructs plausible detail; it can't invent information the blur erased entirely. Extreme blur restores partially β it's a rescue, not a time machine.
Blur a photo, then watch NAFNet rebuild it β wipe between blurred and restored and see the sharpness jump.
Rescue a shaky document photo so the text is legible again, then download the restored image.
Push it: crank the blur up and find the breaking point where restoration starts to give up.
Restore β detect text: deblur a photo, then run the text detector on the result to find text the blur hid.
transformers.js has no NAFNet class and no deblurring task, so we run the ONNX graph directly with ONNX Runtime Web. In goes the blurred image, out comes the restored one:
import * as ort from "onnxruntime-web";
const session = await ort.InferenceSession.create(nafnetBytes, { executionProviders: ["wasm"] });
// blurred image β [1,3,512,512] float32 in [0,1] (fixed network size, no normalisation)
const input = new ort.Tensor("float32", toNCHW(blurred, 512, 512), [1, 3, 512, 512]);
const { [session.outputNames[0]]: restored } = await session.run({ [session.inputNames[0]]: input });
// restored is [1,3,512,512] in [0,1] β clamp to RGBA and resize back to the original aspect
const sharp = tensorToImage(restored.data, 512, 512);
Inference and the whole output composite run in a Web Worker so the UI never blocks, and the 92 MB model is fetched through Cache Storage, so a returning visit auto-initialises with no re-download.