Skip to content
Last updated

Self-host RMBG 2.0

Run RMBG 2.0 background removal on your own hardware with a self-hosted license. This guide installs the model, downloads its weights from Bria, and removes the background from a first image.

Requirements

  • An active RMBG 2.0 self-hosted license (pricing)
  • One of your organization's API keys
  • A machine with an NVIDIA GPU and Python 3.10 or newer
  • For the manual install: curl and jq, and network access to the Bria Engine, AWS CodeArtifact and Bria's weights CDN (no Hugging Face account)

1. Get a license

Buy an RMBG 2.0 license on the pricing page. You manage it, and see the installation steps, on the Licenses tab in the Console.

2. Install

Bria Studio installs the package, downloads the weights, and runs a test for you:

npx @bria-ai/studio

Pick RMBG 2.0 when Studio lists your licensed models. It installs remove_bg into a virtual environment at ~/.bria/venvs/rmbg-2.0, downloads the weights, and removes a sample background to confirm the setup.

3. Run it

Run from the environment the model is installed in. If you used Studio, activate the venv it created:

source ~/.bria/venvs/rmbg-2.0/bin/activate

Then load the model with your API key and remove a background. On first load setup() checks your license and downloads the weights to ~/.bria/models; later runs reuse them.

import os
from remove_bg import RemoveBG, RemoveBGConfig, RemoveBGInput

# Reads BRIA_API_TOKEN; checks the license and downloads the weights on first load.
pipe = RemoveBG(config=RemoveBGConfig(compile_model=False, api_token=os.environ["BRIA_API_TOKEN"]))
pipe.setup()

result = pipe.execute([RemoveBGInput(image="https://bria-test-images.s3.us-east-1.amazonaws.com/strawberry.jpg")])[0]
result.image.save("cutout.png")  # RGBA cutout with a transparent background

pipe.cleanup()  # free the GPU when you are done

Pass a URL or local path to RemoveBGInput.image. Inputs and outputs stay on your machine — only a small attribution vector is sent to Bria.

Errors and troubleshooting

No license for RMBG 2.0

Your account holds no active RMBG 2.0 license, so the install stops before anything downloads. Buy or renew it on the Licenses tab.

LicenseError when the model starts

The license was cancelled or ended. Open the Licenses tab — the error links straight to it. A card retry (past_due) stays active.

The model won't load and asks for an API token

No BRIA_API_TOKEN is set. Set it, or pass RemoveBGConfig(api_token="...").

WeightsError during download

The download was interrupted. Run again — it resumes where it stopped.

Usage and billing

Self-hosted runs are counted against your RMBG 2.0 license and shown in Usage & billing in the Console, tagged as self-hosted. See Self-hosted models for how licensing and billing work across models.