You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lead with visual results and the three-line API, install via uv,
and briefly route readers to Docker, Mac, GIMP, and Hugging Face.
Co-authored-by: Cursor <cursoragent@cursor.com>
**Remove backgrounds in Python. Free locally, or use the cloud API.**
11
+
Same API for both paths: run open weights on your machine (private, offline, unlimited) or call the Cloud API (sharper edges on hair and fur, no local GPU). Built for scripts, notebooks, backends, and batch jobs.
12
12
13
-
Two modes that share the same API — run the open-weights model locally (free, private, offline) or call the cloud API (better quality, no GPU, pay per image). Switch with one line of code.
result.save("output.webp") # WebP — also supports transparency
134
-
result.save("output.jpg") # JPEG — transparency is dropped silently
147
+
model = WithoutBG.open_weights()
148
+
fg = model.remove_background("subject.jpg")
149
+
bg = Image.open("background.jpg")
150
+
bg.paste(fg, (0, 0), fg) # alpha used as mask
151
+
bg.save("composite.png")
135
152
```
136
153
137
154
## Configuration
138
155
139
156
| Environment variable | Effect |
140
157
|---|---|
141
-
|`WITHOUTBG_API_KEY`| API key for Cloud mode (alternative to passing `api_key=`) |
158
+
|`WITHOUTBG_API_KEY`| API key for Cloud mode (alternative to `api_key=`) |
142
159
|`WITHOUTBG_MODEL_PATH`| Path to a local `.onnx` file (skips Hugging Face download) |
143
160
144
-
When using `WITHOUTBG_MODEL_PATH`, the sidecar metadata file (`withoutbg-open-weights.onnx.json`) must be in the same directory.
161
+
When using `WITHOUTBG_MODEL_PATH`, keep the sidecar metadata file (`withoutbg-open-weights.onnx.json`) next to the ONNX file.
145
162
146
163
## Performance
147
164
148
165
|| Local | Cloud |
149
166
|---|---|---|
150
-
| First run | 5–10s (~455MB download) | 1–3s |
167
+
| First run | 5–10s (~455 MB download) | 1–3s |
151
168
| Per image | 2–5s | 1–3s |
152
-
| RAM |~2GB | None |
153
-
| Disk |455MB (one-time cache) | None |
169
+
| RAM |~2 GB | None (client)|
170
+
| Disk |455 MB (one-time cache) | None |
154
171
155
-
Keep the model object alive across all images in a batch. Recreating it for every image reloads the weights each time.
172
+
## Error handling
173
+
174
+
```python
175
+
from withoutbg import WithoutBG, APIError, WithoutBGError
176
+
177
+
try:
178
+
model = WithoutBG.api()
179
+
result = model.remove_background("photo.jpg")
180
+
result.save("output.png")
181
+
except APIError as e:
182
+
print(f"API error: {e}")
183
+
except WithoutBGError as e:
184
+
print(f"Processing error: {e}")
185
+
```
156
186
157
187
## Troubleshooting
158
188
159
-
**Model download fails:**The weights are pulled from [Hugging Face](https://huggingface.co/withoutbg/withoutbg-openweights-onnx) on first run (~455MB). Check your connection, or set `WITHOUTBG_MODEL_PATH` to a local copy.
189
+
**Model download fails:**Weights come from [Hugging Face](https://huggingface.co/withoutbg/withoutbg-openweights-onnx) on first local run (~455 MB). Check your connection, or set `WITHOUTBG_MODEL_PATH` to a local copy.
160
190
161
-
**Out of memory:**The local model uses ~2GB of RAM. Reduce batch size or switch to Cloud mode.
191
+
**Out of memory:**Local mode uses ~2 GB of RAM. Process fewer images at once, or switch to Cloud.
162
192
163
193
**Import error:**
164
194
165
195
```bash
166
196
which python
167
-
pip list | grep withoutbg
168
-
pip install withoutbg
197
+
uv pip list | grep withoutbg
198
+
uv add withoutbg
169
199
```
170
200
171
201
**API key rejected:** Get a key at [withoutbg.com](https://withoutbg.com). Set `export WITHOUTBG_API_KEY=sk_your_key`.
172
202
173
-
**Migrating from older API names** (`WithoutBG.opensource()`, `ProAPI`): see [docs/MIGRATION.md](docs/MIGRATION.md).
203
+
**Migrating from older names** (`WithoutBG.opensource()`, `ProAPI`): see [docs/MIGRATION.md](docs/MIGRATION.md).
174
204
175
-
## Error handling
205
+
## More than Python
176
206
177
-
```python
178
-
from withoutbg import WithoutBG, APIError, WithoutBGError
207
+
This package is the **in-process** path — embed withoutBG in your Python code or CLI. Same open-weights technology powers the rest of the ecosystem; pick the surface that matches your workflow:
179
208
180
-
try:
181
-
model = WithoutBG.api()
182
-
result = model.remove_background("photo.jpg")
183
-
result.save("output.png")
184
-
except APIError as e:
185
-
print(f"API error: {e}")
186
-
except WithoutBGError as e:
187
-
print(f"Processing error: {e}")
209
+
| Surface | Choose when |
210
+
|---|---|
211
+
|**[Docker / self-host](https://github.com/withoutbg/withoutbg-inference)**| You want an HTTP API or browser UI on your own server (CPU or NVIDIA GPU) |
212
+
|**[Mac app](https://withoutbg.com/mac)**| You want a native desktop cutout tool, with an optional Local API for plugins and scripts |
213
+
|**[GIMP plugin](https://github.com/withoutbg/withoutbg-gimp)**| You edit in GIMP 3 and want a private, mask-first workflow via Mac Local API or Docker |
214
+
|**[Hugging Face](https://huggingface.co/withoutbg/withoutbg-openweights-onnx)** · **[Space](https://huggingface.co/spaces/withoutbg/withoutbg)**| You want to try a demo or download the ONNX weights directly |
215
+
|**[Cloud API](https://withoutbg.com/pro-model)**| You need maximum quality without running inference yourself |
216
+
217
+
```bash
218
+
# Self-host the open-weights web app (CPU)
219
+
docker run --rm -p 8080:8080 withoutbg/withoutbg-openweights-v3-app-cpu
188
220
```
189
221
190
222
## Model
191
223
192
-
The withoutBG Open Weights Model is a unified ONNX model hosted at [withoutbg/withoutbg-openweights-onnx](https://huggingface.co/withoutbg/withoutbg-openweights-onnx). Licensed under the [withoutBG Open Model License](https://withoutbg.com/open-model/license) (Apache 2.0 for withoutBG portions; Meta DINOv3 License for DINOv3 backbone weights). Built with DINOv3.
224
+
The withoutBG Open Weights Model is a unified ONNX graph hosted at [withoutbg/withoutbg-openweights-onnx](https://huggingface.co/withoutbg/withoutbg-openweights-onnx). Depth, segmentation, matting, and refinement run in one pass. Built with DINOv3.
225
+
226
+
Licensed under the [withoutBG Open Model License](https://withoutbg.com/open-model/license) (Apache 2.0 for withoutBG portions; Meta DINOv3 License for DINOv3 backbone weights).
193
227
194
228
## Development
195
229
196
230
```bash
197
231
uv sync --extra dev
198
-
# or: pip install -e ".[dev]"
199
232
200
233
make test-fast # fast unit tests
201
234
make quality # lint + format + type check
@@ -204,16 +237,6 @@ make test # full suite (downloads model on first run)
204
237
205
238
See [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide.
206
239
207
-
## Related projects
208
-
209
-
Need a browser UI or HTTP API instead of Python?
210
-
211
-
[**withoutbg-inference**](https://github.com/withoutbg/withoutbg-inference) — Docker images (CPU + GPU), FastAPI inference service, and optional web UI built on the same open-weights model.
212
-
213
-
```bash
214
-
docker run --rm -p 8080:8080 withoutbg/withoutbg-openweights-v3-app-cpu
215
-
```
216
-
217
240
## License
218
241
219
242
This Python SDK is licensed under Apache License 2.0. See [LICENSE](LICENSE).
0 commit comments