AI Personal Learning
and practical guidance

BEN2: Deep learning model for fast background removal from images, videos

General Introduction

BEN2 (Background Erase Network 2) is a deep learning model developed by Prama LLC that specializes in automatically removing the background from an image and generating a foreground image. The model employs an innovative Confidence Guided Matting (CGM) pipeline to process pixels with lower confidence in the base model through a refinement network, resulting in higher accuracy foreground segmentation.BEN2 was trained on DIS5k and Prama LLC's 22K proprietary segmentation dataset, and performs excellently, especially in hair keying, 4K processing, object segmentation and edge refinement. Its installation package is only 1.13GB, and officially deployed instances are capable of keying a 1080p image in less than 6 seconds, while processing a 4K image takes about 20 seconds.

Related Recommendations:removebg: remove picture background with one click, removebg online free Chinese version


BEN2: Deep Learning Model for Automatic Background Removal and Foreground Segmentation-1

BEN2 Remove Image Background Effect

 

BEN2: Deep Learning Model for Automatic Background Removal and Foreground Segmentation-1

BEN2 removes the video background effect, note the microphone position

 

Function List

  • Background Removal: Automatically removes the background from the image and generates a binary mask and foreground image.
  • foreground segmentation: High-precision foreground segmentation for a variety of complex scenes.
  • CUDA Support: Supports GPU acceleration to boost processing speed.
  • Simple API: Provides a clean API for easy integration into various applications.
  • High Resolution Processing: Supports 4K image processing for high resolution requirements.
  • Edge refinement: Enhance segmentation accuracy by processing edges through a fine-grained network.
  • Rapid processing: The official deployment example was able to key 1080p images in 6 seconds, and 4K images were processed in about 20 seconds.

 

Using Help

Installation process

  1. Cloning Warehouse:
   git clone https://huggingface.co/PramaLLC/BEN2
cd BEN2
  1. Install the dependencies:
   pip install -r requirements.txt

Usage Process

  1. Import the necessary libraries and models:
   from PIL import Image
import torch
from model import BEN_Base
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = BEN_Base().to(device).eval()
model.load_state_dict(torch.load('BEN_Base.pth'))
  1. Load the image and perform inference:
   image = Image.open('path_to_image.png')
mask, foreground = model.inference(image)
mask.save('mask.png')
foreground.save('foreground.png')

Main function operation flow

  1. Background Removal::
    • After loading the image, the model automatically generates a background mask and a foreground image.
    • The mask image is saved asmask.pngThe foreground image is saved asforeground.pngThe
  2. foreground segmentation::
    • The model passes through the Confidence Guided Matting (CGM) pipeline to accurately segment the foreground.
    • Ideal for complex backgrounds and detail-rich images such as hair, edges, etc.
  3. High Resolution Processing::
    • Supports 4K image processing to ensure the segmentation effect of high-resolution images.
    • Suitable for application scenarios that require high precision and quality image processing.
  4. Edge refinement::
    • Enhance segmentation accuracy by processing edges through a fine-grained network.
    • Especially suitable for images that require fine edge processing, such as product photos, portraits, etc.
  5. Rapid processing::
    • The official deployment example is capable of keying 1080p images in 6 seconds, and 4K images are processed in about 20 seconds.
    • Ideal for application scenarios where a large number of images need to be processed quickly.
May not be reproduced without permission:Chief AI Sharing Circle " BEN2: Deep learning model for fast background removal from images, videos

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish