birefnet.md

Birefnet API

API reference for Birefnet. bilateral reference framework (BiRefNet) for high-resolution dichotomous image segmentation (DIS)

Endpoint: POST https://fal.run/fal-ai/birefnet Endpoint ID: fal-ai/birefnet

Quick Start

import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
            print(log["message"])

result = fal_client.subscribe(
    "fal-ai/birefnet",
    arguments={
        "image_url": "https://storage.googleapis.com/falserverless/example_inputs/birefnet-input.jpeg"
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("fal-ai/birefnet", {
    input: {
        image_url: "https://storage.googleapis.com/falserverless/example_inputs/birefnet-input.jpeg"
    },
    logs: true,
    onQueueUpdate: (update) => {
        if (update.status === "IN_PROGRESS") {
            update.logs.map((log) => log.message).forEach(console.log);
        }
    },
});
console.log(result.data);
console.log(result.requestId);
curl --request POST \
  --url https://fal.run/fal-ai/birefnet \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "image_url": "https://storage.googleapis.com/falserverless/example_inputs/birefnet-input.jpeg"
}'

Input Schema

Output Schema

Input Example

{
  "model": "General Use (Light)",
  "operating_resolution": "1024x1024",
  "output_mask": false,
  "refine_foreground": true,
  "sync_mode": false,
  "image_url": "https://storage.googleapis.com/falserverless/example_inputs/birefnet-input.jpeg",
  "output_format": "png"
}

Output Example

{
  "image": {
    "content_type": "image/png",
    "file_name": "birefnet-output.png",
    "height": 1024,
    "url": "https://storage.googleapis.com/falserverless/example_outputs/birefnet-output.png",
    "width": 1024
  }
}

BiRefNet's bilateral reference framework delivers high-resolution dichotomous image segmentation with precision mask generation. Trading traditional single-pass segmentation for a dual-reference architecture, it achieves cleaner edge detection and handles complex foreground-background separation. Purpose-built for production workflows requiring pixel-perfect transparency extraction from product photos, portraits, and complex scenes.

Use Cases: E-commerce Product Photography | Portrait Editing | Design Asset Preparation


Performance

BiRefNet operates at production-ready speeds with three specialized model variants optimized for different accuracy-speed tradeoffs, processing images up to 2048x2048 resolution with optional mask output for downstream compositing workflows.

Metric Result Context
Operating Resolution Up to 2048x2048 4 megapixels max for high-fidelity edge detection
Model Variants 3 specialized models Light (fast), Heavy (accurate), Portrait (optimized)
Cost per Inference $0 per compute second Pay only for actual processing time
Output Formats PNG, WebP, GIF Transparency-preserving formats with optional mask export

Precision Segmentation Architecture

BiRefNet's bilateral reference framework processes images through parallel pathways, one analyzing global context, the other focusing on local detail, then synthesizes both for edge-accurate mask generation. This contrasts with standard single-encoder approaches that struggle with fine details like hair strands or transparent objects.

What this means for you:


Technical Specifications

Spec Details
Architecture BiRefNet Bilateral Reference Framework
Input Formats JPEG, PNG, WebP, GIF, AVIF via URL
Output Formats PNG (default), WebP, GIF with alpha channel
Operating Resolutions 1024x1024, 2048x2048
License Commercial use permitted

How It Stacks Up

BiRefNet v2 – BiRefNet v1 provides the core bilateral reference architecture with proven segmentation accuracy for general use cases. BiRefNet v2 builds on this foundation with enhanced edge detection refinement for challenging scenarios like fine hair detail or semi-transparent objects where the original model may struggle.

Limitations