Skip to content

iamjaved026/trueface

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”ฎ TrueFace - AI Face Recognition by Javed Hussain

Real-Time AI Face Recognition System developed by Javed (iamjaved026)
Detect โ€ข Recognize โ€ข Register โ€” all in your browser

Version License Python Node.js Next.js FastAPI

Features โ€ข Tech Stack โ€ข Quick Start โ€ข API โ€ข Models โ€ข Credits


โœจ Features

๐ŸŽฏ Real-Time Detection
Blazing-fast face detection with TinyFaceDetector running at 15-30 FPS directly in your browser via WebAssembly

๐Ÿง  AI Recognition
State-of-the-art face embeddings via FaceNet (InceptionResnetV1) trained on VGGFace2 dataset

๐Ÿ“ท Live Registration
Register new people in seconds โ€” capture 3-5 photos, and they're instantly recognizable

๐Ÿ“‹ Detection Logs
Full history of every recognition event with timestamps, confidence scores, and role info

๐ŸŽจ Premium Dark UI
Futuristic glassmorphism design with smooth animations, scanning effects, and ambient lighting

โšก One-Command Launch
Single node server.js starts both frontend and backend โ€” no complex setup needed

๐Ÿ› ๏ธ Tech Stack

Frontend

Technology Purpose
Next.js 15 React framework with App Router, SSR
Tailwind CSS 4 Utility-first CSS framework
@vladmandic/face-api Browser-side face detection (TinyFaceDetector)
TypeScript Type-safe development

Backend

Technology Purpose
FastAPI High-performance Python API framework
FaceNet-PyTorch MTCNN detection + InceptionResnetV1 embeddings
PyTorch Deep learning runtime
OpenCV Image processing
SQLite Lightweight embedded database

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.9+
  • Node.js 18+ and npm
  • C++ Build Tools (Windows only): Install "Desktop development with C++" via Visual Studio Installer (required by some native Python packages)

1๏ธโƒฃ Clone the Repository

git clone https://github.com/iamjaved026/trueface.git
cd trueface

2๏ธโƒฃ Setup Backend

cd backend

# Create virtual environment
python -m venv venv

# Activate (Windows)
venv\Scripts\activate

# Activate (macOS/Linux)
# source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

๐Ÿ“ Note: On first run, FaceNet-PyTorch will automatically download the pretrained model weights (~100MB). This only happens once.

3๏ธโƒฃ Setup Frontend

cd frontend

# Install dependencies
npm install

# Build for production
npm run build

4๏ธโƒฃ Launch TrueFace

From the project root directory:

node server.js

This single command starts both the FastAPI backend and the Next.js frontend!

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘         TrueFace โ€” Real-Time Face Recognition           โ•‘
โ•‘                        v1.0                             โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

[BACKEND]  Starting FastAPI server on port 8000...
[FRONTEND] Starting Next.js on port 3000...

[SERVER]   Dashboard:    http://localhost:3000
[SERVER]   API Docs:     http://localhost:8000/docs

5๏ธโƒฃ Open the App

Navigate to http://localhost:3000 in your browser and allow camera access.


๐Ÿ“– Usage Guide

๐Ÿ” Real-Time Recognition

  1. Allow camera access when prompted
  2. Faces are detected in real-time with futuristic bounding boxes
  3. Detected faces are sent to the backend for recognition
  4. Known persons show Name (Role) Confidence% in green/blue
  5. Unknown persons show Unknown in red

โž• Adding a New Person

  1. Click "+ Add Person" in the sidebar
  2. Enter the person's name and role (Admin/User)
  3. Capture 3-5 images using the circular capture button
  4. Click "Register Person"
  5. The person is instantly recognizable! ๐ŸŽ‰

๐Ÿ“‹ Viewing Detection Logs

  1. Click "Logs" in the sidebar
  2. A side panel slides in showing detection history
  3. Each entry shows name, timestamp, confidence score, and status

๐Ÿ”Œ API Reference

Once the backend is running, visit http://localhost:8000/docs for the interactive Swagger UI.

Endpoints

Method Endpoint Description
POST /recognize Recognize a face from a base64 image
POST /add-person Register a new person with face images
GET /persons List all registered persons
DELETE /persons/{id} Delete a registered person
GET /logs Get detection history
DELETE /logs Clear all logs
GET /health System health check

Example: Recognize a Face

curl -X POST http://localhost:8000/recognize \
  -H "Content-Type: application/json" \
  -d '{"image": "data:image/jpeg;base64,/9j/4AAQ..."}'

Response:

{
  "name": "Javed Hussain",
  "role": "Admin",
  "confidence": 0.892,
  "status": "known"
}

๐Ÿ“ Project Structure

trueface/
โ”œโ”€โ”€ server.js                  # ๐Ÿš€ Unified launcher (node server.js)
โ”œโ”€โ”€ LICENSE                    # MIT License
โ”œโ”€โ”€ .gitignore                 # Git ignore rules
โ”‚
โ”œโ”€โ”€ frontend/                  # Next.js 15 App Router
โ”‚   โ”œโ”€โ”€ public/models/         # face-api.js model weights
โ”‚   โ””โ”€โ”€ src/app/
โ”‚       โ”œโ”€โ”€ components/        # React UI components
โ”‚       โ”‚   โ”œโ”€โ”€ WebcamFeed.tsx     # Live camera + bounding boxes
โ”‚       โ”‚   โ”œโ”€โ”€ AddPersonModal.tsx # Person registration modal
โ”‚       โ”‚   โ”œโ”€โ”€ LogsPanel.tsx      # Detection history panel
โ”‚       โ”‚   โ”œโ”€โ”€ Sidebar.tsx        # Navigation sidebar
โ”‚       โ”‚   โ””โ”€โ”€ StatusIndicator.tsx
โ”‚       โ”œโ”€โ”€ hooks/             # Custom React hooks
โ”‚       โ”‚   โ”œโ”€โ”€ useFaceDetection.ts  # Browser face detection
โ”‚       โ”‚   โ””โ”€โ”€ useRecognition.ts    # Backend API integration
โ”‚       โ”œโ”€โ”€ lib/               # Shared utilities
โ”‚       โ”‚   โ”œโ”€โ”€ api.ts            # API client
โ”‚       โ”‚   โ””โ”€โ”€ types.ts          # TypeScript definitions
โ”‚       โ”œโ”€โ”€ globals.css        # Design system + theme
โ”‚       โ”œโ”€โ”€ layout.tsx         # Root layout
โ”‚       โ””โ”€โ”€ page.tsx           # Main dashboard page
โ”‚
โ”œโ”€โ”€ backend/                   # Python FastAPI
โ”‚   โ”œโ”€โ”€ main.py                # App entry point
โ”‚   โ”œโ”€โ”€ requirements.txt       # Python dependencies
โ”‚   โ”œโ”€โ”€ routers/               # API endpoint handlers
โ”‚   โ”‚   โ”œโ”€โ”€ recognize.py          # Face recognition endpoint
โ”‚   โ”‚   โ”œโ”€โ”€ persons.py            # Person CRUD endpoints
โ”‚   โ”‚   โ””โ”€โ”€ logs.py               # Detection log endpoints
โ”‚   โ”œโ”€โ”€ services/              # Core business logic
โ”‚   โ”‚   โ”œโ”€โ”€ face_service.py       # FaceNet model wrapper
โ”‚   โ”‚   โ””โ”€โ”€ matching.py           # Cosine similarity matching
โ”‚   โ””โ”€โ”€ database/              # Data persistence
โ”‚       โ”œโ”€โ”€ db.py                 # SQLite operations
โ”‚       โ””โ”€โ”€ models.py            # Pydantic models
โ”‚

โš™๏ธ Configuration

Backend

Setting File Default Description
Recognition Threshold services/matching.py 0.45 Minimum cosine similarity for a match
Detection Size services/face_service.py 160ร—160 MTCNN input resolution
CORS Origins main.py localhost:3000 Allowed frontend origins

Frontend

Setting File Default Description
Frame Skip Rate hooks/useFaceDetection.ts 2 Process every Nth frame
API Base URL lib/api.ts http://localhost:8000 Backend API URL
Cache TTL hooks/useRecognition.ts 1500ms Recognition result cache duration
Smoothing Factor hooks/useFaceDetection.ts 0.35 Bounding box EMA smoothing (0-1)

๐Ÿง  Models & Licenses

TrueFace uses the following pre-trained AI models. No training data is included in this repository. Models are downloaded automatically on first run.

Frontend โ€” Browser-Side Detection

Model Source Purpose License
TinyFaceDetector @vladmandic/face-api Real-time face detection in browser MIT
FaceLandmark68Net @vladmandic/face-api 68-point facial landmark detection MIT
FaceRecognitionNet @vladmandic/face-api Face descriptor extraction MIT

@vladmandic/face-api is a modern ES6/TypeScript rewrite of face-api.js by Vladimir Mandic, licensed under MIT.

Backend โ€” Server-Side Recognition

Model Source Purpose License
MTCNN facenet-pytorch Multi-task face detection + alignment MIT
InceptionResnetV1 facenet-pytorch 512-dim face embedding extraction MIT
Pretrained Weights VGGFace2 dataset Face recognition accuracy CC BY-SA 4.0

facenet-pytorch by Tim Esler provides PyTorch implementations of MTCNN and InceptionResnetV1, pretrained on the VGGFace2 dataset. Licensed under MIT.

Additional Dependencies

Package Purpose License
PyTorch Deep learning runtime BSD-3-Clause
FastAPI Python web framework MIT
Next.js React framework MIT
OpenCV Image processing Apache-2.0
Pillow Python image library MIT-CMU

๐Ÿ—บ๏ธ Roadmap

  • Multi-face tracking with individual recognition
  • GPU-accelerated detection via WebGL
  • Face anti-spoofing (liveness detection)
  • Export/import person database
  • Docker containerization
  • Role-based access control
  • Real-time alerts & notifications

๐Ÿค Contributing

Contributions are welcome! Please read the Contributing Guidelines before submitting a pull request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.

You are free to use, modify, and distribute this software for personal and commercial purposes.


๐Ÿ’– Credits

Built with โค๏ธ by

Javed Hussain

Full-Stack Developer & AI Enthusiast

GitHub

Acknowledgments

  • ๐Ÿ™ Vladimir Mandic โ€” for the excellent face-api library
  • ๐Ÿ™ Tim Esler โ€” for facenet-pytorch and pretrained models
  • ๐Ÿ™ VGGFace2 Team โ€” for the training dataset
  • ๐Ÿ™ Vercel โ€” for Next.js and the amazing developer experience
  • ๐Ÿ™ FastAPI Team โ€” for the blazing-fast Python framework

โญ If you found TrueFace useful, please consider giving it a star!

TrueFace v1.0 โ€” Made in India ๐Ÿ‡ฎ๐Ÿ‡ณ

About

TrueFace: Real-Time AI Face Recognition System by Javed Hussain (@iamjaved026). Built with Next.js, FastAPI, FaceNet & WebAssembly. Detect, recognize & register faces instantly in your browser. ๐Ÿš€

Topics

Resources

License

Contributing

Stars

1 star

Watchers

0 watching

Forks

Contributors