withoutbg/withoutbg-python
Python SDK for local and cloud background removal (pip install withoutbg)
What it solves
It provides a simple way to remove image backgrounds in Python, allowing users to choose between running a free, private local model or using a high-quality Cloud API for better results on complex details like hair and fur.
How it works
The library offers a unified API for two different execution paths:
- Local Mode: Uses an open-weights ONNX model (approximately 455 MB) downloaded from Hugging Face that runs on your CPU. It combines depth, segmentation, matting, and refinement in a single pass using a DINOv3 backbone.
- Cloud Mode: Connects to the withoutBG Cloud API for professional-grade quality without requiring local hardware resources.
Who it’s for
- Developers building scripts, notebooks, or backends that need automated background removal.
- Privacy-conscious users who prefer offline, unlimited processing on their own machine.
- Product builders who need high-precision cutouts for commercial applications via API.
Highlights
- Dual-path API: Switch between local and cloud processing with a single line of code.
- CPU-friendly: Local inference runs on CPU via ONNX, meaning no GPU is required.
- Batch processing: Includes a
remove_background_batchmethod to process multiple images efficiently by loading the model once. - PIL Integration: Returns images as PIL
Imageobjects in RGBA mode, making it easy to composite images or save them as PNG/WebP. - CLI Tool: Includes a command-line interface for quick background removal without writing code.
Related
- Project
- Project
- Project
- Project
- Project