WebGPU vs WebAssembly for local background removal

WebGPU can run model work on the GPU. WebAssembly gives the browser a broader CPU-compatible fallback. A useful background remover chooses between them without changing where the image is processed.

Published

Two execution paths, one local job

WebGPU gives web applications access to modern GPU compute. WebAssembly provides a portable compiled execution target that browsers can run without the same GPU requirements.

For background removal, both paths can execute the model on the user's device. The difference is how the browser performs the computation, not whether the source image has to be uploaded.

bgcut uses ONNX Runtime in both browser paths. Automatic mode attempts WebGPU first. If WebGPU is unavailable or its setup or inference fails in a way that permits fallback, bgcut retries with WebAssembly.

Why try WebGPU first

Neural-network inference contains large groups of numeric operations that can map well to a GPU. WebGPU gives the runtime a way to schedule those operations on supported browser and hardware combinations.

That does not make every WebGPU run faster than every WebAssembly run. Device, browser, model graph, input size, shader compilation, cache state, and runtime version all affect timing. Measure the exact configuration you plan to support.

bgcut keeps benchmark records separate from product claims for this reason. A performance number without its device, image size, browser, runtime, version, and cold or warm state is hard to reproduce.

Why WebAssembly still matters

A browser tool that requires one GPU path has a smaller compatibility range. WebAssembly gives bgcut another local execution option when WebGPU is missing or cannot complete the run.

The fallback also keeps the user-facing contract simple. The user chooses an image. bgcut selects the available browser engine. The output remains local in either case.

The fallback is not a promise that every device can run the model. Memory limits, browser features, and other runtime constraints still apply.

Safari and model selection

bgcut has a validated internal-FP16 browser model for Safari WebGPU devices that expose the shader-f16 feature. Other browser paths use the FP32 artifact.

This selection is an implementation detail with a verification rule. It should not be turned into a broad claim that one browser or numeric format is always faster or more accurate.

If you are integrating bgcut into a workflow where engine choice matters, use the documented runtime behavior and reproduce the benchmark on the devices you care about.