File size: 2,547 Bytes
5d5bbb6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
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