Skip to content

About

AI-powered Face Authentication System for NIT Trichy, leveraging FaceNet and Computer Vision for secure identity verification, automated attendance management, and real-time authentication. Designed for scalable institutional deployment with cloud-backed analytics and role-based administration.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

29 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  Hypersphere Engine

Production-grade biometric face attendance system with real-time geofencing for Amrita Vishwa Vidyapeetham

Hypersphere Engine is a full-stack, research-to-production attendance platform that combines a deep learning facial recognition pipeline with campus-level GPS geofencing. It was designed for institutional deployment at Amrita Vishwa Vidyapeetham, Ettimadai Campus (Coimbatore, Tamil Nadu) with a focus on privacy, accuracy, and zero user friction.


๐Ÿ“ธ System Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   Kiosk / Web Dashboard                      โ”‚
โ”‚         (Next.js 15 ยท TypeScript ยท Glassmorphic UI)         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚  HTTP POST /api/v1/verify         โ”‚ iframe
               โ”‚  HTTP POST /api/v1/register       โ”‚ postMessage
               โ–ผ                                   โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   FastAPI Backend        โ”‚          โ”‚  Amrita Geofence Map   โ”‚
โ”‚   (Python ยท Uvicorn)     โ”‚          โ”‚  (Leaflet.js ยท PiP     โ”‚
โ”‚                          โ”‚          โ”‚   Ray-Casting Engine)  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚  โ”‚  FacePipeline      โ”‚  โ”‚
โ”‚  โ”‚  1. SCRFD ONNX     โ”‚  โ”‚
โ”‚  โ”‚  2. MediaPipe      โ”‚  โ”‚
โ”‚  โ”‚  3. MiniFASNetV2   โ”‚  โ”‚
โ”‚  โ”‚  4. ArcFace ONNX   โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚           โ”‚ 512-D Vector  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚  PgVectorIndex     โ”‚  โ”‚
โ”‚  โ”‚  PostgreSQL +      โ”‚  โ”‚  
โ”‚  โ”‚  pgvector          โ”‚  โ”‚
โ”‚  โ”‚  (FAISS fallback)  โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœจ Key Features

๐ŸŽญ Biometric Pipeline

Stage Technology Detail
Face Detection SCRFD 2.5G (ONNX) Sub-millisecond detection, returns keypoints for alignment
Face Alignment MediaPipe 5-point affine warp to canonical 112ร—112 face crop
Liveness Detection MiniFASNetV2 (PyTorch) Blocks printed photos, screen replays, and 3D masks
Feature Extraction ArcFace w600k_r50 (ONNX) 512-dimensional identity embedding, cosine similarity
Identity Verification 1:1 Verification Restricts vector search to claimed identity, eliminates cross-identity false accepts

๐Ÿ” Quality Gating (Pre-Inference Guards)

Every frame passes through strict pre-flight checks before ML inference:

  • Illumination โ€” Rejects underlit frames
  • Face Size โ€” Rejects faces too small for reliable embedding
  • Yaw Angle โ€” Rejects excessive side-profile poses
  • Blur Detection โ€” Rejects motion-blurred captures
  • Liveness Score โ€” Hard threshold at 0.40 (MiniFASNetV2 confidence)
  • Embedding Norm โ€” Dynamic EMBEDDING_QUALITY_THRESHOLD calibrated at boot from existing enrollment distribution

๐Ÿ—บ๏ธ Amrita Campus Geofencing

  • 103 building polygons extracted from OpenStreetMap via Overpass API
  • Ray-Casting PiP algorithm โ€” determines exact building from GPS coordinates in <1ms
  • GPS accuracy enforcement โ€” rejects IP-based fixes (>100m accuracy), demands hardware GPS
  • 3-tier resolution: Inside Building โ†’ Campus Grounds โ†’ Off Campus
  • Nearest building computation via Haversine distance when outdoors

๐Ÿ’ป Next.js Dashboard

  • Live webcam stream with face bounding-box overlay
  • Enrollment flow with liveness gate and duplicate detection
  • Real-time attendance verification with location context
  • Admin panel: user management, attendance logs, CSV export
  • Dark glassmorphic UI with Outfit + Plus Jakarta Sans typography

๐Ÿ—๏ธ Project Structure

hypersphere-engine/
โ”‚
โ”œโ”€โ”€ backend/                        # FastAPI Python backend
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ endpoints.py        # All API route handlers
โ”‚   โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ pipeline.py         # Main ML inference pipeline (FacePipeline)
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ scrfd.py            # SCRFD ONNX face detector wrapper
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ amrita_engine.py    # Amrita campus geofence engine
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ csv_loader.py       # Faculty CSV auto-seeder on boot
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ liveness/           # MiniFASNetV2 anti-spoofing module
โ”‚   โ”‚   โ”œโ”€โ”€ db/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ database.py         # SQLAlchemy async engine + table definitions
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ vector_index.py     # pgvector + FAISS hybrid vector search
โ”‚   โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ schemas.py          # Pydantic request/response schemas
โ”‚   โ”‚   โ”œโ”€โ”€ config.py               # Centralised settings (thresholds, paths)
โ”‚   โ”‚   โ””โ”€โ”€ main.py                 # FastAPI app, lifespan hooks, CORS
โ”‚   โ”œโ”€โ”€ requirements.txt
โ”‚   โ””โ”€โ”€ run.sh
โ”‚
โ”œโ”€โ”€ nextjs-frontend/                # Next.js 15 TypeScript frontend
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ dashboard/page.tsx      # Main kiosk dashboard
โ”‚   โ”‚   โ”œโ”€โ”€ login/page.tsx          # Auth page
โ”‚   โ”‚   โ””โ”€โ”€ globals.css             # Global design system styles
โ”‚   โ”œโ”€โ”€ components/                 # Reusable UI components
โ”‚   โ”œโ”€โ”€ public/
โ”‚   โ”‚   โ”œโ”€โ”€ amrita_map.html         # Geofencing map (self-contained)
โ”‚   โ”‚   โ””โ”€โ”€ amrita_data/            # Campus GeoJSON data files
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ scripts/                        # Utility & data scripts
โ”‚   โ”œโ”€โ”€ extract_amrita.py           # Live OSM extraction for Amrita campus
โ”‚   โ”œโ”€โ”€ download_models.py          # ONNX model downloader
โ”‚   โ”œโ”€โ”€ anti_spoof_test.py          # Liveness pipeline testing
โ”‚   โ”œโ”€โ”€ embedding_test.py           # ArcFace vector similarity tester
โ”‚   โ””โ”€โ”€ amrita_data/                # Raw + processed campus geodata
โ”‚
โ”œโ”€โ”€ models/                         # ONNX & PyTorch model weights (gitignored)
โ”‚   โ”œโ”€โ”€ scrfd_2.5g_bnkps.onnx
โ”‚   โ”œโ”€โ”€ w600k_r50.onnx
โ”‚   โ””โ”€โ”€ 2.7_80x80_MiniFASNetV2.pth
โ”‚
โ”œโ”€โ”€ features/                       # Feature registry & developer docs
โ”‚   โ”œโ”€โ”€ README.md                   # Architectural overview & extension guide
โ”‚   โ”œโ”€โ”€ 01_biometric_pipeline.md
โ”‚   โ”œโ”€โ”€ 02_vector_database.md
โ”‚   โ”œโ”€โ”€ 03_quality_gating.md
โ”‚   โ””โ”€โ”€ 04_kiosk_live_demo.md
โ”‚
โ”œโ”€โ”€ docker-compose.yml              # PostgreSQL + pgvector + API stack
โ”œโ”€โ”€ Dockerfile
โ””โ”€โ”€ setup.sh

โš™๏ธ Configuration Reference

All tuneable parameters live in backend/app/config.py:

Setting Default Description
MATCH_THRESHOLD 0.60 Minimum cosine similarity to accept a face match. Higher = stricter.
AMBIGUITY_MARGIN 0.05 Minimum score gap between top-2 matches; prevents ambiguous accepts.
DETECTION_THRESHOLD 0.50 SCRFD confidence threshold for face detection.
ANTISPOOF_THRESHOLD 0.40 MiniFASNetV2 live probability; below this = spoofing attempt.
EMBEDDING_QUALITY_THRESHOLD 12.0 Min L2 norm of embedding; calibrated dynamically at boot from enrollment data.
DUPLICATE_SEARCH_THRESHOLD 0.70 Similarity above which a new enrollment is flagged as a duplicate identity.
BBOX_EXPANSION 2.7 Face crop expansion factor for alignment headroom.
VECTOR_INDEX_PATH faiss_vectors.index Path to local FAISS fallback index.
DATABASE_URL SQLite (dev) Set postgresql+asyncpg://... for production.

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • Docker & Docker Compose (for PostgreSQL)
  • CUDA-capable GPU (optional, ONNX Runtime falls back to CPU)

1. Clone & Set Up

git clone https://github.com/Kv-Logics/hypersphere-engine.git
cd hypersphere-engine

2. Download ML Models

cd backend
python ../scripts/download_models.py

This downloads the three required model files into the models/ directory:

  • scrfd_2.5g_bnkps.onnx โ€” Face detector
  • w600k_r50.onnx โ€” ArcFace recogniser
  • 2.7_80x80_MiniFASNetV2.pth โ€” Liveness detector

3. Start the Database

docker-compose up -d postgres

Spins up pgvector/pgvector:pg16 on port 5432. The face_attendance database and all tables are provisioned automatically on first API startup.

4. Start the Backend

cd backend
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
bash run.sh

API will be available at http://localhost:8000. The Swagger docs are at http://localhost:8000/api/v1/openapi.json.

5. Start the Frontend

cd nextjs-frontend
npm install
npm run dev

Dashboard available at http://localhost:3000.

6. (Optional) Full Docker Stack

docker-compose up --build

Starts both the PostgreSQL database and the API server in containers. Connect the frontend to http://localhost:8000.


๐Ÿ”Œ API Reference

All endpoints are prefixed with /api/v1.

Method Endpoint Description
POST /register Enroll a new face. Accepts multipart/form-data with faculty_id, name, image.
POST /verify Verify identity. Accepts faculty_id + image. Performs 1:1 verification.
GET /faculty List all enrolled faculty with metadata.
GET /attendance Retrieve attendance logs with optional date/user filters.
DELETE /faculty/{id} Remove a faculty member and their embeddings.
GET /health System health check (DB connectivity, model status).

Verify Response Schema

{
  "verified": true,
  "faculty_id": "KV001",
  "name": "Kv Logics",
  "score": 0.847,
  "liveness": true,
  "liveness_score": 0.923,
  "quality_passed": true,
  "location": {
    "insideCampus": true,
    "buildingName": "Central Library"
  }
}

๐Ÿงฎ Biometric Accuracy Design

Why 1:1 Verification (not 1:N Search)?

The system shifted from open-set identification (who is this?) to closed-set verification (is this person who they claim to be?). This is the standard production pattern for authenticated portals:

  • A user logs in to the dashboard โ€” their faculty_id is now known
  • The /verify endpoint restricts the vector search to only that identity's stored embeddings
  • This eliminates cross-identity false accepts entirely, regardless of threshold

Threshold Tuning History

Version MATCH_THRESHOLD Behaviour
v1.0 0.45 Too permissive โ€” Person A's embedding matched Person B at ~0.48
v1.1 0.55 Better, occasional boundary cases
v2.0 (current) 0.60 Strict โ€” genuine match scores typically >0.75, impostors typically <0.50

๐Ÿ—บ๏ธ Amrita Campus Data

Campus spatial data is extracted from OpenStreetMap via the Overpass API.

File Description
amrita_buildings.geojson 103 building polygons
amrita_attendance_polygons.json PiP-optimised format {building_id, building_name, polygon, centroid}
amrita_campus_boundary.geojson Outer campus perimeter
amrita_raw_osm.json Raw Overpass API response

Coverage: 32 of 103 buildings are named in OSM (Central Library, Academic Block 2 & 3, Gargi/Vasishta Bhavanam hostels, Fabrication Workshop, etc.). The remaining 71 are tagged Building_<OSM_ID> for on-site naming.

To re-extract or refresh the campus data:

python scripts/extract_amrita.py

๐Ÿ›ก๏ธ Privacy & Security

  • No raw images stored โ€” Only 512-D float embeddings are persisted. Original frames are discarded immediately after inference.
  • Liveness mandatory โ€” Every verification attempt is blocked if MiniFASNetV2 flags the presentation as non-live.
  • Accuracy filter on GPS โ€” Coordinates with >100m accuracy radius are rejected to prevent IP-based location spoofing.
  • 1:1 scope binding โ€” Vector search is hard-scoped to the authenticated user's identity.

๐Ÿ“ฆ Tech Stack

Layer Technology
ML Models SCRFD (ONNX), ArcFace w600k_r50 (ONNX), MiniFASNetV2 (PyTorch)
Face Processing MediaPipe, OpenCV, ONNX Runtime
Backend FastAPI, Uvicorn, Python 3.10+
Vector DB PostgreSQL 16 + pgvector, FAISS (fallback)
ORM / Async SQLAlchemy (async), databases, asyncpg
Frontend Next.js 15, TypeScript, React 19
Map Engine Leaflet.js 1.9.4, Overpass API, Nominatim
Deployment Docker, Docker Compose, Vercel (frontend), ngrok (dev)

๐Ÿ”— Related Repositories

Repo Purpose
amrita-geofence-tester Standalone deployment of the Amrita geofencing map for HTTPS GPS testing

๐Ÿ“„ License

Research project developed under NITT-CDI / Amrita Vishwa Vidyapeetham collaboration.
Campus geospatial data ยฉ OpenStreetMap contributors โ€” ODbL License.

About

AI-powered Face Authentication System for NIT Trichy, leveraging FaceNet and Computer Vision for secure identity verification, automated attendance management, and real-time authentication. Designed for scalable institutional deployment with cloud-backed analytics and role-based administration.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages