I tested 4 open background-removal models in the browser. Only one worked.

November 28, 2026 ยท ProgramTalk

I run programtalk.com, a site of free tools. I wanted a background remover that never uploads the photo.

The plan was simple. Download an open model once, run it on the visitor's device, and apply the mask to the full-resolution original.

Four models looked suitable. All four are tagged for transformers.js on Hugging Face. One of them ran.

The setup

I used transformers.js 3.8.1, which wraps onnxruntime-web, inside a module Web Worker. The ONNX models come from Hugging Face and the browser caches them.

The worker tries WebGPU first and falls back to WebAssembly on the CPU.

The input image is scaled so its longest side is 1,024 px. The model returns a soft mask. I scale the mask back up and apply it as the alpha channel of the original, so the output PNG is full resolution.

For each model the worker tried three settings in order:

  1. WebGPU with fp16 weights, only if the GPU reports shader-f16
  2. WebGPU with fp32 weights
  3. CPU

I counted a model as failed only when every setting failed.

I tested in a normal desktop Chrome with WebGPU. I don't know the exact GPU in that machine, so treat this as one data point.

Results

ModelLicenseSizeResult
MODNetApache-2.07โ€“26 MBWorked on GPU. 6 s first run including download, then 1.3โ€“3.5 s.
BiRefNet liteMIT115 MB fp16 / 224 MB fp32Failed on GPU fp16, GPU fp32 and CPU. Error: 146972536.
ORMBGApache-2.044โ€“176 MBFailed on every setting. Last error mentions ceil() in MaxPool.
BiRefNet 512x512MIT~473 MB fp16, 1.41 GB fp32fp16 failed. I stopped the fp32 download.

What each failure looked like

BiRefNet lite failed three times with the same bare error: 146972536. No message, just the number.

By then the browser had downloaded 338 MB for nothing.

ORMBG failed on every setting too. The last error was at least readable:

using ceil() in shape computation is not yet supported for MaxPool

BiRefNet 512x512 failed on fp16 after about 473 MB. The worker then fell back to fp32 and started a 1.41 GB download. I stopped it there.

So that one never got a full fp32 or CPU attempt. I still count it as failed. I won't ask a visitor to download 1.41 GB to cut out a photo.

Why, as far as I can tell

ORMBG is the clear case. Going by the error, the model uses MaxPool with ceil_mode, and the browser kernel doesn't support that yet.

The bare number is harder. When onnxruntime-web's WASM core throws a native exception, JavaScript receives a raw number instead of a message. That number is a pointer.

An out-of-memory failure and an unsupported operator look identical from the outside. I could not tell which one hit BiRefNet. I'd rather say that than guess.

The fallback chain has its own cost. Each fallback can mean a new download, and the fp32 file can be much bigger than the fp16 one. A "safe" fallback that pulls 1.41 GB is not safe for the visitor.

The crash that broke the working model

This one surprised me most.

After a big model crashed, I fell back to MODNet in the same worker. MODNet failed too. This was the model that had worked fine minutes earlier.

In a fresh worker, MODNet ran in 1.3 s.

My guess is that the crash leaves the worker's WebGPU device unusable. I have not confirmed that. The fix works either way.

What I changed

1. Try settings in order, and treat run-time failure as failure. A model can load cleanly and then die on the first inference. If you only catch load errors, you report success and hand back nothing.

2. Terminate and recreate the worker before falling back. Don't reuse a worker after a crash. Kill it, start a new one, then try the next option.

3. Version scripts by content hash. My worker script was served with a one-year immutable cache. My first fix only changed a version number inside that already-cached file. Nobody received it. The file name has to change when the content changes.

4. Check what your CDN does to HTML caching. My origin sent a no-cache header for HTML. Cloudflare overrode it with a four-hour browser TTL. Visitors kept old pages after each deploy. I switched the setting to respect the origin header.

The last two have nothing to do with machine learning. They cost me more confusion than the models did. I kept testing a fix that had not reached the browser.

Where it stands

The live background remover runs MODNet only. It takes about a second per photo once the model is cached. Output is full resolution, and nothing is uploaded.

MODNet is tuned for people and portraits, and that shows. Products and pets with clear outlines usually come out fine. Fur on a busy background is hard.

I would like to offer a stronger general-purpose model as an option. BiRefNet is the obvious candidate, which is why I tried two variants of it.

The site has eight other private in-browser AI tools built the same way. They include video subtitles with Whisper, an image upscaler, OCR and chat with PDF.

If you have made BiRefNet or ORMBG run in onnxruntime-web, on WebGPU or WASM, I'd like to hear how. I'm curious which export settings, opset or runtime version made the difference. And if you know how to turn that bare pointer into a real error message, even better.