image-to-image (document dewarping) Β· vision Β· WASM Β· ~30 MB
Give this model a photo of a curled, skewed or perspective-distorted page β a book held open, a receipt on a table, a folded page shot at an angle β and it flattens it into a clean, rectangular, scanner-style document: straightened text lines, corrected geometry. UVDoc is the PaddleOCR document image unwarping model. It doesn't crop or rotate β it learns the page's 3D deformation and undoes it. Runs entirely on your device via ONNX Runtime Web; the document never leaves the tab.
| Model | PaddlePaddle/UVDoc_onnx β UVDoc, the PaddleOCR document image unwarping model |
|---|---|
| Task | image-to-image (document dewarping / rectification) β run via raw ONNX Runtime Web (see note below) |
| Runtime | onnxruntime-web 1.21 (transformers.js has no UVDoc class / no document-unwarping task) |
| Input | image [1, 3, H, W] float32 in 0β1 β the warped page, plain RGB (no normalisation), H/W rounded to a multiple of 32 |
| Output | fetch_name_0 [1, 3, H, W] float32 in 0β1 β the flattened page (the unwarped image directly, not a grid) |
| Quantization | fp32 ONNX (single file) β runs on the plain WASM execution provider, no WebGPU needed |
| Backend | WebAssembly (single-threaded on GitHub Pages) β a pass is roughly a second |
| Download | ~30 MB, cached after first load (auto-inits on return) |
| License | Apache-2.0 (PaddleOCR / PaddlePaddle) |
| Web APIs | WebAssembly, Web Workers, OffscreenCanvas, ImageBitmap β all Baseline widely available |
Pick a page and add a known curl/skew so you can watch UVDoc flatten it β or drop your own photo of a genuinely warped document. Drag the divider to compare warped vs flattened.
The wipe above is the real evidence β slide it to watch the page snap straight. βCorrectionβ is the RMS pixel shift between warped and flattened: it rises with the distortion the model had to undo, and is near zero on an already-flat page.
Everything runs on your device β the document and every corrected pixel never leave the tab. Sample pages are rights-cleared (see each caption for the source).
UVDoc doesn't just crop or rotate β it predicts the page's continuous 3D deformation and resamples every pixel to undo it. That's why straight text lines that bowed in the photo come back straight, and a page shot at an angle becomes a front-on rectangle. Watch the edges of the page as you wipe: a plain crop would leave them curved; UVDoc straightens them.
A photo of a page is not a scan β it's curled, skewed and lit unevenly, which wrecks OCR and looks unprofessional. On-device dewarping turns a phone photo into a clean document, privately and free:
UVDoc corrects geometric distortion; it doesn't invent text the photo never captured, and extreme folds or occlusions flatten only partially.
Curl a page, then watch UVDoc flatten it β wipe between warped and flattened and see the text lines straighten.
Flatten a real photographed page and download the corrected scan-style image, ready to file or print.
Crank the curl to an extreme fold and find where geometric rectification starts to break down.
Dewarp β read: flatten a page, then run the on-device text detector to see how many more lines OCR can find.
transformers.js has no UVDoc class and no document-unwarping task, so we run the ONNX graph directly with ONNX Runtime Web. In goes the warped page, out comes the flattened one:
import * as ort from "onnxruntime-web";
const session = await ort.InferenceSession.create(uvdocBytes, { executionProviders: ["wasm"] });
// warped page β [1,3,H,W] float32 in [0,1] (plain RGB, no normalisation)
const input = new ort.Tensor("float32", toNCHW(warped, W, H), [1, 3, H, W]);
const { fetch_name_0 } = await session.run({ image: input });
// fetch_name_0 is [1,3,H,W] in [0,1] β the flattened page β clamp to RGBA
const flat = tensorToImage(fetch_name_0.data, W, H);
Inference and the whole output composite run in a Web Worker so the UI never blocks, and the ~30 MB model is fetched through Cache Storage, so a returning visit auto-initialises with no re-download.