🎨 BiRefNet Background Removal API

State-of-the-art background removal using BiRefNet + edge cleanup.

Usage Options:

  1. Upload an image - Use the file upload
  2. Provide a URL - Enter image URL in the text box
  3. API Access - Use the API endpoint (see below)

Settings:

  • Model: birefnet-general (973MB)
  • Edge Cleanup: 1px alpha erosion + decontamination
  • Output: PNG with transparency
Model

📡 API Access

Use this Space as an API:

import requests

# Using URL
response = requests.post(
    "https://briancassidy-birefnet-background-removal.hf.space/api/predict",
    json={
        "data": [
            None,  # image_input (null for URL)
            "https://example.com/image.jpg",  # image_url
            266,  # width
            400   # height
        ]
    }
)
result = response.json()
# result['data'][0] = base64 image
# result['data'][1] = metadata JSON

Or use Gradio client:

from gradio_client import Client

client = Client("BrianCassidy/birefnet-background-removal")
result = client.predict(
    image_input=None,
    image_url="https://example.com/image.jpg",
    width=266,
    height=400
)

Performance

  • Processing time: 3-5 seconds per image
  • Handles all colors (white, light grey, everything)
  • Free tier (CPU) - sleeps after 30 min inactivity