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.
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
- Python
- FastAPI
- InsightFace
- OpenCV
- NumPy
- Uvicorn
- PyTorch
- Client uploads images (base64) to generate embeddings.
- The service can extract embeddings for up to 5 images during enrollment.
- Node.js backend stores these embeddings in its database.
- For live attendance, the backend supplies a list of stored embeddings to this microservice.
- Client captures a live base64 frame.
- Service extracts the live face embedding and compares it against stored data using Cosine Similarity.
- A response is returned with match status.
POST /extract-embedding
Input: JSON with images (List of Base64 strings)
Output: Up to 5 embedding vectors for the provided images.
POST /store-retrieve-embeddings
Input: Array of user records with their respective embeddings. Output: Success message and total count of identities loaded into memory.
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.
git clone https://github.com/Yashdafade/Face-Recognition-Microservice
cd ./Face-Recognition-Microservicepython -m venv venv
venv\Scripts\activate # On Windows
# source venv/bin/activate # On Linux/Macpip install -r requirements.txtuvicorn main:app --host 0.0.0.0 --port 8000 --reloadServer runs on:
http://127.0.0.1:8000
Or simply use:
python main.pyThis service is designed to plug into:
- Node.js (Express backend)
- MySQL database
- React frontend
Frontend → Node API → Face Service → Response → Node API → Database
.
├── main.py # Main FastAPI application and routing
├── requirements.txt # Python Dependencies
├── README.md # Project Documentation
- 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).
- 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.
- Advanced handling for Multi-face recognition frames.
- Implement robust Liveness Detection integrations.
- Dockerize the application for easier deployment & cross-platform consistency.
Yash Dafade
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.
- Built as a microservice architecture.
- Handles real-world face matching use cases on the edge.
- Designed for scalability and loose coupling using REST.