Background & CleanupOpen source codeZhengPeng7/BiRefNet

BiRefNet: Open Source AI Repository & Self-Hosting Guide

Bilateral Reference Network (BiRefNet) open-source dichotomous image segmentation model achieving sharp hair, glass, and fine-edge foreground mattes.

GitHub Stars
4,483 stars
Repository License
MIT
Last Push (UTC)
Nov 30, 2026
Check the repo's license. Model weights may have a different license.
git clone https://github.com/ZhengPeng7/BiRefNet.git
View on GitHub
Installpip install transformers torch && python -c "from transformers import AutoModelForImageSegmentation"

BiRefNet: Architecture & Practical Workflow

BiRefNet fuses multi-scale bilateral feature reconstruction with gradient supervision to outperform older U2-Net matting on complex transparent or hair-strand boundaries—available directly via Hugging Face Transformers, PyTorch, and ComfyUI/rembg.

Recommended End-to-End Pipeline

Load `ZhengPeng7/BiRefNet` via Hugging Face Transformers or ComfyUI nodes to generate crisp 1024px+ alpha masks for studio portraits and product cutouts.

Runtime Target
Self-Hosted / Python (GitHub)
Primary Users
Developers, Product photo workflows
Code License
MIT
Focus Topics
open-source, github, background-removal, segmentation, self-hosted

Quick Setup & Installation Steps

Platform target: Self-Hosted / Python (GitHub). Always verify environment variables and dependencies in the upstream repository README.

  1. 1Clone the repository from GitHub: `git clone https://github.com/ZhengPeng7/BiRefNet.git && cd BiRefNet`.
  2. 2Review the MIT license (Check the repo's license. Model weights may have a different license.) and note any separate terms on external model weights.
  3. 3Install or launch the project directly: `pip install transformers torch && python -c "from transformers import AutoModelForImageSegmentation"` (use an isolated Python virtualenv, Node workspace, or Docker volume so dependencies remain clean).
  4. 4Validate end-to-end behavior with a small sample input (Load `ZhengPeng7/BiRefNet` via Hugging Face Transformers or ComfyUI nodes to generate crisp 1024px+ alpha masks for studio portraits and product cutouts.)

Hardware & VRAM Notes

Hardware & VRAM guidance: Requires Python and a GPU for speed

GPU & VRAM

Requires Python and a GPU for speed

System RAM & Storage

16 GB–32 GB system RAM recommended plus 10 GB–40 GB free SSD space for container images, Python dependencies, and model weights.

Runtime Target

Self-Hosted / Python (GitHub)

Strengths & Best For

  • Accurate edges
  • Pretrained weights
  • Works in pipelines
  • Best suited for: Developers, Product photo workflows

Limitations & Caveats

  • Requires Python and a GPU for speed
  • Check the model license before commercial use
  • Check the repo's license. Model weights may have a different license.

3 Similar Tools on /tools (Watermark & Background)

Prefer a hosted web app instead of managing local weights or Docker containers? Explore these cloud alternatives.

Browse all tools
Self-Hosted BiRefNet vs. Hosted Alternatives (IOPaint (Lama Cleaner) & Remove.bg)
FactorBiRefNet (Self-Hosted)IOPaint (Lama Cleaner)Remove.bg
Execution & PrivacyRuns locally via Self-Hosted / Python (GitHub); data stays on your disk or private server.Hosted cloud web interface; zero local dependency setup required.Hosted cloud web interface; zero local dependency setup required.
Cost & QuotaMIT code; bound only by local CPU/GPU hardware.Open Source; subject to vendor free-tier limits or paid plans.Freemium; subject to vendor free-tier limits or paid plans.
Primary FitAccurate edges; Pretrained weights100% free and open-source image inpainting & watermark eraser powered by SOTA AI models.AI background removal for images. Instant 1-click transparent cutouts with free tier.
Key Trade-offRequires Python and a GPU for speedRequires internet access and vendor account/quota limits.Requires internet access and vendor account/quota limits.

Matching Ready-Made Prompts

All Prompts →

Customize variables in Live Prompt Studio for BiRefNet workflows.

Compare Alternatives

Compare Engine →

Compare BiRefNet side-by-side on setup ease, privacy, and role scorecards.

More Open Source Background & Cleanup Repositories

Frequently Asked Questions

What does BiRefNet do and how does it work?

BiRefNet (ZhengPeng7/BiRefNet) is an open-source background & cleanup project with 4,483 stars on GitHub. Bilateral Reference Network (BiRefNet) open-source dichotomous image segmentation model achieving sharp hair, glass, and fine-edge foreground mattes. BiRefNet fuses multi-scale bilateral feature reconstruction with gradient supervision to outperform older U2-Net matting on complex transparent or hair-strand boundaries—available directly via Hugging Face Transformers, PyTorch, and ComfyUI/rembg.

Is BiRefNet free to self-host and use commercially?

BiRefNet provides open source code licensed under MIT. Check the repo's license. Model weights may have a different license. Always verify both source code and model weight licenses in the GitHub repository before commercial deployment.

What hardware, runtime, or VRAM does BiRefNet require?

BiRefNet targets Self-Hosted / Python (GitHub). Typical installation runs via `pip install transformers torch && python -c "from transformers import AutoModelForImageSegmentation"`. Requires Python and a GPU for speed

How does self-hosting BiRefNet compare to hosted tools like IOPaint (Lama Cleaner)?

Self-hosting BiRefNet gives you full local data control, zero per-usage vendor fees, and customizable Self-Hosted / Python (GitHub) pipelines—at the cost of managing your own setup and compute. By contrast, IOPaint (Lama Cleaner) (Open Source) runs in the browser with no local installation, though usage quotas and cloud privacy policies apply.

Is BiRefNet actively maintained and what workflow fits it best?

Repository metadata records 4,483 stars on GitHub with the latest recorded push on Nov 30, 2026. Load `ZhengPeng7/BiRefNet` via Hugging Face Transformers or ComfyUI nodes to generate crisp 1024px+ alpha masks for studio portraits and product cutouts.