A beginner-friendly Python script that removes the background from any image using the rembg library. Just run the script, paste your image path, and get a clean transparent PNG, no complicated setup needed!
- Removes background from any image automatically
- Saves output as PNG with transparent background
- Automatically names the output file (adds
no_backgroundto original name) - Handles Windows file paths with quotes and backslashes
- Loop mode: remove multiple images in one session without restarting
- Python 3.7+
- rembg
- Pillow
1. Clone the repository
git clone https://github.com/JunayedMh/simple_imge_background_remover.git
cd removebg2. Install dependencies
pip install "rembg[cpu]" PillowIf you have an NVIDIA GPU, use
pip install "rembg[gpu]"for faster processing.
Run the script:
python removebg.pyThen follow the prompt:
--- Background Remover ---
Enter your image path here: G:\Photos\photo.jpg
Reading path as: G:\Photos\photo.jpg
Opening image...
Removing background... (this may take a few seconds)
✅ Done! Saved as: G:\Photos\_no_background.png
Do you want to remove another background? (y/n):
- Go to your image file
- Hold
Shift+ Right click - Click "Copy as path"
- Paste it into the terminal, the script handles the quotes automatically!
The output file is saved in the same folder as your original image with no_background added to the filename.
| Input | Output |
|---|---|
photo.jpg |
photo_no_background |
portrait.png |
portrait_no_background |
image.webp |
image_no_background.png |
No onnxruntime backend found error:
pip install "rembg[cpu]"File not found error:
- Make sure you paste the full path
- The script automatically removes quotes, so no need to delete them manually
- Try using forward slashes
/instead of backslashes\if issues persist