A lightning-fast, drag-and-drop command-line tool that removes backgrounds from images locally.
Unlike standard web-based removers that compress your images or struggle with complex edges, this script utilizes the state-of-the-art BiRefNet model and intelligent memory management to achieve pixel-perfect cutouts right on your machine.
- Smart Processing Modes:
- [1] PRO QUALITY: Uses Alpha Matting to rescue fine details like hair, fur, and semi-transparent edges. Automatically scales ultra-massive images to a safe 2000px limit to prevent RAM overflows.
- [2] FAST / SAFE: Disables Alpha Matting for lightning-fast processing and minimal RAM usage. Scales to 1080px. Best for standard, hard-edged objects.
- Drag-and-Drop Interface: Just drag single files or entire folders directly into your terminal window.
- Batch Processing: Drop a folder, and the script will automatically find and process every supported image inside it.
- Lossless Output: Saves a clean, transparent
_nobg.pngright next to your original file.
This tool is configured to use the high-quality birefnet-general model instead of standard lightweight models.
- First Run: The script will automatically download the BiRefNet model (~400MB) the very first time you launch it.
- RAM Usage: Doing complex math (Alpha Matting) on ultra-high-resolution images can demand 8GB+ of system RAM. The built-in auto-resizer ensures your machine stays stable without sacrificing visual quality.
Below is a comparison of a complex image processed using the Pro Quality mode. Notice the preservation of fine details.
| Original | Background Removed |
|---|---|
![]() |
![]() |
1. Clone the repository
git clone https://github.com/RZ-Logic/Background-Remover.git
cd background-remover2. Create a virtual environment (Recommended)
python -m venv venv
# On Windows:
venv\Scripts\activate
# On Mac/Linux:
source venv/bin/activate3. Install the dependencies
pip install -r requirements.txt🚀 How to Use Simply run the Python script. The tool stays open and waits for you to drag and drop files directly into your terminal.
python bg_cli.py-
Single Files: Drag and drop an image (JPG, PNG, WEBP) to process it.
-
Batch Processing: Drag and drop an entire folder, and the script will automatically find and process every image inside it.
-
Lossless Output: All images are saved in the same directory as the original with a _nobg.png suffix, preserving full transparency and resolution.
-
Type done, quit, or exit in the terminal to close the program.

