R M B G 2.0

briaai

Introduction

The BRIA RMBG v2.0 model is a state-of-the-art background removal tool developed by BRIA AI. It significantly enhances the capabilities of its predecessor, RMBG v1.4, by efficiently segmenting the foreground from the background across various image categories. This model is designed for commercial use, supporting enterprise-level content creation with a focus on content safety, legally licensed datasets, and bias mitigation. It is available for non-commercial use under specific licensing terms.

Architecture

RMBG-2.0 is built on the BiRefNet architecture, which is enhanced with a proprietary dataset and training regimen. This advanced architecture and dataset combination provides improved accuracy and effectiveness in background removal tasks. The model leverages the Bilateral Reference for High-Resolution Dichotomous Image Segmentation approach.

Training

The model was trained on a dataset of over 15,000 high-resolution, manually labeled images. The dataset is carefully balanced across various categories, including different genders, ethnicities, and disabilities, ensuring versatility and minimizing bias. The distribution includes a mix of objects, people, animals, and text, with both photorealistic and non-photorealistic images.

Guide: Running Locally

Basic Steps

  1. Install Requirements:

    • torch
    • torchvision
    • pillow
    • kornia
    • transformers
  2. Load the Model:

    from transformers import AutoModelForImageSegmentation
    
    model = AutoModelForImageSegmentation.from_pretrained('briaai/RMBG-2.0', trust_remote_code=True)
    model.to('cuda')
    
  3. Prepare the Image:

    from PIL import Image
    from torchvision import transforms
    
    image = Image.open(input_image_path)
    transform_image = transforms.Compose([...])
    input_images = transform_image(image).unsqueeze(0).to('cuda')
    
  4. Predict and Save:

    with torch.no_grad():
        preds = model(input_images)[-1].sigmoid().cpu()
    pred_pil = transforms.ToPILImage()(preds[0].squeeze())
    pred_pil.save("no_bg_image.png")
    

Cloud GPUs

For enhanced performance, especially with large datasets or high-resolution images, consider using cloud GPUs such as those provided by AWS, Google Cloud, or Azure.

License

The RMBG v2.0 model is licensed under the Creative Commons license for non-commercial use. Commercial usage requires a separate agreement with BRIA AI. For detailed licensing terms, visit the BRIA AI license agreement.

More Related APIs in Image Segmentation