At a glance
| 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.
Camera frames stay strictly on your device. Point your webcam at a printed document vs a monitor displaying that document to test real optical moiré capture.
Camera idle.
Initialising model loader…
No document selected yet.
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.
- Pre-upload KYC gate: Warn or quarantine suspected screen-photo spoofs instantaneously before sending payloads to verification servers.
- High recall (99.8% eval): Trained on 6 synthetic moiré regimes including subtle single-frequency and localized elliptical patterns.
- Known caveats from the model card: Resizing high-res dark-mode screenshots to 224×224 can introduce bilinear aliasing that triggers
moire(~1.5% false positive rate on clean inputs; stronger on paper document scans).
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
Basics: 2D Spectrum & Patch Map
Measure 2D DFT spatial frequency energy, sweep moiré strength 0%→100%, and map 4×4 ViT patch sensitivity.
Practical: Batch KYC Screening
Screen multi-file invoice and KYC uploads in a cancellable FIFO queue with quarantine threshold and CSV/JSON export.
Wild: JPEG, Blur & Scan-Line Lab
Probe whether JPEG recompression, Gaussian blur, downscaling, or scan-lines evade or falsely trigger moiré alarms.
Multi-model: Moiré Gate → PP-OCRv5
Authenticate clean document scans (22.44 MB) before extracting oriented OCR text lines with PP-OCRv5 Mobile (21.5 MB).