Skip to content

An AI-powered Image Background Removal system that automatically detects and removes backgrounds from images using deep learning models. It provides clean, transparent outputs for editing, design, or e-commerce use. The system ensures high accuracy and preserves object details effectively.

Notifications You must be signed in to change notification settings

Ramteja24/Image-Background-Removal-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🖼️ Image Background & Foreground Removal Tool This Python application allows users to remove the background or foreground of an image using a deep learning model. After removing the background, you can replace it with any color of your choice — perfect for generating clean, professional-looking images!

✨ Features 🔍 Automatically removes background from input images.

🎯 Optional foreground removal for isolating the background.

🎨 Allows custom background color replacement (e.g., white, green, blue, etc.).

🤖 Uses a pre-trained Keras/TensorFlow segmentation model (model.h5).

📂 Processes single images or batches from a folder.

🧠 Supports custom metrics like Dice Loss, IoU, and Dice Coefficient.

🛠️ Tech Stack Python 3.x

TensorFlow / Keras

NumPy

OpenCV (cv2)

tqdm

📁 Folder Structure graphql Copy Edit image-background-removal/ ├── model.h5 # Trained segmentation model ├── run.py # Main script to process images ├── metrics.py # Custom metrics (dice_loss, dice_coef, iou) ├── input/ # Input images ├── output/ # Output images (after processing) ├── README.md 📦 Installation bash Copy Edit git clone https://github.com/Ramteja24/Image-Background-Removal-AI.git cd image-background-removal

Create virtual environment (optional)

python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate

Install dependencies

pip install -r requirements.txt ✅ Usage Run the script:

bash Copy Edit python run.py --input input/image.jpg --bg_color white You can also specify a hex color:

bash Copy Edit python run.py --input input/photo.png --bg_color "#00ff00" 🧠 Custom Model Metrics In metrics.py:

python Copy Edit def dice_loss(y_true, y_pred): ... def dice_coef(y_true, y_pred): ... def iou(y_true, y_pred): ... These metrics are automatically passed via custom_objects while loading the model.

🖌️ Custom Background Color You can choose any color to replace the removed background:

Common options: white, black, green, blue, etc.

Or use custom hex codes like #ffcc00.

🧪 Example Input: pic3

Output: pic3

About

An AI-powered Image Background Removal system that automatically detects and removes backgrounds from images using deep learning models. It provides clean, transparent outputs for editing, design, or e-commerce use. The system ensures high accuracy and preserves object details effectively.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages