## Guide to Huggingface: RMBG v1.4

### Model Description

– **Developed by:** [BRIA AI](https://bria.ai/)
– **Model type:** Background Removal
– **License:** [bria-rmbg-1.4](https://bria.ai/bria-huggingface-model-license-agreement/)
– The model is released under an open-source license for non-commercial use.
– Commercial use is subject to a commercial agreement with BRIA. [Contact Us](https://bria.ai/contact-us) for more information.
– **Model Description:** BRIA RMBG 1.4 is a saliency segmentation model trained exclusively on a professional-grade dataset.
– **BRIA:** Resources for more information: [BRIA AI](https://bria.ai/)

### Training Data

The Bria-RMBG model was trained with over 12,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% |

#### Distribution of Image Types:

| Category | Distribution |
|——————–|—————|
| Photorealistic | 87.70% |
| Non-Photorealistic | 12.30% |

#### Distribution of Background Types:

| Category | Distribution |
|——————–|—————|
| Non-Solid Background | 52.05% |
| Solid Background | 47.95% |

#### Distribution of Foreground Objects:

| Category | Distribution |
|——————————|—————|
| Single main foreground object | 51.42% |
| Multiple objects in the foreground | 48.58% |

### Qualitative Evaluation

[![Qualitative Evaluation](https://huggingface.co/briaai/RMBG-1.4/blob/main/results.png)](https://huggingface.co/briaai/RMBG-1.4/blob/main/results.png)

### Architecture

RMBG v1.4 is developed on the [IS-Net](https://github.com/xuebinqin/DIS) enhanced with our unique training scheme and proprietary dataset. These modifications significantly improve the model’s accuracy and effectiveness in diverse image-processing scenarios.

### Installation

“`bash
git clone https://huggingface.co/briaai/RMBG-1.4
cd RMBG-1.4/
pip install -r requirements.txt
“`

### Usage

“`python
from skimage import io
import torch, os
from PIL import Image
from briarmbg import BriaRMBG
from utilities import preprocess_image, postprocess_image
from huggingface_hub import hf_hub_download

model_path = hf_hub_download(“briaai/RMBG-1.4″, ‘model.pth’)
im_path = f”{os.path.dirname(os.path.abspath(__file__))}/example_input.jpg”

net = BriaRMBG()
device = torch.device(“cuda” if torch.cuda.is_available() else “cpu”)
net.load_state_dict(torch.load(model_path, map_location=device))
net.to(device)
net.eval()

model_input_size = [1024, 1024]
orig_im = io.imread(im_path)
orig_im_size = orig_im.shape[0:2]
image = preprocess_image(orig_im, model_input_size).to(device)

result = net(image)

result_image = postprocess_image(result[0][0], orig_im_size)

pil_im = Image.fromarray(result_image)
no_bg_image = Image.new(“RGBA”, pil_im.size, (0,0,0,0))
orig_image = Image.open(im_path)
no_bg_image.paste(orig_image, mask=pil_im)
no_bg_image.save(“example_image_no_bg.png”)
“`

For a live demo and more information, [CLICK HERE](https://huggingface.co/spaces/briaai/BRIA-RMBG-1.4)

Source link
**Huggingface BRIA RMBG v1.4 Background Removal Model Manual**

Welcome to the manual for using the Huggingface BRIA RMBG v1.4 background removal model. This model is designed to effectively separate foreground from background in a range of categories and image types. It has been trained on a carefully selected dataset, making it suitable for commercial use cases powering enterprise content creation at scale. This manual will guide you through the features, usage, and installation of the model.

**Features of RMBG v1.4:**

– State-of-the-art background removal model
– Trained on a diverse dataset including stock images, e-commerce, gaming, and advertising content
– Ideal for commercial use cases
– Open-source model for non-commercial use
– High accuracy, efficiency, and versatility
– Model accuracy and effectiveness rival leading open source models

**Model Description:**

– Developed by: BRIA AI
– Model type: Background Removal
– License: Open-source for non-commercial use
– Model Description: BRIA RMBG 1.4 is a saliency segmentation model trained exclusively on a professional-grade dataset.

**Training Data:**

The BRIA-RMBG model was trained with over 12,000 high-quality, high-resolution, manually labeled images. The dataset includes a balanced gender, ethnicity, and people with different types of disabilities. The distribution of images covers various categories, demonstrating the model’s versatility.

**Distribution of Images:**

The distribution of images covers different categories including objects only, people with objects/animals, people only, and more. It also includes the distribution of photorealistic and non-photorealistic images, solid background, non-solid background, and single main foreground object versus multiple objects in the foreground.

**Qualitative Evaluation:**

The model’s qualitative evaluation includes examples of the background removal results. You can view the results using the provided link.

**Architecture:**

RMBG v1.4 is developed based on the IS-Net architecture enhanced with a unique training scheme and proprietary dataset. These modifications significantly improve the model’s accuracy and effectiveness in diverse image-processing scenarios.

**Installation:**

To install the model, you can use the following commands:

“`bash
git clone https://huggingface.co/briaai/RMBG-1.4
cd RMBG-1.4/
pip install -r requirements.txt
“`

**Usage:**

To use the model in your Python code, you can follow the provided usage example. This includes importing necessary libraries, downloading the model, preprocessing and postprocessing the image, and using the model to remove the background from an image.

This manual provides an overview of the Huggingface BRIA RMBG v1.4 background removal model, including its features, installation, and usage. For more information and detailed instructions, you can refer to the provided links and resources.

We hope this manual helps you in using the RMBG v1.4 model effectively for your background removal needs. If you have any further questions or need assistance, please feel free to contact us at BRIA AI.

RMBG v1.4 is our state-of-the-art background removal model, 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 open source models.
It is ideal where content safety, legally licensed datasets, and bias mitigation are paramount.

Developed by BRIA AI, RMBG v1.4 is available as an open-source model for non-commercial use.

CLICK HERE FOR A DEMO
examples



Model Description

  • Developed by: BRIA AI

  • Model type: Background Removal

  • License: bria-rmbg-1.4

    • The model is released under an open-source license for non-commercial use.
    • Commercial use is subject to a commercial agreement with BRIA. Contact Us for more information.
  • Model Description: BRIA RMBG 1.4 is a saliency segmentation model trained exclusively on a professional-grade dataset.

  • BRIA: Resources for more information: BRIA AI



Training data

Bria-RMBG model was trained with over 12,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

examples



Architecture

RMBG v1.4 is developed on the IS-Net enhanced with our unique training scheme and proprietary dataset.
These modifications significantly improve the model’s accuracy and effectiveness in diverse image-processing scenarios.



Installation

git clone https://huggingface.co/briaai/RMBG-1.4
cd RMBG-1.4/
pip install -r requirements.txt



Usage

from skimage import io
import torch, os
from PIL import Image
from briarmbg import BriaRMBG
from utilities import preprocess_image, postprocess_image
from huggingface_hub import hf_hub_download

model_path = hf_hub_download("briaai/RMBG-1.4", 'model.pth')
im_path = f"{os.path.dirname(os.path.abspath(__file__))}/example_input.jpg"

net = BriaRMBG()
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
net.load_state_dict(torch.load(model_path, map_location=device))
net.to(device)
net.eval()    


model_input_size = [1024,1024]
orig_im = io.imread(im_path)
orig_im_size = orig_im.shape[0:2]
image = preprocess_image(orig_im, model_input_size).to(device)


result=net(image)


result_image = postprocess_image(result[0][0], orig_im_size)


pil_im = Image.fromarray(result_image)
no_bg_image = Image.new("RGBA", pil_im.size, (0,0,0,0))
orig_image = Image.open(im_path)
no_bg_image.paste(orig_image, mask=pil_im)
no_bg_image.save("example_image_no_bg.png")

The

tag in HTML is a container element used to group together elements and apply styles or scripts to them. Here are some potential use cases for the

tag without the presence of the

, , or tags:

1. Styling and Scripting: The

tag can be used to group together other HTML elements, and then specific styles or scripts can be applied to the entire group.

2. Data Visualization: The

tag can be used to create containers for data visualization components such as charts, graphs, and maps.

3. Modular Web Design: The

tag is essential for creating modular web designs where different sections of the page are enclosed in separate

containers.

4. Responsive Web Design: When building a responsive website, the

tag can be used to create flexible grid layouts where content adapts to different screen sizes.

5. Parallax Scrolling: The

tag can be used to create parallax scrolling effects where different layers of content move at different speeds as the user scrolls down the page.

6. Image Galleries: The

tag can be used to create containers for image galleries with thumbnails and lightbox effects for viewing larger images.

7. Embedding Media: The

tag can be used to create containers for embedding videos, audio players, or interactive multimedia content.

8. Form Structure: When creating forms, the

tag can be used to group form elements together, making it easier to apply styles or scripts to the entire form.

9. Navigation Menus: The

tag can be used to create navigation menus with dropdowns and submenus for easy navigation on the website.

10. Widget Containers: The

tag can be used to create containers for embedding widgets from external sources such as weather forecasts, news feeds, or social media plugins.

Overall, the

tag is a fundamental building block in HTML and can be used in a wide variety of ways to structure and organize content on a webpage without the need for specific document structure elements like

, , or tags.

2024-02-07T13:47:54+01:00