This repository contains a Python script for removing backgrounds from images using the rembg
library. It provides a simple solution for automatically removing backgrounds from a collection of images.
Before running the script, make sure you have Python installed on your system. You can install the required Python modules using pip:
pip install rembg pillow
- Clone the repository to your local machine:
git clone https://github.com/your-username/your-repo.git
cd your-repo
-
Place your images in the
inputs
directory. These should be JPG files with the backgrounds you want to remove. -
Run the Python script
remove_background.py
:
python remove_background.py
- After the script finishes executing, the images with removed backgrounds will be saved in the
no-background
directory as PNG files.
Suppose you have a collection of images named banana.jpg
, berries.jpg
, empty-globe.jpg
, and icecream-cone.jpg
in the inputs
directory. Running the script will remove the backgrounds from these images and save the resulting images in the no-background
directory.
- Make sure to adjust the file paths in the script if your directory structure differs.
- The
rembg
library utilizes AI-based algorithms for background removal, providing accurate results. - Feel free to modify the script or integrate it into your projects as needed.
For more information on the rembg
library, refer to the official documentation: rembg Documentation
For any questions or issues, please open an issue on GitHub.
Happy background removal! 🖼️✂️