Skip to content

RZ-Logic/Background-Remover

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✂️ Pro AI Background Remover (CLI)

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.

✨ Features

  • 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.png right next to your original file.

⚠️ Performance Note: Heavy Model & Memory

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.

✨ Results

Below is a comparison of a complex image processed using the Pro Quality mode. Notice the preservation of fine details.

Original Background Removed
Original Image Processed Image

⚙️ Installation

1. Clone the repository

git clone https://github.com/RZ-Logic/Background-Remover.git
cd background-remover

2. Create a virtual environment (Recommended)

python -m venv venv
# On Windows:
venv\Scripts\activate
# On Mac/Linux:
source venv/bin/activate

3. 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.

About

High-precision local background removal using BiRefNet. A dual-mode CLI and Streamlit implementation designed for secure, high-resolution image processing without third-party data storage

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages