Skip to content
image-classification · vision DeiT-Small/16 · Anti-Spoofing WASM q8 · 22.44 MB License: Apache-2.0

Document Moiré Detector ViT — Screen-Recapture Anti-Spoofing

Fine-tuned DeiT-small/16 (ViTForImageClassification, ~22.1M params, 14×14 = 196 patches of 16×16 px) that distinguishes genuine clean document scans from moiré interference caused by photographing an LCD monitor or phone screen — running 100% locally in 22.44 MB CPU WASM.

At a glance

Document Moiré Detector ViT specification and runtime grounding
Upstream model Jwalit/document-moire-detector (trained on RVL-CDIP document scans + 6 moiré generation regimes)
Loaded ONNX repo onnx-community/document-moire-detector-ONNX (onnx/model_quantized.onnx)
Pipeline task image-classification · { top_k: 2 } · labels: clean (0), moire (1)
Architecture ViTForImageClassification — facebook/deit-small-patch16-224 (16×16 patches, 14×14 = 196 tokens, 12 layers, 6 heads, hidden 384, MLP 1536, ~22.1M params)
Image processor ViTImageProcessor — 224×224 bilinear resize, rescale 1/255, mean [0.5, 0.5, 0.5], std [0.5, 0.5, 0.5]
Backend & size CPU WASM q8 — 22.44 MB (22,444,734 B) via local @huggingface/transformers@4.3.0 pin in worker.js (ConvInteger(10) unsupported in 3.7.5 WASM; ~200 ms typical latency)
License Apache-2.0 (upstream weights and ONNX export)

Live Document Authenticity & Screen-Recapture Detector

Choose a clean scan or screen-recaptured plate below, toggle live synthetic LCD moiré interference (0% → 100%) to compare Clean Scan vs Screen-Photo immediately, or upload/drop/paste/capture your own document photo. Everything executes locally in a dedicated Web Worker.

Initialising model loader…

No document selected yet.

Verdict–
Clean prob–
Moiré prob–
Margin–
Entropy–
Latency–
Backend / dtypewasm · q8
NaN / invalid0
Raw pipeline output (exact clean / moire score pairs)
[]

Why screen-recapture moiré detection matters in the browser

In KYC onboarding, insurance claims, and expense auditing, fraudsters often photograph an edited ID or forged invoice displayed on a monitor instead of scanning a physical document. Because the camera sensor grid beats against the LCD RGB subpixel matrix, high-frequency periodic interference waves appear across the capture. Checking this before upload keeps private financial and identity documents strictly on-device.

How the API works

Transformers.js runs onnx-community/document-moire-detector-ONNX via the standard image-classification pipeline inside a Web Worker. Because the quantized ViT patch projection uses ConvInteger(10), worker.js pins @huggingface/transformers@4.3.0 locally:

import { pipeline } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@4.3.0";

const detector = await pipeline("image-classification", "onnx-community/document-moire-detector-ONNX", {
  device: "wasm",
  dtype: "q8",
});
const results = await detector(image, { top_k: 2 });
// → [{ label: "clean", score: ... }, { label: "moire", score: ... }]

See inside the code

Inspect the exact ES modules powering this page — local 4.3.0 worker lifecycle, synthetic LCD moiré generator, and binary classification metrics.

Show the code — worker.js: ensureLoaded() (local 4.3.0 WASM q8 + epoch guards)
Show the code — worker.js: classifyImage() (white-flatten, top_k=2, real nanCount)
Show the code — moire-core.mjs: analyzeMoireClassification() & applySyntheticMoireToRgba()

Explore the 5-route use-case ladder

References & model card