{"_id":"scanic-ml","_rev":"2-5aa0cb89cc5ca451a9452588fece183c","name":"scanic-ml","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"scanic-ml","version":"0.1.0","keywords":["scanic","document-scanner","onnx","onnxruntime-web","wasm","corner-detection","doccornernet"],"license":"MIT","_id":"scanic-ml@0.1.0","maintainers":[{"name":"marquaye","email":"Stephan.akrong@gmail.com"}],"homepage":"https://github.com/marquaye/scanic#readme","bugs":{"url":"https://github.com/marquaye/scanic/issues"},"dist":{"shasum":"5b3d25c330de8fc9d12b5ec9bdc851ffdc274e25","tarball":"https://registry.npmjs.org/scanic-ml/-/scanic-ml-0.1.0.tgz","fileCount":6,"integrity":"sha512-UXaQyxGQk1xEaEx0Rs6YVIKUpFADNIIloEXNGVpUfYVdeB2Y+w41X48x/9lbKPmL/Dyfsmrfn/puOum7ec4sXA==","signatures":[{"sig":"MEYCIQD5/LUyXos4nZOMOm9oZFfyzT6njLE+NDdpM3JAYTE95wIhAN5nnUUbYqCSckTDUq+hwmUlDy4GDR+/PWfWySinu2/4","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/scanic-ml@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":3463529},"gitHead":"b4b819e8791b73cb74d3ca75803d90c84af89e17","scripts":{"build:wasm":"bash build/build_minimal.sh"},"_npmUser":{"name":"marquaye","email":"Stephan.akrong@gmail.com"},"repository":{"url":"git+https://github.com/marquaye/scanic.git","type":"git","directory":"scanic-ml"},"_npmVersion":"10.8.2","description":"Optional ML document-corner detector assets for scanic — a channel-slimmed SimCC model (DocCornerNet) and a custom minimal ONNX Runtime Web WASM build (1.5 MB, ~88% smaller than stock ort-web).","directories":{},"_nodeVersion":"20.20.2","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/scanic-ml_0.1.0_1782803346931_0.7860830423492973","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"scanic-ml","version":"0.2.0","description":"Optional ML document-corner detector assets for scanic, a channel-slimmed SimCC model (DocCornerNet) and a custom minimal ONNX Runtime Web WASM build (1.5 MB, ~88% smaller than stock ort-web).","license":"MIT","repository":{"type":"git","url":"git+https://github.com/marquaye/scanic.git","directory":"scanic-ml"},"keywords":["scanic","document-scanner","onnx","onnxruntime-web","wasm","corner-detection","doccornernet"],"scripts":{"build:wasm":"bash build/build.sh"},"_id":"scanic-ml@0.2.0","gitHead":"1c936ca8a1081876b0d2626bb3305e38747608db","bugs":{"url":"https://github.com/marquaye/scanic/issues"},"homepage":"https://github.com/marquaye/scanic#readme","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-saBNPM6W7ubxJd9X3+5XEVal/YpBblfhBnU+Gkl7/QxIgVPWRrdVUnR10JC+nNYKQv2O9XQHBBdEMJWVB0tOgw==","shasum":"857550d8d0d588f453518372c44d60f233615603","tarball":"https://registry.npmjs.org/scanic-ml/-/scanic-ml-0.2.0.tgz","fileCount":6,"unpackedSize":3478417,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/scanic-ml@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEGXUdnspLuk2WFX7AY7rnJ2aD/VYZZ9Sm1kSdYo8vNUAiEA6zD34L7F8BRYq12uwNVXade8XyO5R2UrKfbFhyAJsx4="}]},"_npmUser":{"name":"marquaye","email":"Stephan.akrong@gmail.com"},"directories":{},"maintainers":[{"name":"marquaye","email":"Stephan.akrong@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/scanic-ml_0.2.0_1783429174274_0.10907662164779142"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-30T07:09:06.829Z","modified":"2026-07-07T12:59:34.743Z","0.1.0":"2026-06-30T07:09:07.188Z","0.2.0":"2026-07-07T12:59:34.464Z"},"bugs":{"url":"https://github.com/marquaye/scanic/issues"},"license":"MIT","homepage":"https://github.com/marquaye/scanic#readme","keywords":["scanic","document-scanner","onnx","onnxruntime-web","wasm","corner-detection","doccornernet"],"repository":{"type":"git","url":"git+https://github.com/marquaye/scanic.git","directory":"scanic-ml"},"description":"Optional ML document-corner detector assets for scanic, a channel-slimmed SimCC model (DocCornerNet) and a custom minimal ONNX Runtime Web WASM build (1.5 MB, ~88% smaller than stock ort-web).","maintainers":[{"name":"marquaye","email":"Stephan.akrong@gmail.com"}],"readme":"# scanic-ml\n\nOptional ML assets for [scanic](https://github.com/marquaye/scanic)'s machine-learning\ndocument-corner detector. Installing or hosting this is **only** needed if you use\n`scanDocument(image, { detector: 'ml' })`. The classical scanic detector has no\ndependency on this package.\n\n## What's in here\n\n| file | size | what |\n|---|---|---|\n| `dist/doccornernet_lean.ort` | ~1.9 MB | The corner-detection model, a channel-slimmed SimCC ([DocCornerNet](https://github.com/mapo80/DocCornerNet-CoordClass)), in ORT format. |\n| `dist/ort-wasm-simd-threaded.wasm` | ~1.5 MB | A **custom minimal** ONNX Runtime Web build (SIMD, pthread-capable) compiled with only the ~18 operators this model uses, ~88% smaller than stock ort-web (13 MB), same MLAS kernels. Runs on 1 thread by default; a cross-origin isolated host page can request more (see [Threads](#threads) below). |\n| `dist/ort-wasm-simd-threaded.mjs` | ~19 KB | The emscripten loader (named for what `onnxruntime-web`'s JS expects). |\n\nThese are served from a CDN by default (jsDelivr mirrors npm), so most users never\ninstall this package directly. Scanic fetches the assets at runtime:\n\n```\nhttps://cdn.jsdelivr.net/npm/scanic-ml@<version>/dist/\n```\n\n## Usage\n\nYou generally don't import this package. You point scanic's ML detector at it:\n\n```js\nimport { scanDocument } from 'scanic';\n// ESM build bundles the ONNX Runtime JS. No extra install needed.\n\nconst result = await scanDocument(image, { detector: 'ml' });\n// result.corners, result.score (P(document present))\n```\n\nTo self-host (e.g. offline, or to avoid the CDN), install this package and serve\n`dist/` from your own origin:\n\n```js\nawait scanDocument(image, {\n  detector: 'ml',\n  ml: { assetBaseUrl: '/assets/scanic-ml/' } // contains the files above\n});\n```\n\n## Threads\n\nThere is one wasm build, compiled with pthread support. It runs on 1 thread by\ndefault (works anywhere, no special headers). Opt into more threads with\n`threaded: true`:\n\n```js\nawait scanDocument(image, {\n  detector: 'ml',\n  ml: { threaded: true } // same assets, defaults to 4 threads\n});\n```\n\nRunning on more than 1 thread needs the host page to be\n[cross origin isolated](https://developer.mozilla.org/en-US/docs/Web/API/Window/crossOriginIsolated)\n(`COOP: same-origin` + `COEP: require-corp` response headers) for\n`SharedArrayBuffer` to be available; without that it falls back to running on\n1 thread (same wasm, no error), so requesting it speculatively is safe. Running\nthis build on 1 thread costs about 4% versus a hypothetical dedicated\nsingle-thread build, noise-level in absolute terms (see `MODEL_CARD.md`).\n\nMulti-threading roughly halves inference time (see `MODEL_CARD.md`): about 1.8x\nin Node and 2.1x in a cross-origin-isolated browser at 4 threads. The gain is on\nthe ML inference step. The end-to-end `detectDocumentMl` call improves less,\nabout 1.1x, because canvas preprocessing runs single-threaded. So it is a clear\nwin when inference dominates (repeated scans, larger inputs) and a modest one\nfor a single one-off scan.\n\n## Version pinning\n\nThe wasm is built from ONNX Runtime **v1.23.2**. The `onnxruntime-web` JS peer\ndependency must be **1.23.x**, the JS/wasm ABI is version-locked. The `.ort`\nmodel format is likewise tied to that runtime.\n\n## Reproducing the assets\n\nThe build is fully scripted and pinned, see [`build/`](./build). It converts the\nsource `.onnx` to `.ort`, clones ORT v1.23.2, and compiles the minimal\npthread-capable wasm:\n\n```bash\ndocker build -t scanic-ml-build scanic-ml/build\ndocker run --rm \\\n  -v \"$PWD/scanic-ml:/work\" \\\n  -v \"$PWD/scripts/ml-spike/model:/model:ro\" \\\n  scanic-ml-build\n```\n\nSee [`MODEL_CARD.md`](./MODEL_CARD.md) for the model's I/O contract, accuracy, and\nprovenance.\n","readmeFilename":"README.md"}