Skip to content

sks-007/Celeb-Match

Repository files navigation

🎬 Celebrity Look-Alike Finder

Find out which Bollywood celebrity or sports personality you look like using advanced facial recognition technology!

🌟 Features

  • Face Detection: Uses MTCNN for accurate face detection
  • Deep Learning: VGGFace with ResNet50 for feature extraction
  • High Accuracy: Compares with multiple celebrity images
  • Top 5 Matches: Shows your top 5 celebrity matches
  • Confidence Scores: Displays match confidence percentages
  • Wide Celebrity Database: Includes Bollywood actors and Indian sportspersons

📋 Prerequisites

  • Python 3.10 (Required for TensorFlow compatibility)
  • Webcam or image files for testing

🚀 Quick Start (Local)

1. Install Dependencies

pip install -r requirements.txt

2. Run the Application

streamlit run celebrity_finder.py

The app will open in your browser at http://localhost:8501

☁️ Deploy on Render

Step-by-Step Deployment Guide

1. Prepare Your Repository

# Initialize git (if not already done)
git init
git add .
git commit -m "Initial commit for Render deployment"

2. Create a GitHub Repository

  1. Go to github.com/new
  2. Create a new repository (e.g., celebrity-lookalike-finder)
  3. Push your code:
git remote add origin https://github.com/YOUR_USERNAME/celebrity-lookalike-finder.git
git branch -M main
git push -u origin main

3. Set Up Render Account

  1. Go to render.com
  2. Sign up with GitHub (recommended for easy integration)
  3. Click "Dashboard"

4. Create a New Web Service

  1. Click "New +""Web Service"
  2. Select "Build and deploy from a Git repository"
  3. Click "Connect" next to your GitHub repository
  4. Select the repository: celebrity-lookalike-finder

5. Configure the Service

Basic Settings:

  • Name: celebrity-lookalike-finder
  • Environment: Python 3
  • Build Command: pip install --no-cache-dir -r requirements.txt
  • Start Command: streamlit run celebrity_finder.py --server.port=8501 --server.address=0.0.0.0

Instance Type: Free (for testing)

6. Set Environment Variables

Add these environment variables in Render dashboard:

PYTHONUNBUFFERED=1

7. Deploy

  1. Click "Create Web Service"
  2. Wait for deployment (2-5 minutes)
  3. Your app will be live at: https://celebrity-lookalike-finder.onrender.com

Alternative: Using render.yaml

The render.yaml file is already configured. You can also deploy by:

  1. Going to render.com/dashboard
  2. Click "New +""Web Service"
  3. Select "Build and deploy from Git"
  4. Render will automatically use render.yaml configuration

📁 Project Structure

├── celebrity_finder.py          # Main Streamlit application
├── app.py                       # Alternative app (older version)
├── extract_features.py          # Feature extraction pipeline
├── download_celebrity_images.py # Image downloader setup
├── requirements.txt             # Python dependencies
├── Procfile                     # Render deployment config
├── render.yaml                  # Render service config
├── .streamlit/config.toml       # Streamlit configuration
├── README.md                    # This file
├── celebrity_images/            # Celebrity image database
├── uploads/                     # User uploaded images
├── embedding.pkl                # Celebrity facial embeddings
└── filenames.pkl               # Celebrity image filenames

🎯 How It Works

  1. Face Detection: MTCNN detects faces in the uploaded image
  2. Preprocessing: Face is extracted, padded, and resized to 224x224
  3. Feature Extraction: VGGFace ResNet50 extracts 2048-dimensional features
  4. Similarity Matching: Cosine similarity compares with all celebrity embeddings
  5. Ranking: Top 5 most similar celebrities are displayed with confidence scores

🔧 Improving Accuracy

To improve the model's accuracy:

  1. More Images: Add 30-50 images per celebrity
  2. Diverse Angles: Include various facial angles and expressions
  3. Good Quality: Use high-resolution, clear images
  4. Proper Lighting: Ensure images have good lighting
  5. Face Clarity: Make sure faces are clearly visible

📊 Celebrity Database

Current database includes Bollywood actors and Indian sports personalities.

🛠️ Troubleshooting

Deployment Issues

"Dependencies failed to install"

  • Ensure Python 3.10 is specified
  • Check that all packages in requirements.txt are compatible
  • Try removing large packages temporarily

"App crashes on startup"

  • Check logs in Render dashboard
  • Ensure embedding.pkl and filenames.pkl files are present
  • Verify TensorFlow/Keras versions match

"No face detected"

  • Ensure your face is clearly visible
  • Use good lighting
  • Face the camera directly
  • Avoid sunglasses or face coverings

Memory Issues

If you get memory errors:

  • Use Render's paid plans with more RAM
  • Optimize image processing in extract_features.py
  • Reduce number of celebrity images processed at once

📝 Environment Variables

Set these in Render dashboard if needed:

PYTHONUNBUFFERED=1          # Shows print output immediately
STREAMLIT_SERVER_PORT=8501  # Port for Streamlit

🤝 Contributing

To add more celebrities:

  1. Create folder: celebrity_images/category/Celebrity_Name/
  2. Add 20-50 clear face images
  3. Run: python extract_features.py (locally)
  4. Commit and push changes
  5. Render will auto-redeploy

📧 Support

For issues and questions:

  1. Check the README troubleshooting section
  2. Review error messages in the Render logs
  3. Ensure all files (embedding.pkl, filenames.pkl) are included

🔗 Useful Links


Note: This is a fun project for educational purposes. Results may vary based on the quality and quantity of celebrity images in your database.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors