Rembg removes image backgrounds using AI models. It runs as a command-line tool, Python library, HTTP server, or Docker container. Supports CPU and GPU backends with multiple model options including u2net, SAM, and cloud APIs. Requires Python 3.11 to 3.13.
Install & use
Install
pip install "rembg[cpu,cli]"
Usage
rembg i path/to/input.png path/to/output.png
danielgatis/rembg is a third-party open-source project, listed here from public GitHub data. ImuTechz did not write it and has not reviewed or security-audited its code. Read the source and its permissions before you install or run it.
Features
CLI with subcommands for single files, batch folders, HTTP server, and model management
Python library for programmatic background removal
Multiple model support: u2net, u2netp, SAM, custom ONNX models, and cloud APIs
Alpha matting and color decontamination for edge refinement
CPU, NVIDIA CUDA, and AMD ROCm GPU acceleration options
HTTP server mode for API access
Best for
Removing backgrounds from single images or batches
Integrating background removal into Python applications
Running a local HTTP API for background removal
Processing images with transparent backgrounds for design workflows
Pros
Multiple interfaces: CLI, library, server, Docker
Supports various hardware backends (CPU, CUDA, ROCm)
Choice of models including SAM for prompt-based segmentation