--- license: mit library_name: pytorch tags: - background-removal - image-segmentation - computer-vision - pytorch - foreground-extraction pipeline_tag: image-segmentation --- # Background Remover (BEN2 Base) **BEN2 Base** is a deep learning model for **automatic background removal** from images. The model predicts a **foreground segmentation mask** that can be used to remove or replace the background. This repository contains the pretrained weights: `BEN2_Base.pth` The model can be used in: - photo editing tools - product image processing - portrait segmentation - dataset preprocessing - AI image pipelines --- # Model Details | Property | Value | |--------|--------| | Model Name | BEN2 Base | | Task | Background Removal | | Architecture | Segmentation Network | | Framework | PyTorch | | File Size | 1.13 GB | | Input | RGB image | | Output | Foreground mask | --- # Repository Files | File | Description | |-----|-------------| | BEN2_Base.pth | Pretrained background removal model weights | --- # Installation Install required libraries: ```bash pip install torch torchvision pillow numpy opencv-python ``` --- # Usage Example Example inference using PyTorch. ```python import torch from PIL import Image import torchvision.transforms as transforms # Load model model = torch.load("BEN2_Base.pth", map_location="cpu") model.eval() # Preprocessing transform = transforms.Compose([ transforms.Resize((512, 512)), transforms.ToTensor() ]) image = Image.open("input.jpg").convert("RGB") input_tensor = transform(image).unsqueeze(0) # Inference with torch.no_grad(): output = model(input_tensor) mask = output.squeeze().cpu().numpy() ``` You can apply the mask to generate a **transparent PNG** or replace the background. --- # Example Workflow 1. Load an image 2. Resize and normalize 3. Run model inference 4. Generate segmentation mask 5. Remove background --- # Use Cases ### E-commerce Remove backgrounds from product images. ### Portrait Editing Create clean profile images. ### Content Creation Prepare images for thumbnails, ads, or designs. ### AI Pipelines Preprocess images for ML datasets. --- # Limitations - Performance may vary with extremely complex backgrounds. - Very small foreground objects may reduce segmentation quality. - Images should be resized for optimal results. --- # Training This repository provides **pretrained weights only**. --- # License Please verify the license before using the model in commercial applications. --- # Author Ashank Gupta