CoolFace
Apppublic

ShanmukhaDesu/identix-facial-landmarks

sourceHugging Faceapache-2.0updated 10mo agoView on Hugging Face
0likes
App README

IDENTIX - Facial Landmark Detection & Deepfake Analysis

๐Ÿš€ Production-Ready Deployment Package

What is IDENTIX?

IDENTIX is an advanced AI-powered web application that performs:

  • โ€”Facial Landmark Detection - 11-class segmentation using BiSeNet architecture
  • โ€”Deepfake Detection - Multi-factor analysis for video authenticity
  • โ€”User Authentication - Secure MongoDB-backed user management
  • โ€”Real-time Processing - Image and video analysis with instant results

๐ŸŽฏ Key Features

  • โ€”โœ… High-accuracy facial landmark segmentation (trained BiSeNet model)
  • โ€”โœ… Multi-person detection and tracking
  • โ€”โœ… Deepfake detection with confidence scoring
  • โ€”โœ… Secure user registration and authentication
  • โ€”โœ… Beautiful responsive UI with light/dark themes
  • โ€”โœ… MongoDB Atlas integration for user data
  • โ€”โœ… Production-ready Flask application
  • โ€”โœ… Optimized for Render deployment

๐Ÿ“‹ Quick Start

For deployment instructions, see [DEPLOYMENT.md](DEPLOYMENT.md)

Local Testing

  1. 1.Install dependencies:
bash
   pip install -r requirements.txt
  1. 1.Set up environment variables:
bash
   cp .env.example .env
   # Edit .env with your MongoDB connection string
  1. 1.Run the application:
bash
   python app.py
  1. 1.Open browser:
   http://localhost:5000

๐Ÿ—๏ธ Architecture

Tech Stack

  • โ€”Backend: Flask (Python web framework)
  • โ€”ML Framework: PyTorch (BiSeNet model)
  • โ€”Database: MongoDB Atlas (user authentication)
  • โ€”Image Processing: OpenCV, PIL
  • โ€”Server: Gunicorn (production)

Model Details

  • โ€”Architecture: BiSeNet (Bilateral Segmentation Network)
  • โ€”Backbone: ResNet-50
  • โ€”Classes: 11 facial landmarks
  • โ€”Skin
  • โ€”Left Eyebrow
  • โ€”Right Eyebrow
  • โ€”Left Eye
  • โ€”Right Eye
  • โ€”Nose
  • โ€”Upper Lip
  • โ€”Inner Mouth
  • โ€”Lower Lip
  • โ€”Hair
  • โ€”Background

Security Features

  • โ€”SHA256 password hashing (upgradable to bcrypt)
  • โ€”Email validation with regex
  • โ€”Input sanitization (XSS prevention)
  • โ€”Unique email constraint in MongoDB
  • โ€”Session-based authentication
  • โ€”Environment variable configuration

๐Ÿ“ Project Structure

identix-deploy/
โ”œโ”€โ”€ app.py                  # Main Flask application
โ”œโ”€โ”€ mongodb_utils.py        # Database connection utilities
โ”œโ”€โ”€ deepfake_detector.py    # Deepfake analysis module
โ”œโ”€โ”€ best_model.pth          # Trained BiSeNet model (~95MB)
โ”œโ”€โ”€ requirements.txt        # Python dependencies
โ”œโ”€โ”€ render.yaml             # Render deployment config
โ”œโ”€โ”€ .env.example            # Environment template
โ”œโ”€โ”€ .gitignore              # Git ignore rules
โ”œโ”€โ”€ DEPLOYMENT.md           # Detailed deployment guide
โ”œโ”€โ”€ README.md               # This file
โ””โ”€โ”€ templates/              # HTML templates
    โ”œโ”€โ”€ index.html          # Landing page
    โ”œโ”€โ”€ image_analysis.html # Image upload page
    โ”œโ”€โ”€ video_analysis.html # Video upload page
    โ”œโ”€โ”€ deepfake_detection.html
    โ””โ”€โ”€ ... (other pages)

๐Ÿ”‘ Environment Variables

Required variables (see .env.example):

VariableDescriptionExample
MONGODB_URIMongoDB Atlas connection stringmongodb+srv://user:pass@cluster.mongodb.net/db
SECRET_KEYFlask session secretGenerate with secrets.token_hex(32)
FLASK_ENVEnvironment modeproduction or development
PORTServer port (auto-set by Render)5000

๐Ÿงช API Endpoints

Authentication

  • โ€”POST /register - Create new user account
  • โ€”POST /login - Authenticate user
  • โ€”POST /logout - End user session
  • โ€”GET /check-auth - Check authentication status

Analysis

  • โ€”POST /predict - Analyze image for facial landmarks
  • โ€”POST /predict_video - Process video frames
  • โ€”POST /detect_deepfake - Analyze video for deepfake

Other

  • โ€”GET /health - Health check endpoint
  • โ€”GET / - Landing page
  • โ€”GET /facial-landmarks - Image analysis UI
  • โ€”GET /video-analysis - Video analysis UI

๐Ÿ›ก๏ธ Security Considerations

Current Implementation

โœ… Password hashing (SHA256) โœ… Input validation โœ… XSS prevention โœ… Secure session management โœ… Environment-based secrets

Recommended Improvements

โš ๏ธ Upgrade to bcrypt/argon2 password hashing โš ๏ธ Add rate limiting (Flask-Limiter) โš ๏ธ Add CSRF protection (Flask-WTF) โš ๏ธ Implement password reset functionality โš ๏ธ Add email verification

See DEPLOYMENT.md for implementation details.

๐Ÿ“Š Performance

Model Performance

  • โ€”Input Size: 256ร—256 pixels
  • โ€”Output: 11-class segmentation mask
  • โ€”Inference Time: ~100-300ms per image (CPU)

Resource Requirements

  • โ€”RAM: ~1GB minimum
  • โ€”Storage: ~500MB (model + dependencies)
  • โ€”CPU: Single core sufficient for free tier

Render Free Tier

  • โ€”750 hours/month
  • โ€”Sleeps after 15 minutes inactivity
  • โ€”First request after sleep: ~30 seconds

๐Ÿ› Known Issues & Limitations

  1. 1.Free Tier Sleep: App sleeps on inactivity (Render limitation)
  2. 2.Model Size: Large model file (~95MB) affects cold start
  3. 3.SHA256 Hashing: Basic password security (upgrade recommended)
  4. 4.No Rate Limiting: Vulnerable to brute force (mitigation available)
  5. 5.CPU Inference: Slower than GPU (acceptable for free tier)

๐Ÿ”„ Updates & Maintenance

Updating Code

bash
git add .
git commit -m "Update description"
git push origin main
# Render auto-deploys

Monitoring

  • โ€”Check Render dashboard for logs
  • โ€”Monitor /health endpoint
  • โ€”Review MongoDB Atlas metrics

๐Ÿ“– Documentation

  • โ€”Deployment Guide: DEPLOYMENT.md
  • โ€”Render Setup Summary:
  • โ€”Build: pip install --upgrade pip && pip install -r requirements.txt
  • โ€”Start: gunicorn app:app -b 0.0.0.0:$PORT -w 2
  • โ€”Health: /health
  • โ€”Env vars: MONGODB_URI, SECRET_KEY, FLASK_ENV=production
  • โ€”Plan: standard recommended for PyTorch model
  • โ€”Code Documentation: Inline docstrings in Python files
  • โ€”API Reference: See "API Endpoints" section above

๐Ÿค Contributing

This is a capstone project. For modifications:

  1. 1.Test locally first
  2. 2.Update requirements.txt if adding dependencies
  3. 3.Document changes in commit messages
  4. 4.Check security implications

๐Ÿ“ License

Educational/Academic Project - Capstone 4-1

๐Ÿ‘ฅ Authors

Capstone Team - Facial Landmark Detection Project

๐Ÿ™ Acknowledgments

  • โ€”BiSeNet architecture inspiration
  • โ€”MongoDB Atlas free tier
  • โ€”Render free hosting
  • โ€”PyTorch framework
  • โ€”Flask community

Ready to deploy? Follow the comprehensive guide in DEPLOYMENT.md

Questions? Check troubleshooting section in deployment guide.

Need help? Review the security and performance sections above.