Johan Alphonso Braga
Typing test⌘J
ProjectsStack

Utilities

Ask anything Typing test

Elsewhere

GitHub

All projects

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.

ONNX Digit Lab

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.

onnx-digit-lab.johanthegoat.xyz Open in a new tab ↗
Next projectWebGPU Vision Lab →