A web application built with Flask that removes backgrounds from images using the rembg library.
This project provides a user-friendly web interface for removing backgrounds from images. It leverages the rembg library for efficient background removal and supports multiple image formats. The application is designed to be responsive, accessible, and easy to use.
- Web-based interface for seamless image uploads
- Supports JPG, PNG, GIF, and BMP image formats
- Fast and reliable background removal using rembg
- Responsive design compatible with desktop and mobile devices
- Displays processed images with an option to download
- Python 3.8 or higher
- pip package manager
-
Clone the repository:
git clone https://github.com/fahadelahikhan/Background-Remover-Flask-Python.git cd Background-Remover-Flask-Python -
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install required dependencies:
pip install -r requirements.txt
-
Run the application:
python main.py
-
Open your browser and navigate to
http://localhost:4000.
- Access the web interface at
http://localhost:4000 - Upload an image by clicking "Choose file" or dragging and dropping
- Click "Remove Background" to process the image
- View the processed image and download the result
Background-Remover-Flask-Python/
├── main.py # Main application code
├── templates/
│ └── index.html # HTML template for the web interface
├── requirements.txt # Project dependencies
├── LICENSE.txt # MIT License file
├── .gitignore # Git ignore file
├── assets
│ └── input image.jpg
│ └── processed image.jpg
└── README.md # Project documentation
See requirements.txt for a complete list of dependencies.
For production deployment, use a WSGI server like Gunicorn:
gunicorn -w 4 -b 0.0.0.0:4000 main:create_appSet the PORT environment variable for custom port configuration:
export PORT=8080 # On Windows: set PORT=8080- Ensure all dependencies are installed correctly.
- Verify that the uploaded image is in a supported format (JPG, PNG, GIF, BMP).
- Check the console for error messages if processing fails.
Distributed under the MIT License. See LICENSE.txt for details.
Note: The quality of background removal depends on the rembg library's capabilities. For best results, use high-quality images with clear foregrounds.

