This application provides functionality to remove the background from an image and replace it with a solid color or another image. It uses the rembg
library for background removal and the PIL
(Pillow) library for image processing.
- Remove Background: Remove the background from an image using the
remove_bg
function. - Add Background Color: Replace the background of an image with a solid color using the
add_bg_color
function. - Add Background Image: Replace the background of an image with another image using the
add_bg_image
function. - Download Images: Download the processed images directly from the app.
- Python 3.x
- Streamlit
- Pillow
- rembg
-
Clone the repository:
git clone /~https://github.com/anurag-singh-9622/bgremover cd your-repo
-
Install the required packages:
pip install -r requirements.txt
-
Run the Streamlit app:
streamlit run app.py
-
Open your web browser and go to
http://localhost:8501
to access the app.
Removes the background from the given image.
- Parameters:
image
(PIL.Image): The input image from which the background will be removed.
- Returns:
PIL.Image
: The image with the background removed.
Adds a solid color background to the given foreground image.
- Parameters:
foreground
(PIL.Image): The foreground image.color
(tuple): The color to be used for the background (e.g.,(255, 255, 255, 255)
for white).
- Returns:
PIL.Image
: The combined image with the new background color.
Adds a background image to the given foreground image.
- Parameters:
foreground
(PIL.Image): The foreground image.background
(PIL.Image): The background image.
- Returns:
PIL.Image
: The combined image with the new background image.
This project is licensed under the MIT License. See the LICENSE file for details.
This repository is maintained by Anurag Singh. You can connect with me on LinkedIn.