withoutbg/withoutbg-python

Python SDK for local and cloud background removal (pip install withoutbg)

What it solves

It provides a simple way to remove backgrounds from images using Python, offering a flexible choice between running a model locally for privacy and cost, or using a high-quality cloud API for better precision on complex details like hair and fur.

How it works

The library allows users to switch between two modes:

  • Local Mode: Uses an ONNX bundle (based on DINOv3, Depth Anything V2, and BiRefNet) that runs on CPU or GPU. A router determines whether to use a specialized matting model for fine details or a segmentation model for hard objects.
  • Cloud Mode: Connects to the withoutBG API for professional-grade results without requiring local infrastructure.

Who it’s for

Developers building scripts, notebooks, backends, or batch processing jobs who need to automate image background removal.

Highlights

  • Hybrid Approach: One API for both local open-weights inference and cloud-based processing.
  • Batch Processing: Optimized for processing multiple images by loading the model once.
  • Privacy-First: Local mode operates entirely offline after the initial weight download.
  • CLI Tool: Includes a command-line interface for quick background removal without writing code.
  • PIL Integration: Returns images as PIL Image objects in RGBA mode for easy compositing.

Related

  • Project
  • Project
  • Project
  • Project
  • Project