Official PyTorch implementation of BiRefNet, a deep learning model for high-resolution dichotomous image segmentation, commonly used for background removal.
danielgatis/rembg
A tool that removes image backgrounds, usable as a CLI, Python library, HTTP server, or Docker container.
Open-source alternative to:Remove.bg
Adobe Photoshop
- Stars
- 25,127
- Forks
- 2,442
- Open issues
- 2
- Last commit
- 10 days ago
What is it?
Rembg removes the background from images, leaving the subject as a transparent cutout. It runs local ONNX segmentation models such as U2Net, ISNet, SAM and several BiRefNet variants, which are downloaded automatically on first use. Cloud backends (withoutBG and Atlas Cloud) are also available through the same interface.
The same functionality is exposed in four ways: a `rembg` CLI for single files, folders and FFmpeg RGB24 streams; a Python `remove()` function accepting bytes, PIL images or NumPy arrays; an HTTP server with an API and Gradio UI; and a Docker image with CPU or NVIDIA CUDA builds. CPU, NVIDIA GPU and AMD ROCm backends are selected at install time through onnxruntime variants.
For soft edges such as hair or fur, the project offers color decontamination (`-dc`), alpha matting (`-a`) and ViTMatte (`-vm`) as alternative refinement modes.
Key features
- 01Runs local ONNX models including U2Net, ISNet, SAM and BiRefNet variants.
- 02Offers CLI, Python library, HTTP server and Docker usage.
- 03Supports batch folder processing and a watch mode.
- 04Includes color decontamination and alpha matting for soft edges.
- 05Accepts input as bytes, PIL images or NumPy arrays.
- 06Provides optional cloud backends via withoutBG and Atlas Cloud.
Use cases
- Batch removing backgrounds from product photos for e-commerce listings.
- Adding a background-removal endpoint to a web service via the HTTP server.
- Extracting subjects from video frames by piping FFmpeg output into rembg.
- Creating transparent portraits with the portrait or human segmentation models.
Quick start
- 1
Install the CPU backend with CLI support
pip install "rembg[cpu,cli]" - 2
Remove the background from a local image
rembg i path/to/input.png path/to/output.png
Things to know
- Requires Python 3.11 to 3.13.
- GPU setup can be complicated and may need CUDA and cudnn-devel on NVIDIA systems.
- Some cloud models such as withoutBG and Atlas Cloud need an API key and are paid or credit-based.
Topics
FAQ
- What is rembg?
- A tool that removes image backgrounds, usable as a CLI, Python library, HTTP server, or Docker container. Rembg removes the background from images, leaving the subject as a transparent cutout. It runs local ONNX segmentation models such as U2Net, ISNet, SAM and several BiRefNet variants, which are downloaded automatically on first use. Cloud backends (withoutBG and Atlas Cloud) are also available through the same interface.
- Is rembg free to use? What license does it have?
- rembg is open source under the MIT license. Check the license terms before using it in commercial products.
- Is rembg still maintained?
- Actively maintained. The last commit to rembg was on Oct 10, 2026.
- What can I use rembg for?
- Batch removing backgrounds from product photos for e-commerce listings. Adding a background-removal endpoint to a web service via the HTTP server. Extracting subjects from video frames by piping FFmpeg output into rembg. Creating transparent portraits with the portrait or human segmentation models.
- How do I install rembg?
- Install the CPU backend with CLI support: pip install "rembg[cpu,cli]" Remove the background from a local image: rembg i path/to/input.png path/to/output.png
- Where can I get rembg?
- The source code and installation instructions are on GitHub: https://github.com/danielgatis/rembg
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Open-source background remover that runs entirely in the browser using WebGPU or WebAssembly, with no uploads.
Offline C++ tool that removes visible Gemini watermarks from images via reverse alpha blending, with GUI, CLI and batch modes.
Command-line tool and Python library that turns a whiteboard-style image into a CPU-rendered hand-drawn reveal MP4, optionally paced to narration.
Ultralytics YOLOv5, a PyTorch-based computer vision toolkit for object detection, instance segmentation and image classification with training and export.
Open-source browser automation that uses LLMs and computer vision to run web workflows on any site, extending Playwright with AI commands.