This project uses Flask, FastAPI, DeepFace, and MongoDB to create a face recognition system. It allows users to register faces with associated metadata, update their information, and delete their data.
This project is a facial recognition system designed for employee management using FastAPI, Flask, and MongoDB. The application allows for:
- Storing employee details along with facial embeddings in a MongoDB database.
- Managing employees through an easy-to-use API interface with functionality for creating, reading, updating, and deleting face entries.
- Integrating both FastAPI (for API operations) and Flask (for front-end operations) into a seamless web application.
- Efficient face detection and recognition using state-of-the-art machine learning techniques.
- Facial Recognition: Extract and store facial embeddings from uploaded images.
- Employee Management: Add, update, and delete employee data along with their associated images.
- Database Storage: Store and retrieve data securely using MongoDB.
- API Integration: Provide an API interface to interact with the data.
- Testing: Use Pytest for testing and ensuring the application's reliability.
This application is built with the intent of simplifying employee data management, using facial recognition as the core identification method, ensuring efficiency and security. Whether you're adding a new employee or updating an existing one, this system provides a simple, robust, and scalable solution for managing employee records with facial data.
These instructions will get you a copy of the project up and running on your local machine for development.
This project requires Python 3.7 or later.
-
Clone this repository to your local system using the link:
git clone https://github.com/Devasy23/FaceRec.git
-
Navigate to the project directory:
cd FaceRec
-
Install the required packages:
pip install -r requirements.txt
To start Flask and FastAPI, run the following command:
python main.py
Directory/File | Description |
---|---|
requirements.txt |
Contains the Python dependencies for the project. |
API/ |
Contains code for the FastAPI application. |
FaceRec/ |
Contains all files for the HTML, CSS, and Flask applications. |
main.py |
Contains code to start FastAPI and Flask together. |
Create a new connection in MongoDB and connect using the following URL:
URL: mongodb://localhost:27017/8000
Create the database using:
- Database Name:
DatabaseName
- Collection Name:
CollectionName
Add data by importing the JSON file from the database.mongo
folder:
{DatabaseName}.{CollectionName}.json
The database contains a faceEntries
collection with the following schema:
Field | Description |
---|---|
id |
A unique identifier for the face entry. |
Employeecode |
A unique employee ID associated with the image. |
Name |
The name of the person in the image. |
gender |
The gender of the person. |
Department |
The department of the person. |
time |
The time the face entry was created. |
embeddings |
The embeddings of the face image. |
Image |
Base64 encoded image file. |
-
create_new_faceEntry()
: This function receives a POST request with an image and metadata. It extracts the face from the image, calculates the embeddings, and stores the data in the database. -
Data()
: This function sends a GET request to the/data
endpoint of the FastAPI app to get the list of Face Entries from MongoDB. -
update()
: This function is used to update the details of the face entry in the database. -
read()
: This function sends a GET request with a specific Employeecode to read the information related to that particular Employeecode. -
delete()
: This function deletes specific employee data.
To run the tests, use the following command:
pytest
This project is licensed under the APACHE License - please look at the LICENSE file for details.