Skip to content

Yashdafade/Face-Recognition-Microservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AI Face Recognition Microservice (Schoolix)

A Python-based microservice for face recognition, designed to integrate with the Schoolix system for automated student identification and attendance tracking.

This service exposes REST APIs to generate facial embeddings and compare faces using deep learning models.


Overview

This microservice handles all face recognition logic separately from the main application. It follows a modular approach where the Node.js backend communicates with this service via HTTP APIs.

Core responsibilities:

  • Detect face from image input
  • Generate face embeddings
  • Load stored embeddings into system memory dynamically
  • Compare live face embeddings with stored ones to perform true face matching

Tech Stack

  • Python
  • FastAPI
  • InsightFace
  • OpenCV
  • NumPy
  • Uvicorn
  • PyTorch

How It Works

  1. Client uploads images (base64) to generate embeddings.
  2. The service can extract embeddings for up to 5 images during enrollment.
  3. Node.js backend stores these embeddings in its database.
  4. For live attendance, the backend supplies a list of stored embeddings to this microservice.
  5. Client captures a live base64 frame.
  6. Service extracts the live face embedding and compares it against stored data using Cosine Similarity.
  7. A response is returned with match status.

API Endpoints

1. Extract Embedding

POST /extract-embedding

Input: JSON with images (List of Base64 strings) Output: Up to 5 embedding vectors for the provided images.


2. Store & Retrieve Embeddings

POST /store-retrieve-embeddings

Input: Array of user records with their respective embeddings. Output: Success message and total count of identities loaded into memory.


3. Embed Live Face & Compare

POST /embedd-live-face

Input: Single Base64 image in image field. Output:

  • Similarity status ("Match Found" or "No Match Found")
  • Match details with user information and confidence score.
  • The live face embedding vector.

Setup Instructions

1. Clone Repository

git clone https://github.com/Yashdafade/Face-Recognition-Microservice
cd ./Face-Recognition-Microservice

2. Create Virtual Environment

python -m venv venv
venv\Scripts\activate  # On Windows
# source venv/bin/activate  # On Linux/Mac

3. Install Dependencies

pip install -r requirements.txt

Run the Service

uvicorn main:app --host 0.0.0.0 --port 8000 --reload

Server runs on:

http://127.0.0.1:8000

Or simply use:

python main.py

Integration (Schoolix)

This service is designed to plug into:

  • Node.js (Express backend)
  • MySQL database
  • React frontend

Flow

Frontend → Node API → Face Service → Response → Node API → Database

Project Structure (Simplified)

.
├── main.py            # Main FastAPI application and routing
├── requirements.txt   # Python Dependencies
├── README.md          # Project Documentation

Key Considerations

  • Works best with clear, front-facing images.
  • Expected single face per image.
  • Uses CPU-based inference by default (accelerated by PyTorch GPU if torch.cuda.is_available() is True).

Limitations

  • No anti-spoofing (photo attacks possible natively).
  • Basic handling for multi-face detection (currently relies on faces[0]).
  • RAM consumption can scale depending on peak memory loaded.

Future Improvements

  • Advanced handling for Multi-face recognition frames.
  • Implement robust Liveness Detection integrations.
  • Dockerize the application for easier deployment & cross-platform consistency.

Author

Yash Dafade


Note

This project is originally built as a part of a larger system (Schoolix AI Attendance Application), shared for demonstration purposes and an excellent standalone portfolio project.


Key Highlights

  • Built as a microservice architecture.
  • Handles real-world face matching use cases on the edge.
  • Designed for scalability and loose coupling using REST.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages