# Card corner model

`docaligner-fastvit-t8-w16.onnx` finds the four corners of an ID card in a
photo for the ID card copy (src/assets/cardmodel.js). It runs in the visitor's
browser with onnxruntime-web; the photo never leaves the device.

## Source

DocAligner by DocsaidLab, heatmap model `fastvit_t8_h_e_bifpn_256_fp32.onnx`
(https://github.com/DocsaidLab/DocAligner, Apache License 2.0, see LICENSE).
Downloaded 2026-10-09 from the Google Drive file the project's code names
(id `1W88oOkHjMza6xXbDxrG8k_C-Tf2aYKJ4`), SHA-256
`950070fd4a46e25d46db7c35d0ed77612d9063f70d4543c7c504f0da6a943a89`.

## Change

The weights are stored as 16-bit floats and widened back to 32-bit by `Cast`
nodes when the model loads, so the file is half the size (6.7 MB instead of
13.2 MB) and the arithmetic is unchanged: on 200 labelled photos of ID cards
(MIDV-2020) the corners come out the same as with the original. Made with
`python3 models/card/shrink.py <original.onnx> docaligner-fastvit-t8-w16.onnx`
(needs `pip install onnx numpy`).

## Use

Input `img`: 1 × 3 × 256 × 256, the photo stretched to 256 × 256, channels in
BGR order, values 0 to 1. Output `heatmap`: 1 × 4 × 128 × 128, one map per
corner (top-left, top-right, bottom-right, bottom-left); the peak of each map
is the corner, its height how sure the model is.

`onnxruntime.LICENSE` is the licence of onnxruntime-web (MIT) and
`onnxruntime.ThirdPartyNotices.txt` the notices of the components inside its
.wasm (from github.com/microsoft/onnxruntime, tag v1.29.0); the build copies
both next to the runtime. Update the notices together with onnxruntime-web.
