photomopOpen the studio

AI and on-device processing

ONNX

Also called open neural network exchange, .onnx or onnx runtime. Here is what it means, when it changes what you export, and what people get wrong.

AI and on-device processingRuns on your deviceUpdated 10 August 2026

The short answer

ONNX (Open Neural Network Exchange) is an open format for saving a trained model so a different framework or runtime can load it. The file holds the computation graph, the operators it uses and the learned weights, which lets a model trained in one toolkit run somewhere else entirely.

Updated

The short version

ONNX at a glance

Quick facts about ONNX: stands for, file extension, encoding, contains, compatibility marker, web backends
Quick factDetail
Stands forOpen Neural Network Exchange
File extension.onnx
EncodingProtocol buffers
ContainsGraph, operators, weights, metadata
Compatibility markerOpset version
Web backendsWebAssembly and WebGPU

Slide the table sideways to see every column.

What is inside an .onnx file?

A single file, encoded as protocol buffers, containing four things worth knowing about.

  • A graph of nodes and the tensors flowing between them, describing the order of operations from input to output.
  • Operators at each node, drawn from a standard set with defined semantics, so a convolution means the same thing to every runtime.
  • Initialisers, which are the trained weights, and usually the bulk of the file size.
  • Metadata, including input and output tensor names, shapes and data types, and an opset version that pins which revision of the operator set the graph relies on.

That last item causes more real problems than the rest combined, because a runtime that predates the opset a model was exported with will refuse to load it.

Why does it matter for shipping models to browsers?

Models are trained in Python, on large frameworks, on machines with plenty of memory. None of that exists in a browser tab. ONNX breaks the dependency: you export once from whatever you trained in, and any runtime that understands the format can execute it, including runtimes compiled to WebAssembly or backed by WebGPU.

The practical effect is that the training stack and the delivery stack stop being the same decision. A segmentation or matting model can be developed with the usual research tooling, exported, quantised, and then run on a phone, a laptop and a server from one artefact, rather than being reimplemented for each target.

What tends to go wrong on export?

Three failures account for most of them. Unsupported operators: the model uses something the target runtime or backend does not implement, so it either fails to load or silently falls back to a slower path. Dynamic shapes: the graph was exported expecting a fixed input size, and then you feed it a different resolution. Exporting with dynamic axes declared avoids a lot of pain.

The subtlest is preprocessing mismatch. Whether the model expects pixel values scaled to a particular range, in a particular channel order, with a particular normalisation, is a convention that often lives in the training code rather than in the file. Get it wrong and nothing errors, you just receive a plausible-looking mask that is quietly incorrect.

What people get wrong about onnx

Each one is a real failure mode, not a style preference.

  1. Exporting with a fixed input size and then discovering the model refuses any image at a different resolution.

  2. Ignoring the opset version, so a model loads on a development machine and fails in the runtime you ship.

  3. Reimplementing preprocessing by hand in the target application and getting the value range or channel order subtly wrong.

  4. Assuming a model that exports without warnings is numerically identical, rather than comparing outputs against the original.

Questions people ask

ONNX, answered

The follow-up questions people search for once they have the definition.

Is ONNX a model, a runtime, or a file format?

The format, primarily: a specification for how to serialise a computation graph and its weights. Several separate runtimes can load and execute that format, and people often use the name loosely for the whole ecosystem, but the standard itself is the interchange format.

Does converting to ONNX change the model's accuracy?

It should not, since the graph and weights are preserved. In practice small numeric differences appear because operators are implemented differently across backends, and larger ones appear if the export simplified something. Always compare outputs on a test set before and after conversion.

Can I quantise an ONNX model after exporting it?

Yes. Post-training quantisation operates on the exported file and rewrites the weights at lower precision, optionally using a small calibration set. This is the usual way a model gets shrunk for browser delivery, since it needs no access to the original training pipeline.

Why is my ONNX model slower in the browser than expected?

Usually one unsupported operator forcing part of the graph onto a slower fallback path, or the model running on the CPU because the GPU backend was unavailable. Profiling which nodes ran on which backend is the fastest way to find it.

Sources

Where the facts on this page come from. Every link opens the specification, standard or documentation the claim was read at.

Now do it to a photo

Photomop is a photo studio that runs on your own device. Resize, crop, compress, convert, batch edit, remove a background and change one all work in the browser tab you are reading this in, at full resolution and with no watermark. The on-device page shows you how to check that the photo stays put.