A Python project that removes backgrounds from images using the rembg library.
This project uses the powerful rembg library to automatically detect and remove backgrounds from image files. It's useful for:
- Creating transparent PNGs from regular photos
- Batch processing images
- Product photography editing
- Profile pictures
- Automatic background removal using AI
- Supports various image formats (JPG, PNG, etc.)
- Simple command-line interface
- Error handling and status messages
- Python 3.7+
- rembg library
- PIL/Pillow
- Clone this repository:
git clone https://github.com/YOUR_USERNAME/photo-background-remover.git
cd photo-background-remover- Install dependencies:
pip install rembg pillowEdit test_rembg.py and update the paths:
in_path = r'path/to/your/image.jpg'
out_path = r'path/to/output/image_no_bg.png'Then run:
python test_rembg.pyThe script will:
- Read the input image
- Remove the background
- Save the result as a PNG file with transparency
- Input:
download.jpg - Output:
download_no_bg.png(transparent background)
test_rembg.py- Main script for removing backgroundshello.py- Simple test filefirstp.py- Additional utility file
MIT License - feel free to use this project for personal or commercial purposes.
- The first run may take longer as the model is downloaded
- The process requires a good amount of memory
- For best results, use clear images with distinct subjects