TGraphX › Insights › Local Computer Vision Inference: Browser, WebGPU or GPU Worker?
← Back to Insights

Local Computer Vision Inference: Browser, WebGPU or GPU Worker?

Topic: Vision, multimodal and domain applications

Local computer vision inference can mean four different things: a model running in your browser on the CPU, in your browser on the GPU through WebGPU, in a worker process on your own machine, or, loosely and wrongly, in a "private" worker on somebody else's machine. They differ in where your pixels travel, which models fit and what you wait for.

Choose in this order: data boundary first, because it is a requirement rather than a preference; capability second, because a model that does not fit is not an option; speed last, and only from measurements on your own hardware. This article gives you the arithmetic you can do before measuring.

Four places a model can run

Browser backends, a local worker and a remote worker

Server for codeand weightsBrowser page withyour inputBrowser CPU(WebAssembly)Remote GPU workerLocal workerprocessBrowser GPU(WebGPU)Other machinesYour device
The same diagram as a table
boxboundaryarrows to
Server for code and weightsOther machinesBrowser page with your input
Browser page with your inputYour deviceRemote GPU worker; Local worker process; Browser CPU (WebAssembly); Browser GPU (WebGPU)
Browser CPU (WebAssembly)Your device—
Remote GPU workerOther machines—
Local worker processYour device—
Browser GPU (WebGPU)Your device—

6 boxes and 5 arrows. No box is selected.

The server sends code and weights to the page. Of the arrows leaving the page, only the one to the remote worker carries your input off the device. A schematic drawn from the author's description: nothing is executed or measured. A dashed boundary shows what the author places together; it is not a tested security or privacy property.
Browser CPU Browser WebGPU Local worker Remote worker
Runtime WebAssembly GPU compute in the browser Native process (Python, C++, CUDA and so on) Native process elsewhere
User installs Nothing Nothing, but needs browser and GPU support Runtime, drivers, weights Nothing
Which models Those exported for the browser that fit in memory The same, minus unsupported operators Whatever your hardware runs The provider's list
Input leaves the browser No No Yes, to a process on the same machine Yes, over the network
Typical limit Speed GPU limits and operator coverage Your hardware and your maintenance Bandwidth, cost, trust

Follow the pixels and the weights

For each mode, write down four flows: where the input goes, where the weights come from, where results go, and what other traffic the application produces.

Mode Input Weights What else to check
Browser (either backend) Stays in the tab, unless the application also uploads or saves it Downloaded once from a server, then cached Analytics, error reporting, "save to cloud" features
Local worker Passed to another local program Stored on disk Which address it listens on, logs, temporary files
Remote worker Sent over the network Stay with the provider Retention, logging, who operates it, region, deletion

"Runs on your device" describes the inference step. It does not mean the page is offline, or that nothing is transmitted: the code and weights have to arrive first, a cached model can be evicted by the browser and fetched again, and an application can still send telemetry. To verify a privacy claim, watch the network panel during a run, and read what the product says about storage.

A local worker deserves its own care. Bound to the loopback address it is reachable only from the same machine; bound to all interfaces it is a network service that needs authentication like any other. A web page calling it is also subject to the browser's cross-origin rules and to restrictions on pages reaching local addresses, which browsers have been tightening, so test with the browsers your users have.

What the browser runtime can do

Browser inference libraries such as ONNX Runtime Web and Transformers.js offer a CPU backend compiled to WebAssembly and a GPU backend on WebGPU.

CPU through WebAssembly runs almost everywhere. Multi-threading needs shared memory, which browsers grant only to cross-origin isolated pages, those served with particular Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers. ONNX Runtime Web documents that without it, execution is single-threaded. WebAssembly's 32-bit addressing also caps a module at 4 GB of memory.

GPU through WebGPU needs a secure context, a browser that exposes the API, and a GPU adapter the browser is willing to hand out. The specification sets default limits of 128 MiB for one storage buffer binding and 256 MiB for one buffer. Adapters often support more, but an application has to ask for it. Not every operator in every model has a WebGPU implementation, so a runtime may place some work back on the CPU, with copies in between, or fail to load the model. In particular, a quantised 8-bit model that is small to download is not automatically a good GPU model.

Capability How to detect it What depends on it
Secure context isSecureContext WebGPU is not exposed without it
WebGPU adapter navigator.gpu.requestAdapter() returns an object Any GPU backend
16-bit float shaders adapter.features.has("shader-f16") Whether half-precision weights can be used on the GPU
Buffer limits adapter.limits Whether large intermediate tensors fit
Cross-origin isolation crossOriginIsolated Multi-threaded WebAssembly
Storage quota navigator.storage.estimate() Whether large weights stay cached

You can run this probe in your own browser's developer console:

javascript
async function probe() {
  const report = {
    secureContext: globalThis.isSecureContext,
    crossOriginIsolated: globalThis.crossOriginIsolated,
    logicalCores: navigator.hardwareConcurrency,
    webgpu: "navigator.gpu is missing",
  };
  const adapter = navigator.gpu ? await navigator.gpu.requestAdapter() : null;
  if (navigator.gpu) report.webgpu = adapter ? "adapter found" : "no adapter";
  if (adapter) {
    report.shaderF16 = adapter.features.has("shader-f16");
    report.maxStorageBufferBindingMiB = adapter.limits.maxStorageBufferBindingSize / 2 ** 20;
    report.maxBufferMiB = adapter.limits.maxBufferSize / 2 ** 20;
  }
  return report;
}
probe().then((report) => console.log(JSON.stringify(report, null, 2)));

Opened from a local file in headless Google Chrome 158 on a Linux machine that has a discrete GPU, it printed:

text
{
  "secureContext": true,
  "crossOriginIsolated": false,
  "logicalCores": 28,
  "webgpu": "no adapter"
}

That is the case people forget: the API exists, the hardware exists, and there is still no adapter in this configuration. Test for the adapter, not for the object, and have a defined answer for "no".

Estimating memory before you measure

Weights

weight bytes = number of parameters × bytes per parameter

with 4 bytes for 32-bit floats, 2 for 16-bit floats and 1 for 8-bit integers. The DINOv2 repository lists about 21, 86, 300 and 1100 million parameters for its small, base, large and giant backbones, so this arithmetic covers a useful range. (The Python outputs in this article were produced with Python 3.13.12 and NumPy 2.5.4.)

python
BYTES = {"float32": 4, "float16": 2, "int8": 1}

print("weights only (decimal MB)")
for name, parameters in (("DINOv2 ViT-S/14", 21e6), ("DINOv2 ViT-B/14", 86e6), ("DINOv2 ViT-L/14", 300e6)):
    print(f"  {name:16s}" + "".join(f"  {kind} {parameters * b / 1e6:6.0f}" for kind, b in BYTES.items()))


def tensor_mb(*shape, kind="float32"):
    n = 1
    for d in shape:
        n *= d
    return n * BYTES[kind] / 1e6


print("single tensors, float32 (decimal MB)")
print(f"  input 1x3x640x640        {tensor_mb(1, 3, 640, 640):6.2f}")
print(f"  feature map 1x256x80x80  {tensor_mb(1, 256, 80, 80):6.2f}")


def attention_mib(heads, side, patch, extra_tokens):
    """One full attention matrix [heads, tokens, tokens] in float32, in MiB (2**20 bytes)."""
    tokens = (side // patch) ** 2 + extra_tokens
    return tokens, heads * tokens * tokens * 4 / 2 ** 20


print("one attention matrix")
for label, args in (("ViT-L/14 at 224 px (1 class token)", (16, 224, 14, 1)),
                    ("ViT-S/16 at 1024 px (1 + 4 registers)", (6, 1024, 16, 5)),
                    ("ViT-L/16 at 1024 px (1 + 4 registers)", (16, 1024, 16, 5))):
    tokens, mib = attention_mib(*args)
    print(f"  {label:38s} tokens {tokens:5d}  {mib:7.1f} MiB")
text
weights only (decimal MB)
  DINOv2 ViT-S/14   float32     84  float16     42  int8     21
  DINOv2 ViT-B/14   float32    344  float16    172  int8     86
  DINOv2 ViT-L/14   float32   1200  float16    600  int8    300
single tensors, float32 (decimal MB)
  input 1x3x640x640          4.92
  feature map 1x256x80x80    6.55
one attention matrix
  ViT-L/14 at 224 px (1 class token)     tokens   257      4.0 MiB
  ViT-S/16 at 1024 px (1 + 4 registers)  tokens  4101    384.9 MiB
  ViT-L/16 at 1024 px (1 + 4 registers)  tokens  4101   1026.5 MiB

Raw size of a model's weights

A calculator that multiplies a parameter count, starting at 21 million, by the bytes of the chosen number type and shows the weight size.

Weights = parameters × bytes per parameter: 21,000,000 parameters × 2 B = 42,000,000 B, that is 40.05 MiB.

The same parameter count in each dtype
dtypeweights
float648 B each160.22 MiB168,000,000 B
float324 B each80.11 MiB84,000,000 B
float162 B each40.05 MiB42,000,000 B
bfloat162 B each40.05 MiB42,000,000 B
int81 B each20.03 MiB21,000,000 B
int40.5 B each10.01 MiB10,500,000 B

Theoretical weight memory in float16: 40.05 MiB (21,000,000 parameters × 2 B = 42,000,000 B).

Set the parameter count and the number type. This is weight storage only, not the memory a run needs. Theoretical: weights only. Real memory use is higher (activations, buffers, the runtime and its allocator), and quantised formats add scales and may keep some layers in higher precision. 1 KiB = 1024 B.

How close is the weight estimate to a real download?

Disclosure: the author of this article is also involved in building Anastig.

Anastig, an independent, early-access visual AI platform that is not part of TGraphX, serves DINOv2 browser builds, and on 2026-11-27 their weight files reported these sizes:

Build Estimate Observed file
Small, 8-bit 21 MB 24.5 MB
Small, 16-bit 42 MB 44.4 MB
Base, 16-bit 172 MB 173.6 MB
Large, 16-bit 600 MB 609.3 MB

For these four files the estimate is a little below the download size. A file also holds the graph and any tensors kept at higher precision.

Activations, and why input size matters so much

A tensor occupies the product of its dimensions times the bytes per element. A convolutional detector holds many feature maps like the one above. A vision transformer's attention compares every token with every other, so one full attention matrix is

heads × tokens² × bytes

Going from 224 to 1024 pixels multiplies the side by about 4.6, the token count by about 21 and this matrix by more than 400: the token count grows with the square of the side, and the matrix with the square of the token count. (The 5 extra tokens in the last two rows are one class token and four registers, as in DINOv3.) A runtime using a fused attention operator may never build the whole matrix, but if one must exist as a single GPU buffer, even the small model above exceeds WebGPU's default limits.

Real peak memory is larger than weights plus one tensor. Weights stored in 16 bits may be converted to 32 bits for computation; several activations are alive at once; the runtime keeps its own buffers; decoding and pre-processing allocate too; and other tabs share the machine. Treat estimates as a way to reject impossible plans, then measure peak memory on the weakest device you intend to support.

Latency is a sum

T = T_download + T_load + T_warm + N × (T_pre + T_transfer + T_infer + T_post)

  • T_download: weights, first use only (and again after cache eviction).
  • T_load: reading weights and building the session.
  • T_warm: one-off work on the first run, such as compiling GPU shaders.
  • N: number of images or sampled frames, processed one after another.
  • T_transfer: moving data to the GPU and back, or to a worker and back, including the network round trip.

Transfer is easy to compute and easy to forget. A 200 kB image on a 20 Mbit/s uplink takes 200 × 8 / 20000 = 0.08 seconds before the remote GPU has seen a pixel. Under serial processing, with equal pre- and post-processing, a remote worker beats a warm local one per frame only if

upload + round trip + remote inference + download of results < local inference

The block below applies the sum to invented timings. Nothing here is a measurement; the local and remote workers are assumed to have the weights already, and the remote model to be loaded.

python
def total_seconds(frames, infer_ms, load_s=0.0, download_mb=0.0, down_mbit=50.0,
                  upload_kb=0.0, up_mbit=20.0, round_trip_ms=0.0, other_ms=10.0):
    """Serial pipeline: one frame is finished before the next starts. All inputs are yours to measure."""
    first_use = download_mb * 8 / down_mbit
    per_frame_upload = upload_kb * 8e3 / (up_mbit * 1e6)
    per_frame = other_ms / 1000 + per_frame_upload + round_trip_ms / 1000 + infer_ms / 1000
    return first_use + load_s + frames * per_frame


OPTIONS = {                       # INVENTED numbers, only to show how the terms combine
    "browser CPU": dict(infer_ms=300, load_s=1.0, download_mb=40),
    "browser WebGPU": dict(infer_ms=40, load_s=3.0, download_mb=40),
    "local worker": dict(infer_ms=15, load_s=5.0),
    "remote worker": dict(infer_ms=15, upload_kb=200, round_trip_ms=50),
}
for frames in (1, 100):
    print(f"{frames} frame(s)")
    for name, settings in OPTIONS.items():
        print(f"  {name:15s} first run {total_seconds(frames, **settings):6.2f} s")
text
1 frame(s)
  browser CPU     first run   7.71 s
  browser WebGPU  first run   9.45 s
  local worker    first run   5.03 s
  remote worker   first run   0.16 s
100 frame(s)
  browser CPU     first run  38.40 s
  browser WebGPU  first run  14.40 s
  local worker    first run   7.50 s
  remote worker   first run  15.50 s

Where the time goes for 100 frames, invented inputs

Stacked bars for four options. Browser CPU is dominated by compute, browser WebGPU by download, load and compute together, the local worker by loading, and the remote worker by network time.

1. download2. load3. network4. per frame work

browser CPU: 38.4 s ×1.00

browser WebGPU: 14.4 s ×0.38

local worker: 7.5 s ×0.20

remote worker: 15.5 s ×0.40

Each × compares with browser CPU. Shown: total.

Values (s)
bardownloadloadnetworkper frame worktotal
browser CPU6.4103138.4
browser WebGPU6.430514.4
local worker0502.57.5
remote worker00132.515.5

Showing the totals: browser CPU 38.4 s; browser WebGPU 14.4 s; local worker 7.5 s; remote worker 15.5 s. Ratios are to browser CPU.

Show one segment at a time. The fixed costs and the per frame costs favour different options. Illustrative values chosen by the author: not measurements and not the output of any model. Bars start at zero; totals and ratios are computed from the values.

The pattern matters more than the numbers. For a single image the GPU backend in this example loses to the CPU backend because loading costs more than it saves. For many frames it wins. The warm remote worker is far ahead for one image, but over a hundred it falls behind the local worker and, narrowly, behind WebGPU, because upload and round trip repeat every time. Batching or sending requests concurrently changes the picture: throughput can rise while the delay of each item does not fall.

A GPU is fast at many independent multiply-and-add operations. Small models and small inputs give it little to parallelise, so launch and copy overheads weigh more. This is why a benchmark must name the model, input size, batch size and whether the first run was counted.

For measured numbers on one machine, with its method, see the CPU versus GPU video object detection benchmark.

Batching, pre-processing and whether executors agree

Batching processes several inputs in one pass. It raises throughput by sharing fixed costs, and it makes each item wait for the whole batch. It also multiplies activation memory, which in a browser or a small GPU may be the real limit. An interactive single-image tool and an overnight job want different settings.

Pre- and post-processing run around the model: decoding, orientation, resizing, normalisation, then thresholding, overlap removal and coordinate mapping. They often run on the CPU even when the model runs on the GPU. They are also where two executors of "the same model" most easily differ: one may stretch the image to the input size and another pad it, or use a different resampling filter.

Number format is another source of difference. An 8-bit build stores each weight as an integer times a step size. With one step for a whole tensor, the largest value sets the step for all the others:

python
import numpy as np


def batch(size, fixed_ms=20.0, per_item_ms=5.0):         # an invented linear cost model
    delay = fixed_ms + per_item_ms * size
    return delay, 1000 * size / delay


for size in (1, 8, 32):
    delay, rate = batch(size)
    print(f"batch {size:2d}: every item waits {delay:5.0f} ms, throughput {rate:5.0f} items/s")

rng = np.random.default_rng(0)
weights = rng.normal(0, 0.02, (256, 256))
inputs = rng.normal(0, 1, (256, 100))
outlier = weights.copy()
outlier[0, 0] = 2.0
for name, w in (("without outlier", weights), ("with one outlier", outlier)):
    scale = np.abs(w).max() / 127                        # one scale for the whole tensor
    restored = np.round(w / scale) * scale               # what 8-bit storage can represent
    error = np.linalg.norm((restored - w) @ inputs) / np.linalg.norm(w @ inputs)
    print(f"{name:17s} step {scale:.5f}   relative output error {error:.3f}")
text
batch  1: every item waits    25 ms, throughput    40 items/s
batch  8: every item waits    60 ms, throughput   133 items/s
batch 32: every item waits   180 ms, throughput   178 items/s
without outlier   step 0.00075   relative output error 0.011
with one outlier  step 0.01575   relative output error 0.208

The batch costs are invented; the quantisation arithmetic is exact for this random matrix. Real quantisers reduce the outlier problem, for example with one step per channel, but the lesson holds: do not assume that two builds or two backends give identical outputs. Keep a small reference set, run it on every executor you ship, and compare detections by class and IoU, or embeddings by cosine, against tolerances you chose in advance.

Choosing an executor

An executor decision tree

Browserbuild thatfits?UsableWebGPUadapter?BrowserWebGPUCan yourmachine runit?Browser CPULocalworkerMay theinput besent away?RemoteworkerChangemodel ortaskyesnoyesnoyesnoyesno
The same diagram as a table
boxarrows to
Browser build that fits?Usable WebGPU adapter? (yes); Can your machine run it? (no)
Usable WebGPU adapter?Browser WebGPU (yes); Browser CPU (no)
Browser WebGPU—
Can your machine run it?Local worker (yes); May the input be sent away? (no)
Browser CPU—
Local worker—
May the input be sent away?Remote worker (yes); Change model or task (no)
Remote worker—
Change model or task—

9 boxes and 8 arrows. No box is selected.

Start at the top left. Every path ends in a choice, including the choice to change the model. A schematic drawn from the author's description: nothing is executed or measured.

Two rules keep the tree honest. First, never fall back across a data boundary silently: moving from GPU to CPU inside the tab changes speed, while moving from the device to a server changes what happens to the data, and needs the user's decision. Second, report which backend and model actually ran, so that a slow result or a different result can be explained.

Video raises the same questions at scale. The browser must be able to decode the codec, and most applications analyse sampled frames, so decide the sampling interval and a frame limit before estimating N. Events between samples are not seen.

Two local options that run outside the browser, both from the same author as this article: VisionServeX serves vision models on your own machine and documents that its HTTP gateway binds to 127.0.0.1 by default; AI-Powered Video Analyzer analyses video on your computer from the command line, downloading model weights on first use. If you try the latter: in v1.1.0, checked 2026-11-27, the documented .[vision] install does not bring PyTorch or Transformers, so detection finds nothing until they are installed.

One concrete example: Anastig's three choices

In Anastig's Vision Lab and Studio, a user chooses where a model runs. This reflects the published application on 2026-11-27; no Anastig model was run for this article. The Anastig overview on this site sets out account requirements and where your input goes. The public Vision Lab landing page still lists Anastig-hosted inference as roadmap, so confirm Remote GPU access before relying on it.

Choice Where the input goes Access
This device (default; WebGPU or WebAssembly) Stays in the browser; weights come from anastig.ai and are cached No account
My other device Sent directly to your own machine, not to Anastig Setup of that machine is not documented for customers
Anastig Remote GPU Uploaded and passed through anastig.ai to Anastig's GPU worker; Anastig states it is processed in memory and not stored unless you save or export; its privacy policy also mentions temporary staged upload chunks and jobs, removed when the job completes Paid, by arrangement

The same-machine local worker in the earlier tables is general architecture, not one of these three choices. A run is not moved to another choice without your selection. Within This device, the browser engines use ONNX Runtime Web and Transformers.js, take WebGPU when there is a usable adapter that can hold the model and otherwise the CPU where a CPU build exists, and report which backend and model actually ran.

Task This device, WebGPU This device, CPU Remote GPU (catalogue)
Detection YOLOv10n, D-FINE-N YOLOv10n, D-FINE-N Larger detector families such as RF-DETR, D-FINE and DEIM
Segmentation SAM 2.1 Tiny, a separate GPU build (box or point prompts) SAM 2.1 Tiny, MobileSAM, TinySAM, EfficientSAM-Ti (box or point prompts) SAM family, RF-DETR-Seg
Similarity DINOv2 S/B/L, INSID3 (experimental) DINOv2 S/B/L, INSID3 (experimental; large ones slow) DINOv2, CLIP, SigLIP 2, INSID3
Text prompts None None Grounding DINO, OWL-ViT/OWLv2 with SAM

The remote list is the product's catalogue; what a given worker reports as ready was not checked. Details that illustrate the earlier sections:

  • Having WebGPU does not mean every model uses it: the 8-bit SAM builds run on the CPU, and only a separate SAM 2.1 build, marked experimental, uses the GPU.
  • Capability changes download size: the small DINOv2 build is about 24 MB on the CPU, 44 MB on a GPU with 16-bit shaders and 88 MB on one without.
  • There is no browser build of DINOv2 giant, which at 1.1 billion parameters is about 2.2 GB even in 16 bits.
  • The Vision Lab workbench and demo pages are cross-origin isolated, so the CPU backend can use several threads.
  • On-device video in Vision Lab samples about one frame per second, up to 240 frames, with no tracking.

"This device" means the input is not sent for inference; the site still runs cookieless web analytics and makes status requests that carry no media. Signed-in workspaces do store uploaded images server-side, in Anastig's managed storage or an S3-compatible bucket. Anastig describes its optional GPU worker as built on VisionServeX. Its security page lists the controls it states; these are vendor statements rather than an audit, and no compliance certification is claimed.

What the text-prompt models in that table can and cannot do is shown in text-prompt object detection and segmentation.

The similarity models are explained in visual similarity search from one example.

A short checklist

  1. Write down which data may leave the device, the machine and the organisation.
  2. Estimate weight and largest-tensor memory; discard impossible options.
  3. Detect capabilities at run time, and define what happens when one is missing.
  4. Measure first-run and repeat latency separately, plus peak memory, on the weakest target.
  5. Show users where each run happens.

References