Skip to content

Vineshnayak/Sentinel-Face-Secure

Repository files navigation

Sentinel Face Secure

Language Framework Database AI Model Security

Sentinel Face Secure is a facial authentication system designed for secure and privacy-aware identity verification. It uses lightweight convolutional neural networks (CNNs) for efficient face recognition and incorporates multiple liveness detection techniques to reduce spoofing attacks. The system is designed and implemented with a focus on deployment on resource-constrained edge devices.


πŸ“– Table of Contents


πŸš€ Features

πŸ‘€ Core Authentication

  • Touchless Login: Authenticate users instantly using just their face.
  • Instant Enrollment: Fast user registration process capturing multiple angles.
  • Role-Based Access Control (RBAC): Distinct interfaces for Admin, Manager, Employee, and Guest.

πŸ›‘οΈ Advanced Security

  • Multi-Modal Liveness Detection:
  • Blink Detection: Monitors Eye Aspect Ratio (EAR) to ensure user presence (Active Liveness).
  • Motion Analysis: Analyzes temporal frame differences to detect static photo attacks (Passive Liveness).
  • Head Movement Tracking: Verifies 3D face geometry changes via face size variance.
  • Video Spoofing Analysis: Detects replay attacks and screen artifacts to prevent video playback spoofing.
  • Zero-Knowledge Privacy: Raw user photos are never stored. Only mathematical vector embeddings are saved.
  • At-Rest Encryption: All stored embeddings are encrypted using Fernet (AES-128) symmetric encryption.

πŸ“Š Monitoring & Analytics

  • Real-Time Dashboard: Live monitoring of system performance.
  • Audit Logs: Immutable history of all login attempts, including spoofing alerts.
  • Performance Metrics: Tracks discrimination latency, embedding time, and hardware utilization.

πŸ— System Architecture

The system follows a modern decoupled Client-Server architecture.

  1. Client (Frontend): Captures live video feed, handles user interaction, and sends optimized image frames to the server.
  2. API Gateway (FastAPI): Validates requests and routes them to specific micro-services (Detection, Liveness, Embedding).
  3. Processing Engine:
  • Detection: Locates face using Hybrid approach (YOLO-Nano for accuracy or Haar Cascades for speed).
  • Liveness: Evaluates frame sequence for biological signs.
  • Embedding: Extracts 128-dimensional vector using MobileNetV2.
  1. Database Layer: MongoDB stores user metadata and encrypted vector blobs.

πŸ’» Technology Stack

Component Technology Description
Frontend React 18, TypeScript UI/UX and logic
Build Tool Vite High-performance frontend tooling
Styling Tailwind CSS, Radix UI Responsive and accessible design system
Backend Python FastAPI Async, high-performance API framework
Database MongoDB (Motor) Document store for flexible user data
AI Model MobileNetV2 (PyTorch) Lightweight CNN for feature extraction
Computer Vision OpenCV, TorchVision Image processing and transformation
Security Cryptography (Fernet) Symmetric encryption for data at rest

🧠 AI & Security Specifications

1. Convolutional Neural Network (CNN)

We utilize a customized MobileNetV2 architecture, finetuned for facial recognition:

  • Backbone: MobileNetV2 pretrained on ImageNet.
  • Input: 224x224 RGB Images.
  • Custom Head: Replaced standard classifier with a dense embedding layer.
  • Structure: Dropout(0.3) -> Linear(1280, 128) -> BatchNorm1d(128)
  • Output: 128-dimensional float vector (L2 Normalized).
  • Similarity Metric: Cosine Similarity.

2. Enhanced Liveness Engine

The EnhancedLivenessDetector calculates a weighted probability score based on:

  • Blink Score (weight: 0.25): Uses scipy.spatial distance on eye landmarks.
  • Motion Score (weight: 0.25): Calculates pixel intensity changes between frames.
  • Head Movement (weight: 0.20): Monitors bounding box scale variance.
  • Video Spoofing Analysis (weight: 0.30): Detects replay attacks and screen artifacts.
  • Threshold: A combined score < 0.15 triggers a spoofing alert.

πŸ“‚ Project Structure

sentinel-face-secure/
β”œβ”€β”€ client/                         # --- Frontend Application ---
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/             # Reusable UI (Forms, Charts, Camera)
β”‚   β”‚   β”œβ”€β”€ hooks/                  # Logic hooks (useAuth, useCamera)
β”‚   β”‚   β”œβ”€β”€ pages/                  # Route Views
β”‚   β”‚   β”‚   β”œβ”€β”€ Landing.tsx         # Home/Welcome page
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.tsx           # Face Authentication page
β”‚   β”‚   β”‚   β”œβ”€β”€ Register.tsx        # User Enrollment page
β”‚   β”‚   β”‚   └── Dashboard.tsx       # Main User/Admin Interface
β”‚   β”‚   β”œβ”€β”€ lib/                    # API clients & Utilities
β”‚   β”‚   └── App.tsx                 # Main Component
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.ts
β”‚
β”œβ”€β”€ server/                         # --- Backend Application ---
β”‚   β”œβ”€β”€ main.py                     # API Entry Point & Routes
β”‚   β”œβ”€β”€ cnn_embedding.py            # MobileNetV2 Model Definition
β”‚   β”œβ”€β”€ liveness_detection.py       # Anti-Spoofing & Blink Logic
β”‚   β”œβ”€β”€ yolo_detector.py            # YOLO-Nano Face Detector
β”‚   β”œβ”€β”€ encryption.py               # Fernet Encryption Utils
β”‚   β”œβ”€β”€ database.py                 # MongoDB Connection Wrapper
β”‚   β”œβ”€β”€ models.py                   # Pydantic Data Schemas
β”‚   β”œβ”€β”€ metrics.py                  # System Performance Monitor
β”‚   β”œβ”€β”€ lfw_evaluation.py           # Evaluation Scripts
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── haarcascade_*.xml           # OpenCV Cascades
β”‚
└── README.md                       # Documentation

πŸ›  Installation Guide

Prerequisites

  • Node.js v18+
  • Python 3.9+
  • MongoDB v5.0+

Step 1: Backend Setup

  1. Navigate to the server directory:
cd server
  1. Install Python dependencies:
pip install -r requirements.txt
  1. Create a .env file (see Configuration).
  2. Start the FastAPI server:
python main.py

Server will start at http://localhost:5001.

Step 2: Frontend Setup

  1. Open a new terminal and navigate to the client directory:
cd client
  1. Install Node dependencies:
npm install
  1. Start the development server:
npm run dev

App will be accessible at http://localhost:5173.


βš™ Configuration

Create a .env file in the server directory with the following variables:

# Server
PORT=5001
FRONTEND_DIR=../client/dist

# Database
MONGODB_URI=mongodb://localhost:27017
DB_NAME=sentinel_face

# AI & Security
ENCRYPT_EMBEDDINGS=true       # Encrypt vectors in DB
USE_YOLO=false                # Set true for higher accuracy (slower)

πŸ“– API Documentation

Authentication

Method Endpoint Description
POST /api/enroll Enroll a new user. Requires name, role, and 15 face images.
POST /api/verify Authenticate a user. Requires live image frames.

System & Users

Method Endpoint Description
GET /api/users List all enrolled users (Admin).
GET /api/logs Retrieve authentication logs and security alerts.
GET /api/system/metrics Get CPU/RAM usage and inference latency.
GET /api/health Check database and model status.

πŸ”§ Troubleshooting

"Video device not found"

Ensure your browser has permission to access the camera. Check chrome://settings/content/camera.

"Model not loaded"

The first run requires downloading pretrained weights. Ensure you have an active internet connection when running python main.py for the first time.

"MongoDB Connection Failed"

Ensure your local MongoDB service is running.

  • Mac: brew services start mongodb-community
  • Windows: net start MongoDB

πŸ“„ License

This project is licensed under the MIT License.

About

Sentinel Face Secure is a lightweight CNN-based facial authentication system using MobileNetV2 with liveness detection and encrypted biometric embeddings for secure, real-time user verification.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors