Skip to content
Cutshed
Menu

Image · 18

Background remover

A small salient-object model paints a mask, and the page writes a PNG with that mask as alpha. Hair and glass are the hard cases. A person on a plain wall is the easy one.

The cutout uses U²-Netp, a 4.4 MB salient-object model (Apache-2.0). It is a general subject mask, not a studio key, so hair and glass can be rough. RMBG weights are not used because their license is non-commercial. First run downloads the model (4.4 MB) plus the ONNX runtime if it is not cached.

How to use it

The photo is scaled so the long edge is at most 1600 pixels, drawn into a 320×320 input, and normalized with ImageNet mean and standard deviation. U²-Netp returns a 320×320 mask. That mask is sampled back onto the working image.

The first run downloads about 4.4 MB of weights, then ONNX Runtime’s WASM build if it is not already cached. Later photos reuse both. The model runs on WASM, not WebGPU, because the session is shared with other image tools that need static shapes to stay simple.

Check the checkerboard. A halo means the mask is soft at the edge. A hole in a dark shirt means the shirt looked like background. Neither is fixed by running it twice. Paint those pixels in an editor, or shoot on a cleaner backdrop.

Tips

  • Contrast helps. A dark jacket on a dark couch is where the mask gives up.
  • Crop in close if the subject is small in the frame. 320 pixels of input cannot see a face that is 20 pixels tall.
  • JPEG edges can fringe. Start from PNG when you have it.

FAQ

Which model is this, and why not RMBG?

U²-Netp, the small U²-Net variant, Apache-2.0, from the xuebinqin/U-2-Net project (ONNX weights matching the rembg u2netp asset). RMBG-1.4 is not used. Its weights are not licensed for commercial use.

Will it keep hair?

Sometimes, as a soft edge. Fine hair against a busy background is the case this small model misses. Expect to tidy it.

Is the photo uploaded?

No. The weights download once. The pixels stay in the tab.

License

U²-Netp weights and the U²-Net project are Apache-2.0 (Xuebin Qin et al.). ONNX Runtime Web is MIT. RMBG and other non-commercial background weights are not included. The model license is not a release for the person in the photo.