← All posts

ClearPix engineering series · Part 19

Choosing a Browser Background Remover: 24 Real Cases and a Portrait Correction

By the ClearPix team · Oct 29, 2026 · 4 min read

We tested 24 licensed portrait and product images before shipping our background-removal workflow, then repeated the full set after a portrait failure report. U²-Net is now the single production model for products and portraits. MODNet passed our initial export checks but produced unacceptable subject loss on the built-in portrait sample; ISNet and BiRefNet were also rejected, while RMBG was excluded by its license.

Route What happened Decision
U²-Net, fp32 All 24 product and portrait cases exported in the follow-up run; difficult ISNet products recovered Use for every production cutout
MODNet, fp16/fp32 Initial alpha/export checks passed, but the actual portrait sample lost hair, clothing, and body regions Reject for production
ISNet general-use A watch, white headphones, and dark shoes lost most or all of the subject Reject for this product set
BiRefNet general-lite, fp32/fp16 ArrayBuffer is detached on WebGPU; std::bad_alloc on WASM Reject on compatibility
RMBG-1.4/2.0 The weights require non-commercial licensing or a commercial agreement Exclude without a license

The hard cases changed the model choice

Our first general candidate was ISNet general-use. It processed ordinary products in roughly 376–414ms, but its failures were not subtle. A watch retained only faint pieces, white headphones largely disappeared, and a dark shoe image produced a maximum alpha value of 6 on a 0–255 scale. A report saying “all 24 cases ran” would have hidden the fact that some outputs contained almost no subject.

U²-Net recovered all four of those sentinels. The watch is intact, the white headphones are visible, the brush container keeps its thin structure, and the shoe returns as a usable cutout. Its measured time on those difficult images was 139–147ms, also faster than ISNet in this browser environment.

We initially kept MODNet for portraits because all 12 portrait inputs generated full-range alpha and downloadable results. That was not a sufficient visual gate. The built-in sample showed large holes across the person, hair, and clothing, while the Auto route—already using U²-Net—kept the subject intact. The mode selector exposed two genuinely different models, not two tuned versions of one pipeline.

The follow-up benchmark therefore ran U²-Net on every case. All 12 portraits and all 12 products completed with source RGB preserved in confident foreground pixels. The 24 measured runs took 139–148ms on the same Chrome WebGPU setup. Visual review of the white, black, and blue composites replaced the earlier MODNet verdicts; the public Quality data now names u2net_fp32_v1 for every case.

A large model is not automatically a better model

BiRefNet general-lite looked attractive on paper: general weights, a 1024×1024 input, and an MIT license. The fp32 graph had no DeformConv dependency, so we tested it in the actual browser pipeline. WebGPU failed with ArrayBuffer is detached and could not be cloned; WASM failed with std::bad_alloc. Converting the same general weights to fp16 reduced the file from 224,005,088 bytes to 114,538,787 bytes but reproduced the WebGPU error on the first hard case.

That ended the route. We did not switch to RMBG as a shortcut. Its non-commercial license is not compatible with dropping the weights into a commercial free tool without an agreement. License checks belong in model selection, not in a footer added after implementation.

The benchmark itself also needed repair. Routing a 224MB model through Playwright caused a Node JSON/base64 out-of-memory failure. Vite now serves the local model directly. Full-size PNG artifacts are saved one file at a time rather than serialized as one large batch. These changes made the measurements repeatable, but they did not turn a failed model into a successful one.

The production pipeline keeps original RGB

The model produces an alpha estimate, not a new photograph. matteFromAlpha combines that estimate with the original image data, so pixels whose alpha is 255 remain bit-identical to the source in the confident foreground. The benchmark checks that property explicitly.

Background replacement and output sizing happen in a separate compositor after the cutout exists. Transparent output keeps alpha; a color or image background produces an opaque composite. Changing a color, document preset, zoom, or vertical position reuses the stored matte and updates the preview without rerunning inference. The general and portrait pages only create transparent cutouts; replacement backgrounds and document layouts belong to their dedicated scene pages.

ID-photo presets now come from a source-linked registry of public authority dimensions. Millimeter sizes are converted at a stated 300dpi, not presented as universal digital-photo requirements. Canvas dimensions do not prove biometric or official compliance, and some authorities prohibit edited or composited photos.

The page-level E2E verifies real downloads and the scene boundaries: cutout-only pages expose no background controls, result-page controls update the canvas without another inference, custom backgrounds flatten correctly, and official presets produce the expected pixel dimensions. It also checks the 390px mobile layout for horizontal overflow.

What the public evidence says—and does not say

The 24 inputs are licensed real photos with per-case attribution. They do not have alpha ground truth. For that reason, our Quality dashboard publishes actual alpha, white and black outputs, model and backend names, wall time, review status, and source licenses. It does not invent PSNR, SSIM, or an accuracy score from those files.

This is still a limited test. Glass, transparent packaging, reflective details, original shadows, flyaway hair, overlapping people, and incorrect edges can fail. There is no manual mask brush in this version, and the compositor does not match perspective, lighting, or contact shadows. An ID-style canvas does not prove that any authority will accept the photo.

The background remover, product-photo page, and portrait-photo page expose those limits next to the real outputs. The useful result is not a claim of universal matting. It is a small, inspectable pipeline that recovered the cases our first candidates failed and makes the remaining failures visible.

Part 19 of the ClearPix engineering series.

More on in-browser models & performance

ClearPix is free, unlimited and runs entirely in your browser. If this post saved you a debugging session, a coffee keeps the model hosting and bandwidth paid for — nothing here is locked behind it.

Buy me a coffee