LocalBG

Fri May 01 2026 08:00:00 GMT+0800 (Taiwan Standard Time)

A local background remover, with a real model

What local means for background removal. WebGPU when it exists, WASM when it does not, and a cached MIT model.

A local background remover has to do the inference on the computer that has the photo. LocalBG uses ONNX Runtime Web inside a worker so the tab stays responsive while the graph runs. The worker asks for WebGPU first. If the adapter is missing — common on some locked-down browsers and on headless test runs — it loads the same session on the WASM backend with a single thread.

One thread is a deliberate limit. Multithreaded WASM needs cross-origin isolation (COOP and COEP), which this site does enable in public/_headers for Cloudflare Pages. The session still uses one thread because BiRefNet-lite’s intermediate tensors are happier with a smaller heap. WebGPU is the fast path when the machine has it. On WASM, a 512×512 pass is typically a few seconds to a few tens of seconds, depending on the CPU. The tool prints the inference time after each file so you can see which backend you actually got.

After the first download

The weights are cached with the Cache Storage API under localbg-models-v1, keyed by the pinned Hugging Face revision. A later visit can cut out a photo without fetching the model again, as long as the browser has not evicted the cache. That is the honest version of “offline”: the app shell is a static site, and the model is local after it has been stored. Airplane mode before the first run will fail, because there is nothing to run yet.

What local does not mean

It does not mean a native app, and it does not mean the model is tiny. BiRefNet-lite FP16 is about 94 MB. Smaller nets such as U²-Netp are faster and Apache-2.0, but they give up edge quality. The 512 export is the one that matched “good matte” and “fits in a browser” at the same time. Details and the MIT text are on the licenses page. Try it on the tool.