Skip to main content
Somokolon LabsSomokolon Labs
All insights

Cutting a 600 MB model app down to 70 MB

6 min read
  • Edge AI
  • ONNX
  • Mobile

ResoNet needed to run respiratory screening entirely on-device, in places with no reliable network. The model was never the problem — the runtime was.

ResoNet classifies respiratory conditions from a cough recording. The requirement that shaped every decision was that it had to work with the network off — both for privacy and because the target users are in areas where connectivity is not a given.

The first working build was over 600 MB. Almost none of that was the model. It was the dependency tree we had dragged along to do audio preprocessing: a Python-shaped pipeline lifted onto the device, bundling numerical libraries to compute what amounts to a mel spectrogram.

The actual problem

Training-time and inference-time preprocessing had been written once, in the training environment, and then shipped. That is convenient during research and expensive in production. The classifier itself, exported to ONNX and quantized, was a few tens of megabytes.

What we changed

  • Reimplemented the audio front end — resampling, framing, windowing, mel filterbank, log compression — in pure Dart, with no numerical dependency.
  • Exported the ResNet classifier to ONNX and ran it through ONNX Runtime's mobile build instead of a full framework runtime.
  • Wrote a parity test that runs the same WAV files through the original pipeline and the Dart one and asserts the feature matrices match within tolerance.

That parity test is the part worth copying. Rewriting preprocessing is where accuracy quietly disappears: the model is unchanged, the features shift slightly, and the metrics drop for reasons nobody can locate three weeks later. Pinning the two implementations against each other turns a risky rewrite into a mechanical one.

Result

Roughly 70 MB installed, down from 600 MB+, with no measured accuracy loss and inference running locally on the handset. No audio leaves the device.

On-device budgets are usually spent on the runtime, not the weights. Measure before optimizing the model.

Have a problem worth solving with software?

Tell us what you're building. We'll help you scope it, build it, and ship it.

Get in touch