Machine learning / 2026 / Live in the browser
ONNX Digit Lab
A 26 KB neural network running entirely in a browser tab. Draw a digit, it classifies on device, and the page reports which execution provider it actually got and what the inference cost.
01
The problem
Shipping a model to the browser is mostly not about the model. It is about which execution provider you land on, what the first inference costs against the steady state, and what the page does on a machine where none of the fast paths exist.
02
How I approached it
The runtime walks WebGPU, then WebGL, then WASM, and reports where it landed rather than guessing. A throwaway inference during load pays the kernel-compilation cost up front so it does not land on the first real click. Preprocessing mirrors the MNIST pipeline exactly: bounding box the ink, scale the longest side to 20px, centre it, then shift so the centre of mass sits in the middle. Skipping that is the usual reason a correctly-loaded model looks broken.
03
The outcome
Verified in a browser with software rendering: WebGL selected, 326ms to load, 643.8ms first inference, 3.3ms steady state. The first run is about 195 times the steady state, which is why warming the model matters more than the model does.