Skip to content

kumar-shanu-1881/Secure_Face_AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

46 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” SecureFace AI

A real-time Face Authentication System built using Flask, MediaPipe, InsightFace (ArcFace), and MongoDB. SecureFace AI authenticates users using both traditional credentials and biometric facial recognition for enhanced security.


πŸ“Œ Features

  • πŸ‘€ User Registration
  • πŸ”‘ Secure Login using Face + Password
  • πŸ“· Real-Time Webcam Face Capture
  • 😊 Face Detection using MediaPipe
  • 🧠 Face Recognition using InsightFace (ArcFace)
  • πŸ“ 512-D Face Embeddings
  • πŸ“Š Cosine Similarity & Euclidean Distance Matching
  • πŸ”’ Password Hashing (Werkzeug - Scrypt)
  • πŸ’Ύ MongoDB Database Integration
  • πŸ†” Automatic User ID Generation
  • ⏳ Session-based Authentication (2 Days)
  • πŸ“± Responsive User Interface
  • πŸ§ͺ Face Similarity Testing Module

πŸš€ Demo

Landing Page

  • Project Introduction
  • Features Overview
  • Login/Register Navigation

Registration

  • User Details
  • Live Face Capture
  • Face Embedding Generation
  • Secure Password Storage

Login

  • User ID Verification
  • Email Verification
  • Password Verification
  • Live Face Verification
  • Dashboard Access

Dashboard

  • User Profile
  • Project Information
  • Authentication Status
  • Technology Stack

πŸ— Project Architecture

SecureFace AI
β”‚
β”œβ”€β”€ app
β”‚   β”‚
β”‚   β”œβ”€β”€ api
β”‚   β”‚   β”œβ”€β”€ detect.py
β”‚   β”‚   β”œβ”€β”€ register.py
β”‚   β”‚   β”œβ”€β”€ login.py
β”‚   β”‚   └── dashboard.py
β”‚   β”‚
β”‚   β”œβ”€β”€ core
β”‚   β”‚   β”œβ”€β”€ face_detector.py
β”‚   β”‚   β”œβ”€β”€ get_embedings.py
β”‚   β”‚   β”œβ”€β”€ check_similarity.py
β”‚   β”‚   └── anti_spoof.py (Future)
β”‚   β”‚
β”‚   β”œβ”€β”€ db
β”‚   β”‚   β”œβ”€β”€ mongodb.py
β”‚   β”‚   └── user_repo.py
β”‚   β”‚
β”‚   └── __init__.py
β”‚
β”œβ”€β”€ image
β”œβ”€β”€ static
β”œβ”€β”€ templates
β”œβ”€β”€ test
β”‚
β”œβ”€β”€ .env
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ run.py
└── README.md

βš™οΈ Technology Stack

Backend

  • Python
  • Flask
  • REST API

Frontend

  • HTML5
  • CSS3
  • JavaScript
  • Fetch API

Computer Vision

  • OpenCV
  • MediaPipe

Face Recognition

  • InsightFace
  • ArcFace (buffalo_sc)

Machine Learning

  • NumPy

Database

  • MongoDB Atlas

Security

  • Werkzeug Security (Scrypt)
  • Flask Sessions
  • Environment Variables

🧠 AI Pipeline

Registration Flow

User
      β”‚
      β–Ό
Capture Face
      β”‚
      β–Ό
MediaPipe Face Detection
      β”‚
      β–Ό
Face Crop
      β”‚
      β–Ό
InsightFace Embedding
      β”‚
      β–Ό
Generate User ID
      β”‚
      β–Ό
Hash Password
      β”‚
      β–Ό
Store User Data
      β”‚
      β–Ό
MongoDB

Login Flow

User
      β”‚
      β–Ό
Capture Live Face
      β”‚
      β–Ό
MediaPipe Detection
      β”‚
      β–Ό
Generate Face Embedding
      β”‚
      β–Ό
Verify Email
      β”‚
      β–Ό
Verify User ID
      β”‚
      β–Ό
Verify Password
      β”‚
      β–Ό
Compare Face Embeddings
      β”‚
      β–Ό
Authentication Success
      β”‚
      β–Ό
Dashboard

πŸ” Face Recognition Pipeline

Input Image
      β”‚
      β–Ό
MediaPipe Face Detection
      β”‚
      β–Ό
Face Crop
      β”‚
      β–Ό
InsightFace ArcFace
      β”‚
      β–Ό
512-D Face Embedding
      β”‚
      β–Ό
Cosine Similarity
      β”‚
      β–Ό
Euclidean Distance
      β”‚
      β–Ό
Authentication Result

πŸ“Š Face Matching

The system compares two facial embeddings using:

  • Cosine Similarity
  • Euclidean Distance

Authentication is successful only if both similarity metrics satisfy predefined thresholds.


πŸ”’ Security Features

  • Password Hashing using Scrypt
  • Session Authentication
  • Environment Variables
  • Face Authentication
  • User ID Validation
  • Email Validation

πŸ“‚ Database Schema

Each registered user contains:

Field Description
User ID Unique Generated ID
Name User Name
Email User Email
Password Hashed Password
Face Embedding 512-D Vector
Created At Registration Date

πŸ§ͺ Testing

The project includes testing modules for:

Face Detection

  • Detect face successfully
  • Face crop validation

Face Embedding

  • Generate 512-dimensional embeddings

Similarity Testing

Tests include:

  • Same Person Matching
  • Different Person Matching

Outputs:

  • Cosine Similarity
  • Euclidean Distance
  • Match Decision

Results are stored in:

similarity_results.csv

πŸ“¦ Installation

Clone Repository

git clone https://github.com/yourusername/SecureFace-AI.git

cd SecureFace-AI

Create Virtual Environment

python -m venv faceenv

Activate

Windows

faceenv\Scripts\activate

Linux/Mac

source faceenv/bin/activate

Install Dependencies

pip install -r requirements.txt

Configure Environment Variables

Create a .env file

MONGO_URI=your_mongodb_connection_string

SECRET_KEY=your_secret_key

Run Project

python run.py

Application will run at

http://127.0.0.1:10000

πŸ“ˆ Future Improvements

  • Anti-Spoof Detection (MiniFASNet)
  • JWT Authentication
  • PostgreSQL Support
  • Qdrant Vector Database
  • Docker Deployment
  • Redis Session Storage
  • Admin Dashboard
  • Authentication Logs
  • Email Verification
  • Password Reset
  • Face Registration History
  • Multi-Factor Authentication

🎯 Project Highlights

  • Real-Time Face Authentication
  • Secure User Registration
  • Face + Password Login
  • InsightFace ArcFace Recognition
  • MediaPipe Face Detection
  • MongoDB Integration
  • Flask Modular Architecture
  • Session-Based Authentication
  • Face Similarity Evaluation
  • Production-Oriented Design

πŸ‘¨β€πŸ’» Author

Kumar Shanu

B.Tech Computer Science Engineering (AI & ML)

Machine Learning & Full Stack Developer

GitHub: https://github.com/kumar-shanu-1881/

LinkedIn: https://www.linkedin.com/in/kumar-shanu-9219a5293/


⭐ If you found this project useful, consider giving it a star on GitHub!

About

πŸš€ SecureFace AI is an intelligent face authentication system that enables secure user registration and login using facial recognition technology. It integrates MediaPipe for face detection, InsightFace (Buffalo_SC) for high-accuracy facial embeddings, Flask for backend APIs, and MongoDB Atlas for secure data storage. The system verifies users by c

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors