Python background removal when you outgrow a single local script#
Many teams start with a small Python script and a popular open model. That works until you need consistent product edges, a local HTTP API for editors, or a managed path without rewriting the client.
When this applies#
- You already automate cutouts in Python and want a maintained package
- You need both local open weights and a cloud upgrade in one SDK
- You want Docker or Mac Local API with the same HTTP contract as cloud
- You are comparing open models on real photos, not only demos
Which path to use#
| If you… | Use |
|---|---|
| Offline / private / unlimited local | pip install withoutbg + open_weights() |
| Hair, fur, product edges | WithoutBG.api() (Pro Model API) |
| Choosing among rembg session models | Open Model Hub → rembg models directory |
| Quality vs u2net-class open models | Open Model vs u2net compare |
| Quality vs hosted remove.bg | remove.bg alternatives (Open, Pro and open models) |
How withoutBG fits#
- Official package: uv add withoutbg or pip install withoutbg.
- Local mode downloads Open Weights once (~495MB) and runs on CPU ONNX. No API key.
- Cloud mode uses the same remove_background call with an API key or WITHOUTBG_API_KEY.
- For editor workflows, pair Python or Docker with the GIMP plugin against 127.0.0.1:8000.
- rembg is a runtime with many sessions (u2net, IS-Net, BiRefNet, …) — see the rembg models hub for cards and visual compares.
Local options compared#
Alpha-matte error on Bench v0 (60 real photos, ground-truth mattes, 1024 px shorter side). Lower is better. withoutBG models route each image to a matting model or to BiRefNet; see the benchmark for the split.
| Option | License | MAE | MGE | Run |
|---|---|---|---|---|
| withoutBG Pro Model Self-Host | Commercial self-host license (commercial license) | 0.028 | 0.037 | Docker image (commercial license) |
| withoutBG Open Weights | Apache-2.0 (open weights) | 0.029 | 0.045 | pip install withoutbg |
| BiRefNet General | MIT (open weights) | 0.043 | 0.049 | rembg i -m birefnet-general in.jpg out.png |
| BiRefNet General Lite | MIT (open weights) | 0.052 | 0.054 | rembg i -m birefnet-general-lite in.jpg out.png |
| BiRefNet DIS | MIT (open weights) | 0.057 | 0.058 | rembg i -m birefnet-dis in.jpg out.png |
| BiRefNet Massive | MIT (open weights) | 0.071 | 0.056 | rembg i -m birefnet-massive in.jpg out.png |
| BiRefNet Portrait | MIT (open weights) | 0.071 | 0.065 | rembg i -m birefnet-portrait in.jpg out.png |
| IS-Net | Apache-2.0 (open weights) | 0.094 | 0.061 | rembg i -m isnet-general-use in.jpg out.png |
| BiRefNet HRSOD | MIT (open weights) | 0.107 | 0.071 | rembg i -m birefnet-hrsod in.jpg out.png |
| U²-Net | Apache-2.0 (open weights) | 0.128 | 0.080 | rembg i -m u2net in.jpg out.png |
| Silueta | Apache-2.0 (open weights) | 0.134 | 0.085 | rembg i -m silueta in.jpg out.png |
| U²-NetP | Apache-2.0 (open weights) | 0.140 | 0.080 | rembg i -m u2netp in.jpg out.png |
Python (open weights, runs locally)
pip install withoutbg
from withoutbg import WithoutBG
model = WithoutBG.open_weights()
model.remove_background("input.jpg").save("output.png")FAQ#
Is this a drop-in replacement for every open Python tool?#
APIs differ. Expect a short migration: install withoutbg, choose open_weights or api, call remove_background. See the Python docs for examples.
Can I keep processing local?#
Yes. open_weights() never sends images to withoutBG servers. Switch to api() only when you want Pro quality.
How does quality compare to u2net-based stacks?#
See the Open Model vs u2net side-by-side page for alpha mattes on the same photos. Pro is a further step up on hard edges. For the full rembg catalog, open the rembg models hub.
Where do I start?#
Python docs for install and batch examples, Open Model hub for the full surface area (Docker, Mac, GIMP).
How does withoutBG Open Weights score against u2net and other rembg sessions?#
Bench v0 scores 60 real photos against ground-truth alpha mattes at a 1024 px shorter side; lower is better. withoutBG Open Weights MAE 0.029, MGE 0.045; U²-Net MAE 0.128, MGE 0.080; U²-NetP MAE 0.140, MGE 0.080; IS-Net MAE 0.094, MGE 0.061; BiRefNet General MAE 0.043, MGE 0.049. The lowest MAE among the rembg sessions is BiRefNet General at 0.043. withoutBG Open Weights routes each image to a matting model or to BiRefNet, so part of its score is BiRefNet output; see the benchmark page for the split.
Next steps#
Pick an entrypoint. All product paths are linked from the use cases hub.