Self-host a background removal server with rembg (2027)
Bria.ai

Updated 2026-12-01
Disclosure: Bria wrote this guide and makes RMBG 3.0 and RMBG 2.0. Commands and license sentences are quoted from the rembg README and the model pages named below, read 2026-12-02. This guide is not legal advice.
TL;DR
Answer: Install rembg, start its HTTP server with
rembg s --host 0.0.0.0 --port 7000, and post images to/api/remove. Choose the model first, because the license sits with the model, not with rembg. Commercial use of RMBG 3.0 without a server runs through the Bria API at $0.018 per image (checked 2026-12-02).Default model: rembg's code is MIT licensed, but its default model, bria-rmbg (RMBG 2.0), is released under CC BY-NC 4.0, so commercial use needs a license from Bria. Other models link to their own source projects; check each one's license.
Docker: The README says to replace the
rembgcommand withdocker run danielgatis/rembg. The CPU image is about 1.6GB, and the NVIDIA CUDA image about 11GB with no models included.Bria route: The Bria API runs RMBG 3.0 at $0.018 per image for background removal (checked 2026-12-02), with no server to run.
Benchmark context: In Bria's benchmark, RMBG 3.0 ranked first of 6 models with an average rank of 1.51 on 234 hard images.
How do you self-host a background removal model and use it commercially? The practical route is the open source tool rembg, and the step most guides skip is choosing a model whose license you have read.
What do you need to self-host a background removal server with rembg?
You need Python from 3.11 up to but not including 3.14, one install command and disk space for the model files.
The rembg README lists python: >=3.11, <3.14. It describes rembg as a tool that "can be used as a CLI, Python library, HTTP server, or Docker container".
CPU install:
pip install "rembg[cpu,cli]"for the library plus the command line.NVIDIA install:
pip install "rembg[gpu,cli]", after checking onnxruntime support for your system.Models: Local models download on first use and are saved under
~/.rembg/models/.
Which model license should you check before the first run?
Check the license of the model you will run, because rembg's default model, bria-rmbg (RMBG 2.0), is CC BY-NC 4.0.
The README says the default model is bria-rmbg, sourced from RMBG-2.0, about 1.02 GB. rembg's code is MIT licensed, but its default model, bria-rmbg (RMBG 2.0), is released under CC BY-NC 4.0, so commercial use needs a license from Bria. Other models link to their own source projects; check each one's license. The RMBG 2.0 card says commercial use is subject to a commercial agreement with Bria.
rembg model name:
bria-rmbg(default); Source named in README: RMBG-2.0; License as published at the source: CC BY-NC 4.0, commercial agreement neededrembg model name:
u2net,u2netp; Source named in README: U-2-Net; License as published at the source: Apache License 2.0rembg model name:
birefnet-general; Source named in README: BiRefNet; License as published at the source: MIT per the card header
Source: rembg README model list, BiRefNet card and the U-2-Net LICENSE, read 2026-12-02. The rembg file is a converted export, so confirm that the ONNX file you download matches the license you read.
How do you install rembg and fetch models ahead of time?
Install with pip, then run the `d` subcommand to download models before the server takes traffic.
The README lists d as "download models ahead of time". Run rembg d --help to see its arguments, because the README does not show an example.
Install:
pip install "rembg[cpu,cli]"Help:
rembg --helpandrembg <COMMAND> --helpshow every subcommand.Model folder: Set
REMBG_HOMEto change where models are stored.
How do you start the rembg HTTP server?
Run `rembg s --host 0.0.0.0 --port 7000 --log_level info`, and the API documentation is at `http://localhost:7000/api`.
Two flags matter for a production box. --no-ui disables the Gradio interface, which the README says "reduces idle CPU usage". --max-sessions 4 limits how many models stay loaded in memory, from a default of 8.
Start:
rembg s --host 0.0.0.0 --port 7000 --log_level infoNo web UI:
rembg s --no-uiFewer models in memory:
rembg s --max-sessions 4Flag:
--no-ui; What the README says it does: Disables the Gradio UI to reduce idle CPU usage; Default: UI onFlag:
--max-sessions; What the README says it does: Limits how many models stay loaded in memory; Default: 8Flag:
--allow-remote-models; What the README says it does: Serves cloud models; Default: Off
Source: rembg README, read 2026-12-02.
How do you send an image to the server?
Post a file to `/api/remove` with curl, or pass an image URL as a query parameter.
Both calls are quoted from the README:
curl -s -F file=@/path/to/input.jpg "http://localhost:7000/api/remove" -o output.png
curl -s "http://localhost:7000/api/remove?url=http://input.png" -o output.pngThe model the server uses for a request is set by its options, so read the parameters on your own server's /api page. This guide quotes the README and did not run your server.
How do you run rembg in Docker?
Replace the `rembg` command with `docker run danielgatis/rembg`, and mount a folder so models are not downloaded again.
The README example for a single file is docker run -v .:/data danielgatis/rembg i /data/input.png /data/output.png. Its tip is to use -v /path/to/models/:/root/.rembg to store model files outside the container. For an NVIDIA GPU you build the image yourself, and the README says it needs about 11GB of disk space, against about 1.6GB for the CPU version.
CPU image:
danielgatis/rembgon Docker Hub.GPU image: Build from
Dockerfile_nvidia_cuda_cudnn_gpu, with the NVIDIA Container Toolkit installed.Server in Docker: Apply the README rule to
rembg s, and map the port with Docker's standard-pflag.
What should you keep switched off on a public server?
Keep `--allow-remote-models` off, because remote models bill the API key set in the server's environment.
The README says cloud models are off by default "because a request without its own api_key is billed to the API key set in the server's environment". Put your own access control in front of any server that faces the public internet.
When is the Bria API the simpler commercial path?
The Bria API is the simpler path when you want RMBG 3.0 without a GPU or a weights agreement.
Bria's pricing page lists "Background Removal $0.018 / Image ($0.025 with prompt)" and 100 free generations on the Free plan (checked 2026-12-02). In the API docs, RMBG 2.0 is the default and "model": "RMBG3" selects RMBG 3.0. The RMBG 3.0 card lists 32 GB or more of GPU memory for self-hosting.
What should you record before going live?
Record the model, its license sentence, the source URL and the date for every file in the image.
Model file: Name and download URL.
License: The exact sentence from the card or LICENSE.
Date read: The day you checked it.
Notices: For MIT and Apache files, see license notices for a self-hosted remover.
Which setup should you choose?
Choose by who carries the license and the GPU.
Choose rembg with `u2netp` or `u2net` if you want Apache-2.0 text and a small file.
Choose rembg with `birefnet-general` if you want the MIT-labelled BiRefNet family.
Choose the Bria API if you want RMBG 3.0 with the commercial license included.
Choose another model if you have no license from Bria for RMBG 2.0, because it is rembg's default model.





