File size: 8,494 Bytes
00e2d9a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
---
license: other
license_name: bria-rmbg-2.0
license_link: https://creativecommons.org/licenses/by-nc/4.0/deed.en
pipeline_tag: image-segmentation
tags:
- remove background
- background
- background-removal
- Pytorch
- vision
- legal liability
- transformers
- transformers.js
extra_gated_description: >-
Bria AI Model weights are open source for non commercial use only, per the
provided [license](https://creativecommons.org/licenses/by-nc/4.0/deed.en).
extra_gated_heading: Fill in this form to immediatly access the model for non commercial use
extra_gated_fields:
Name: text
Email: text
Company/Org name: text
Company Website URL: text
Discord user: text
I agree to BRIA’s Privacy policy, Terms & conditions, and acknowledge Non commercial use to be Personal use / Academy / Non profit (direct or indirect): checkbox
---
# BRIA Background Removal v2.0 Model Card
<p align="center"><img src="https://platform.bria.ai/assets/Bria-logo-5e0c53b1.svg" alt="BRIA Logo" width="200" /></p>
<!-- RMBG Card wrapper -->
<div class="rmbg-card" style="position: relative; border-radius: 12px; overflow: hidden;">
<!-- FIBO Promo Banner (Top) -->
<a
href="https://huggingface.co/briaai/FIBO"
target="_blank"
rel="noopener"
aria-label="Explore FIBO on Hugging Face"
style="
position: absolute;
top: 0;
left: 0;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
background: linear-gradient(90deg, #fff6b7 0%, #fde047 100%);
color: #1f2937;
text-decoration: none;
font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
font-weight: 600;
font-size: 13px;
padding: 10px 0;
border-bottom: 1px solid rgba(0,0,0,0.08);
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
z-index: 10;
">
<img
src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg"
alt="Hugging Face"
width="18"
height="18"
style="display:block"
/>
<span>✨ Discover <strong>FIBO</strong> on Hugging Face</span>
</a>
<!-- ... your RMBG content below ... -->
<p align="center">
💜 <a href="https://go.bria.ai/46gzn20"><b>Bria AI</b></a>   |   🤗 <a href="https://huggingface.co/briaai/">Hugging Face</a>    |    📑 <a href="https://blog.bria.ai/">Blog</a>   
<br>
🖥️ <a href="https://huggingface.co/spaces/briaai/BRIA-RMBG-2.0">Demo</a>  |    <a href="https://github.com/Bria-AI/RMBG-2.0">Github</a>  
</p>
RMBG v2.0 is our new state-of-the-art background removal model significantly improves RMBG v1.4. The model is designed to effectively separate foreground from background in a range of
categories and image types. This model has been trained on a carefully selected dataset, which includes:
general stock images, e-commerce, gaming, and advertising content, making it suitable for commercial use cases powering enterprise content creation at scale.
The accuracy, efficiency, and versatility currently rival leading source-available models.
It is ideal where content safety, legally licensed datasets, and bias mitigation are paramount.
Developed by BRIA AI, RMBG v2.0 is available as a source-available model for non-commercial use.
### Get Access
Bria RMBG2.0 is availabe everywhere you build, either as source-code and weights, ComfyUI nodes or API endpoints.
- **Purchase:** To purchase a commercial license for RMBG V2.0 **or** an API package [Click Here](https://share-eu1.hsforms.com/2sj9FVZTGSFmFRibDLhr_ZAf4e04).
- **API Endpoint**: [Bria.ai](https://docs.bria.ai/image-editing/v2-endpoints/background-remove), [fal.ai](https://fal.ai/models/fal-ai/bria/background/remove), [Replicate](https://replicate.com/bria/remove-background)
- **ComfyUI**: [Use it in workflows](https://github.com/Bria-AI/ComfyUI-BRIA-API)
- **GitHub**: [github.com/Bria-AI/RMBG-2.0](https://github.com/Bria-AI/RMBG-2.0)
For more information, please visit our [website](https://bria.ai/).
Join our [Discord community](https://discord.gg/Nxe9YW9zHS) for more information, tutorials, tools, and to connect with other users!
[CLICK HERE FOR A DEMO](https://huggingface.co/spaces/briaai/BRIA-RMBG-2.0)

## Model Details
#####
### Model Description
- **Developed by:** [BRIA AI](https://bria.ai/)
- **Model type:** Background Removal
- **License:** [Creative Commons Attribution–Non-Commercial (CC BY-NC 4.0)](https://creativecommons.org/licenses/by-nc/4.0/deed.en)
- The model is released under a CC BY-NC 4.0 license for non-commercial use.
- Commercial use is subject to a commercial agreement with BRIA. Available [here](https://share-eu1.hsforms.com/2sj9FVZTGSFmFRibDLhr_ZAf4e04)
- **Model Description:** BRIA RMBG-2.0 is a dichotomous image segmentation model trained exclusively on a professional-grade dataset. The model output includes a single-channel 8-bit grayscale alpha matte, where each pixel value indicates the opacity level of the corresponding pixel in the original image. This non-binary output approach offers developers the flexibility to define custom thresholds for foreground-background separation, catering to varied use cases requirements and enhancing integration into complex pipelines.
- **BRIA:** Resources for more information: [BRIA AI](https://bria.ai/)
## Training data
Bria-RMBG model was trained with over 15,000 high-quality, high-resolution, manually labeled (pixel-wise accuracy), fully licensed images.
Our benchmark included balanced gender, balanced ethnicity, and people with different types of disabilities.
For clarity, we provide our data distribution according to different categories, demonstrating our model’s versatility.
### Distribution of images:
| Category | Distribution |
| -----------------------------------| -----------------------------------:|
| Objects only | 45.11% |
| People with objects/animals | 25.24% |
| People only | 17.35% |
| people/objects/animals with text | 8.52% |
| Text only | 2.52% |
| Animals only | 1.89% |
| Category | Distribution |
| -----------------------------------| -----------------------------------------:|
| Photorealistic | 87.70% |
| Non-Photorealistic | 12.30% |
| Category | Distribution |
| -----------------------------------| -----------------------------------:|
| Non Solid Background | 52.05% |
| Solid Background | 47.95%
| Category | Distribution |
| -----------------------------------| -----------------------------------:|
| Single main foreground object | 51.42% |
| Multiple objects in the foreground | 48.58% |
## Qualitative Evaluation
Open source models comparison


### Architecture
RMBG-2.0 is developed on the [BiRefNet](https://github.com/ZhengPeng7/BiRefNet) architecture enhanced with our proprietary dataset and training scheme. This training data significantly improves the model’s accuracy and effectiveness for background-removal task.<br>
If you use this model in your research, please cite:
```
@article{BiRefNet,
title={Bilateral Reference for High-Resolution Dichotomous Image Segmentation},
author={Zheng, Peng and Gao, Dehong and Fan, Deng-Ping and Liu, Li and Laaksonen, Jorma and Ouyang, Wanli and Sebe, Nicu},
journal={CAAI Artificial Intelligence Research},
year={2024}
}
```
#### Requirements
```bash
torch
torchvision
pillow
kornia
transformers
```
### Usage
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
```python
from PIL import Image
import torch
from torchvision import transforms
from transformers import AutoModelForImageSegmentation
device = 'cuda' if torch.cuda.is_available() else 'cpu'
model = AutoModelForImageSegmentation.from_pretrained('briaai/RMBG-2.0', trust_remote_code=True).eval().to(device)
# Data settings
image_size = (1024, 1024)
transform_image = transforms.Compose([
transforms.Resize(image_size),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])
image = Image.open(input_image_path)
input_images = transform_image(image).unsqueeze(0).to(device)
# Prediction
with torch.no_grad():
preds = model(input_images)[-1].sigmoid().cpu()
pred = preds[0].squeeze()
pred_pil = transforms.ToPILImage()(pred)
mask = pred_pil.resize(image.size)
image.putalpha(mask)
image.save("no_bg_image.png")
```
</div>
|