BiRefNet
An open-source image segmentation model that runs locally for background removal and trimap-free matting, with PyTorch and ONNX support.

BiRefNet is an AI image segmentation model for developers and image workflow builders who need to separate subjects from backgrounds. It produces foreground masks for cutouts and has dedicated models for matting, where edges can include partial transparency.
- Background removal: Extract foreground subjects with general-purpose models, including high-resolution and lightweight variants.
- Trimap-free matting: Use general or portrait matting models without supplying a separate map marking foreground, background and uncertain areas.
- Specialized segmentation: Choose trained models for salient objects or camouflaged objects, and use box guidance to indicate the region of interest.
- Custom training: Fine-tune existing weights on your own labeled images for a particular subject type or segmentation task.
BiRefNet is open source under the MIT license and runs locally through Python and PyTorch, with ONNX models also available. Local inference processes images on your own hardware. The project reports NVIDIA GPU inference, and memory needs vary with the model, image resolution and numerical precision.
ComfyUI has an official integration for adding BiRefNet to image workflows. Third-party integrations also connect it to Invoke and Stable Diffusion WebUI. For browser-based processing, SafeResize runs the lightweight model through ONNX Runtime Web. The fal.ai API and Hugging Face hosted deployments process images on cloud infrastructure.