What is BiRefNet?

BiRefNet is a model used for background removal and matting.

Formally, it is a model for Dichotomous Image Segmentation (DIS), which means splitting an image into foreground and background.

It is not like SAM, where you specify "this point", "this box", or "this object" to create a mask. Instead, it is good at producing high-quality cutout masks from subjects with complex details, such as hair or plants.


Model Download

📂ComfyUI/
└── 📂models/
    └── 📂background_removal/
        └── birefnet.safetensors

workflow

Cut Out the Foreground

BiRefNet.json
  • Use Load Background Removal Model to load birefnet.safetensors.
  • Input the image and model into Remove Background to output a background-removal MASK.
  • Use Join Image with Alpha when you want an image with a transparent background.
    • If you use the mask as-is, the foreground becomes transparent, so insert Invert Mask first.

Fill the Background

The workflow above makes the background transparent, but for preprocessing in image generation or analysis, it is often easier to fill the background with a solid color.

BiRefNet_fill.json
  • Input the original image, inverted mask, and solid-color image into Image Composite Masked.
  • Only the masked background area is replaced with the solid-color image.
  • See Layer Composite for details.