RestoreFormer++ — ONNX for the browser
A web-ready ONNX export of RestoreFormer++ (blind face restoration) for running in the browser with onnxruntime-web on WebGPU or WebAssembly.
Used by the free Doetra Photo Restorer.
What changed vs. the original
- Converted from the official PyTorch checkpoint to ONNX.
- Weights stored as fp16, compute in fp32: large float initializers are stored as float16 and cast back to
float32 inside the graph. This halves the download (≈147 MB instead of ≈294 MB) with no visible quality loss,
and it runs on GPUs without
shader-f16support.
Files
| File | Size | Notes |
|---|---|---|
restoreformer_pp_fp16w.onnx | 148 MB | fp16 weights, fp32 compute |
restoreformer_pp_int8w.onnx | 74 MB | int8 per-channel weights (DequantizeLinear) for convs/matmuls, fp16 for the rest, fp32 compute — mean output difference 0.7/255 vs the original; same speed on WebGPU. Recommended for the web. |
Input / output
| Name | Shape | Range | |
|---|---|---|---|
| Input | input | [1, 3, 512, 512] float32, RGB | [-1, 1] |
| Output | first output (session.outputNames[0]) | [1, 3, 512, 512] float32, RGB | [-1, 1] |
The graph also exposes intermediate tensors — request only the first output. Faces should be aligned to the FFHQ 512×512 five-point template (eyes, nose, mouth corners), e.g. with the YuNet face detector.
import * as ort from 'onnxruntime-web/webgpu'
const session = await ort.InferenceSession.create(url, { executionProviders: ['webgpu', 'wasm'] })
const out = await session.run({ input: tensor }, [session.outputNames[0]])
Credits & license
- Paper / code: RestoreFormer++: Towards Real-World Blind Face Restoration from Undegraded Key-Value Pairs, Zhouxia Wang et al. — https://github.com/wzhouxiff/RestoreFormerPlusPlus (Apache-2.0).
- This export is redistributed under the same Apache-2.0 license.