5 ways to remove image backgrounds in Python in 2027

Bria.ai

5 ways to remove image backgrounds in Python in 2027

Updated 2026-12-01

TL;DR

  • Direct answer: the Bria API with RMBG 3.0 is the first route to try. It takes a short SDK call through bria-client, costs $0.018 per image (checked 2026-11-29) and ranked first of 6 models in Bria's benchmark.

  • Free and local: rembg installs with pip, runs on your machine and uses the MIT license. Its default model, bria-rmbg (RMBG 2.0), is CC BY-NC 4.0, so commercial use needs a license from Bria.

  • Self-hosted model: BiRefNet loads through transformers under an MIT license and ranked sixth of 6 in Bria's benchmark, with an average rank of 3.56.

  • Other hosted APIs: Photoroom costs $0.02 per image on its Basic plan. The Clipdrop API page shows no price per credit.

  • Tested: none of the code below was run for this article. It is copied or translated from official docs.

How do I remove image backgrounds in Python? You pick one of five routes: a hosted API, a local library or a self-hosted model. This guide lists each with its documented Python call, price, free tier and license. Bria wrote this guide, and the benchmark rank is Bria's own, built from blind votes by professional and casual users plus a VLM side by side. For hands-on rembg and API steps, see the basic Python guide.

What are the 5 ways to remove an image background in Python?

The five routes are the Bria API, the Photoroom API, BiRefNet through transformers, rembg and the Clipdrop API. Two run on your machine, three are hosted. The table puts the Python facts side by side.

  • Route: Bria API, RMBG 3.0; Install: pip install bria-client; Runs on: Hosted; Price per image: $0.018; Free tier: 100 free generations; Benchmark rank (Bria's): 1 of 6, avg 1.51

  • Route: Photoroom API; Install: pip install requests; Runs on: Hosted; Price per image: $0.02; Free tier: 10 free production calls; Benchmark rank (Bria's): 2 of 6, avg 1.87

  • Route: BiRefNet; Install: pip install transformers plus PyTorch; Runs on: Your hardware; Price per image: No fee; Free tier: Not applicable; Benchmark rank (Bria's): 6 of 6, avg 3.56

  • Route: rembg; Install: pip install "rembg[cpu]"; Runs on: Your hardware; Price per image: No fee; Free tier: Not applicable; Benchmark rank (Bria's): Not benchmarked

  • Route: Clipdrop API; Install: pip install requests; Runs on: Hosted; Price per image: Not found; Free tier: 100 free credits; Benchmark rank (Bria's): Not benchmarked

Source: Bria benchmark and pricing (checked 2026-11-22 and 2026-12-02), Photoroom and Clipdrop docs, rembg and BiRefNet pages, all checked 2026-12-02. The Bria rank covers the models in Bria's test, not the Python packages around them.

1. Bria API with RMBG 3.0: which Python route ranks first in Bria's benchmark?

The Bria API runs [RMBG 3.0](https://huggingface.co/briaai/RMBG-3.0) with an SDK call that submits a job and polls for a PNG URL. RMBG 3.0 ranked first of 6 in Bria's benchmark, with an average rank of 1.51 over 234 hard images. The benchmark post explains the method.

from bria_client import BriaSyncClient
from bria_client.toolkit import Image

client = BriaSyncClient()  # reads BRIA_API_TOKEN
job = client.submit(
    endpoint="image/edit/remove_background",
    payload={"image": Image("input.jpg").as_bria_api_input, "model": "RMBG3"},
    raise_for_status=True,  # surface 429, 415 or 422 at submit
)
print(client.poll(job, interval=2, timeout=120).result.image_url)
  • Where it wins: it needs no GPU, takes a path, URL, PIL image or NumPy array, and the price is $0.018 per image on the pricing page.

  • What to know: the result is a URL you download, not bytes. The 60 requests per minute limit on Pay-as-you-go applies, and the Python SDK docs list the async client for concurrency.

  • When to shortlist it: shortlist it for code that ships to users and needs a commercial path. The open weights are CC BY-NC 4.0, and commercial use of the weights needs an agreement.

2. Photoroom API: which hosted route ranks second in Bria's benchmark?

Photoroom's Remove Background API takes one multipart request and returns the image. Photoroom ranked second of 6 in Bria's benchmark, with an average rank of 1.87, and was best or tied-best on 162 of 234 hard images.

import requests

with open("input.jpg", "rb") as f:
    r = requests.post(
        "https://sdk.photoroom.com/v1/segment",
        headers={"x-api-key": "YOUR_API_KEY"},
        files={"image_file": f},
    )
r.raise_for_status()
open("output.png", "wb").write(r.content)
  • Where it wins: the documented call is one request per image with no polling, and optional parameters are format, channels, bg_color, size and crop (Photoroom docs, checked 2026-12-02).

  • Where it falls short: the Basic plan costs $0.02 per image, $0.002 more than Bria's $0.018, with 10 free production calls (Photoroom pricing, checked 2026-12-02).

  • When to shortlist it: shortlist it if you want a synchronous call that returns image bytes. The code is translated from the curl call in Photoroom's docs.

3. BiRefNet through transformers: which MIT-licensed model can you run yourself?

[BiRefNet](https://huggingface.co/ZhengPeng7/BiRefNet) loads with `AutoModelForImageSegmentation` and produces a mask you write into the alpha channel. The model card lists an MIT license.

from transformers import AutoModelForImageSegmentation

birefnet = AutoModelForImageSegmentation.from_pretrained(
    "ZhengPeng7/BiRefNet", trust_remote_code=True
)
# The card's example then resizes to 1024 x 1024, runs
# birefnet(x)[-1].sigmoid(), resizes the mask back and calls image.putalpha(mask)
  • Where it wins: no per-image fee, the weights are MIT licensed and you control where images go.

  • Where it falls short: it ranked sixth of 6 in Bria's benchmark with an average rank of 3.56. You write the pre and post processing yourself from the card's example.

  • When to shortlist it: shortlist it for research or offline pipelines where you want the weights.

4. rembg: which Python library installs with one command?

[rembg](https://github.com/danielgatis/rembg) wraps several models behind `remove()` and runs as a library, a CLI, an HTTP server or a Docker container. The code is MIT licensed, and it supports Python 3.11 up to, but not including, 3.14.

from rembg import remove
from PIL import Image

remove(Image.open("input.jpg")).save("output.png")
  • Where it wins: the install variants [cpu], [gpu] and [rocm], a long model list and no per-image fee.

  • Where it falls short: the default model is RMBG 2.0, about 1.02 GB, 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.

  • When to shortlist it: shortlist it for scripts and prototypes on your own hardware. rembg as a package was not part of Bria's benchmark.

5. Clipdrop API: which hosted route uses a plain multipart call?

Clipdrop's Remove Background API takes `image_file` as multipart form data and returns a PNG by default. The docs page carries the note "Clipdrop is part of Jasper now" (Clipdrop API docs, checked 2026-12-02).

import requests

r = requests.post(
    "https://clipdrop-api.co/remove-background/v1",
    files={"image_file": ("car.jpg", open("car.jpg", "rb"), "image/jpeg")},
    headers={"x-api-key": "YOUR_API_KEY"},
)
r.raise_for_status()
open("result.png", "wb").write(r.content)
  • Where it wins: a default of 60 requests per minute per key and 100 free credits for development.

  • Where it falls short: the page gives no price per credit, and it says to contact the team for an API key and for more credits. Clipdrop was not part of Bria's benchmark.

  • When to shortlist it: shortlist it if you already hold a key and want a one request call.

What does each route return in Python?

The Bria API returns a URL, Photoroom and Clipdrop return image bytes, and the local routes return a PIL image or a mask. That decides how much glue code you write.

  • Route: Bria API; What you get back: result.image_url, a temporary link to download; Documented input limits: JPEG, PNG, WEBP

  • Route: Photoroom API; What you get back: PNG bytes; Documented input limits: 50 MB, 6,000 px on the widest side

  • Route: Clipdrop API; What you get back: PNG bytes by default; Documented input limits: 25 megapixels, 30 MB

  • Route: rembg; What you get back: PIL image, bytes or NumPy array, matching the input; Documented input limits: Not stated in the README

  • Route: BiRefNet; What you get back: A mask you apply with putalpha; Documented input limits: Example resizes to 1024 x 1024

Source: each route's docs or card, checked 2026-12-02.

  • Save every cutout as PNG, because JPEG has no alpha channel.

  • Bria result URLs are temporary, so download them at once.

Which routes can you use commercially?

Check the license of the weights and the terms of each service, because rembg's MIT license does not cover the model it loads. This is a summary of published terms, not legal advice.

  • rembg: MIT code. The default model, bria-rmbg (RMBG 2.0), is CC BY-NC 4.0. Other models link to their own source projects.

  • BiRefNet: MIT on the model card.

  • RMBG 2.0 and RMBG 3.0 weights: RMBG 2.0 is CC BY-NC 4.0 with commercial use needing a license from Bria, and RMBG 3.0 is CC BY-NC 4.0 with commercial use needing a separate agreement with Bria.

  • Bria API: the commercial path for RMBG 3.0 at $0.018 per image.

  • Photoroom and Clipdrop: read each vendor's service terms. This guide did not review them.

Which Python route should you choose?

  • Choose the Bria API with RMBG 3.0 if the code ships to users, you have no GPU and you want the route that ranked first in Bria's benchmark.

  • Choose rembg if you run scripts on your own hardware and can check the model license.

  • Choose BiRefNet if you want MIT-licensed weights and will write the pre and post processing.

  • Choose Photoroom if you want a one-request call that returns bytes, at $0.02 per image.

  • Choose Clipdrop if you already hold a key and need a plain multipart call.

Related posts

FAQs

Pick one of five routes. Call a hosted API such as the Bria API with RMBG 3.0 through bria-client, the Photoroom API or the Clipdrop API with requests. Or run a model on your own machine with rembg or BiRefNet through transformers. Save the result as PNG, because JPEG has no alpha channel. Bria's benchmark ranked RMBG 3.0 first of 6 models.

rembg installs with pip install rembg[cpu] and exposes remove(), which takes a PIL image, bytes or a NumPy array and returns the same kind of object. It also runs as a CLI, an HTTP server or a Docker container. The code is MIT licensed, but its default model, bria-rmbg (RMBG 2.0), is CC BY-NC 4.0, so commercial use needs a license from Bria. Check other models too.

The rembg code is MIT licensed, but the license of the model matters too. rembg's default model is RMBG 2.0, released under CC BY-NC 4.0, so commercial use needs a license from Bria. Other models link to their own source projects. Read the license of the exact model before you ship, and treat this as a summary, not legal advice.

Bria lists $0.018 per image for background removal with RMBG 3.0, checked 2026-11-29, and 100 free generations on the Free plan. Photoroom's Basic plan costs $0.02 per image, checked 2026-12-02, with 10 free production calls. The difference is $0.002 per image. Clipdrop's API page shows no price per credit, and rembg and BiRefNet have no per-image fee on your own hardware.

Follow us on social media

discord
Social media logo
Social media card
Social media logo
Social media card
Social media logo