Giter Site home page Giter Site logo

facerec's Introduction

Python application CodeQL codecov Quality Gate Status Bugs Code Smells Duplicated Lines (%) Lines of Code Security Rating Sqale Rating Sqale Index Reliability Rating Vulnerabilities

Face Recognition Project

This project uses Flask, FastAPI,DeepFace and MongoDB to create a Face recognition system. It allows users to register face with associated metadata, update their information and also can delete their data.

Get started

These instructions will get you a copy of the project up and running on your local machine for development.

Prerequisites

This project requires Python 3.7 or later.

Installing

  1. Clone this repository to your local system using link

    git clone "https://dev.azure.com/tmspl/FaceRec/_git/FaceRec-Employee-Enrollment.python"
  2. Navigate to the project directory:

    cd FaceRec
  3. Install the required packages:

    pip install -r requirements.txt

Running the Server

To start FLask and FastAPI, run the given command:

python main.py

Project Structure

  • requirements.txt: Contains the Python dependencies for the project.
  • API/: Contains code of FastAPI application.
  • FaceRec/: Contain all files of HTML,CSS and flask application.
  • main.py: Contains code of to start FastAPI and flask together.

Database Schema

  1. Create new connection in MongoDB and Connect using given url URL: mongodb://localhost:27017/8000

  2. Create database using Database name: DatabaseName Collection name: CollectionName

  3. Add data by importing json file: From 'database.mongo' folder -> {DatabaseName}.{CollectionName}.json

The database contains a faceEntries collection with the following schema:

  • 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.

Function Flow

  1. 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.

  2. Data(): This function sent a GET request to /data endpoint of FastAPI app to get the list of Face Entries from MongoDB.

  3. update() :This function is used to update the details of the face entry in the database.

  4. read() : This function sent a GET request with specific Employeecode to read the information related to that particular Employeecode.

  5. delete() : This function is used to delete the specific Employee Data.

Face Recognition Project

This project uses Flask, FastAPI,DeepFace and MongoDB to create a Face recognition system. It allows users to register face with associated metadata, update their information and also can delete their data.

Get started

These instructions will get you a copy of the project up and running on your local machine for development.

Prerequisites

This project requires Python 3.7 or later.

Installing

  1. Clone this repository to your local system using link

    git clone "https://dev.azure.com/tmspl/FaceRec/_git/FaceRec-Employee-Enrollment.python"
  2. Navigate to the project directory:

    cd FaceRec
  3. Install the required packages:

    pip install -r requirements.txt

Running the Server

To start FLask and FastAPI, run the given command:

python main.py

Project Structure

  • requirements.txt: Contains the Python dependencies for the project.
  • API/: Contains code of FastAPI application.
  • FaceRec/: Contain all files of HTML,CSS and flask application.
  • main.py: Contains code of to start FastAPI and flask together.

Database Schema

  1. Create new connection in MongoDB and Connect using given url URL: mongodb://localhost:27017/8000

  2. Create database using Database name: DatabaseName Collection name: CollectionName

  3. Add data by importing json file: From 'database.mongo' folder -> {DatabaseName}.{CollectionName}.json

The database contains a faceEntries collection with the following schema:

  • 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.
  • Images: Base64 encoded image file.

Function Flow

  1. 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.

  2. Data(): This function sent a GET request to /data endpoint of FastAPI app to get the list of Face Entries from MongoDB.

  3. update() :This function is used to update the details of the face entry in the database.

  4. read() : This function sent a GET request with specific Employeecode to read the information related to that particular Employeecode.

  5. delete() : This function is used to delete the specific Employee Data.

Testing

To run the tests, use the following command:

pytest

License

This project is licensed under the APACHE License - see the LICENSE file for details.

facerec's People

Contributors

devasy23 avatar devansh-shah-11 avatar rahul-tmspl avatar pankti-1308 avatar

Stargazers

 avatar

Watchers

 avatar

facerec's Issues

Final Integration Testing

Description

This covers all the unknown errors / issues that may arise while integration of frontend code with the backend endpoints.

Will include testing out the entire Flask application thoroughly to ensure all test cases are being covered

Feature Request: New Endpoint for `recognise_face()`

Feature Request: New Endpoint for recognise_face()

Description

We need a new endpoint, recognise_face(), that accepts a base64 string as input. This endpoint should convert the base64 string into embeddings using the same process as the create_new_faceEntry() endpoint.

Once the embeddings are calculated, the endpoint should run a vector search query on our MongoDB Atlas database. The search should use Euclidean distance as the similarity measure to find the most similar face in the database.

Expected Behavior

The endpoint should return the EmployeeCode and other associated information of the most similar face found in the database. If no similar face is found, the endpoint should return an appropriate error message.

Benefits

This feature will allow us to identify faces from images without having to manually compare the embeddings. This could be useful in a variety of scenarios, such as employee check-in/check-out, security checks, etc.

Tasks

  • Implement the recognise_face() endpoint.
  • Write tests for the new endpoint.
  • Update the API documentation to include the new endpoint.

Elaborate Documentation for API Endpoints

Description

Write a detailed description for each endpoint (what are the inputs it expects, what does it do and what is the expected output, how are the various scenarios handled etc

Benefits

This will cover all the API endpoints and thus, will be easier for the frontend team to modify their code accordingly and will ensure proper readability, even in the future

Feature Request: Testing for `recognise_face()` Endpoint

Feature Request: Testing for recognise_face() Endpoint

Description

Once the recognise_face() endpoint is implemented, we need to create pytest tests to ensure it's working as expected. These tests should cover various scenarios, including successful face recognition, failure due to no matching face in the database, and failure due to invalid input.

Expected Behavior

The tests should confirm that the recognise_face() endpoint correctly identifies a face from a base64 string, returns the correct employee information, and handles errors appropriately.

Benefits

Testing is crucial to ensure the reliability and stability of our application. By testing the recognise_face() endpoint, we can catch any bugs or issues early and ensure that it's working as expected before it's deployed.

Tasks

  • Write a test to verify that the recognise_face() endpoint correctly identifies a face and returns the correct employee information.
  • Write a test to verify that the recognise_face() endpoint returns an appropriate error when there is no matching face in the database.
  • Write a test to verify that the recognise_face() endpoint returns an appropriate error when the input is invalid.
  • Run the tests and fix any issues that are identified.
  • Update the testing documentation to include the new tests.

Feature Request: Migrate Database to MongoDB Atlas and Create Interoperable Functions

Feature Request: Migrate Database to MongoDB Atlas and Create Interoperable Functions

Description

We need to migrate our current local MongoDB database to MongoDB Atlas. This will allow us to leverage the benefits of a cloud database, such as scalability, reliability, and accessibility from anywhere.
In addition, we need to create functions that can be used interchangeably with either the local MongoDB or MongoDB Atlas. This will provide flexibility in our development and testing processes. However, the recognise_face() API endpoint will exclusively use MongoDB Atlas as it requires features available only on the cloud.

Expected Behavior

The functions should be able to operate with either the local MongoDB or MongoDB Atlas based on a configuration setting. The recognise_face() API endpoint should always use MongoDB Atlas.

Benefits

This feature will allow us to leverage the benefits of a cloud database while maintaining the ability to use a local database for certain operations. It will also simplify the codebase by providing a consistent interface for database operations.

Tasks

  • Migrate the existing data from the local MongoDB to MongoDB Atlas.
  • Update the Database class in database.py to support both local MongoDB and MongoDB Atlas.
  • Update the recognise_face() API endpoint to use MongoDB Atlas.
  • Test the new setup to ensure all functions work correctly with both databases.
  • Update the documentation to reflect the new database setup and functions.
Checklist
  • Modify API/database.py828c526 Edit
  • Running GitHub Actions for API/database.pyEdit
  • Modify API/route.py9e19287 Edit
  • Running GitHub Actions for API/route.pyEdit
  • Modify README.mdd4efcd0 Edit
  • Running GitHub Actions for README.mdEdit

Follow up with frontend Team

Description

Follow up with the frontend team and if needed, modify the backend API endpoints according to their requirements to ensure that the entire application is working!

Feature Request: Implement MongoDB Atlas Locally Using Docker [Backlog - Least Priority]

Feature Request: Implement MongoDB Atlas Locally Using Docker [Backlog - Least Priority]

Description

In the future, we may want to consider implementing MongoDB Atlas locally using Docker. MongoDB Atlas offers two options: cloud and Linux. By using Docker, we can create a Linux environment to run MongoDB Atlas locally. This would also pave the way for a potential use case where we want to deploy the application on the cloud and test it online.

Expected Behavior

We should be able to run MongoDB Atlas locally using Docker and switch between the local and cloud versions of MongoDB Atlas based on our needs.

Benefits

This feature would provide us with more flexibility in our development and testing processes. It would also make it easier to test the application in an environment that closely mirrors the production environment.

Tasks

  • Research how to implement MongoDB Atlas locally using Docker.
  • Create a Dockerfile and docker-compose.yml file for the MongoDB Atlas setup.
  • Update the Database class in database.py to support the local MongoDB Atlas setup.
  • Test the new setup to ensure it works correctly.
  • Update the documentation to reflect the new MongoDB Atlas setup.
Checklist
  • Create Dockerfilecd4c92e Edit
  • Running GitHub Actions for DockerfileEdit
  • Create docker-compose.yml2184c60 Edit
  • Running GitHub Actions for docker-compose.ymlEdit
  • Modify API/database.pybcf4f8b Edit
  • Running GitHub Actions for API/database.pyEdit
  • Modify README.md83c38eb Edit
  • Running GitHub Actions for README.mdEdit

Utility Function for Vector Similarity Search

Description
We need a new utility function in Database.py that performs a vector similarity search. This function should take an embedding vector as input and return the most similar vectors from the MongoDB Atlas database using Euclidean distance as the similarity measure.

This utility function will be used by the recognise_face() endpoint to find the most similar face in the database.

Expected Behavior

The endpoint should take n as input from the user and return the top n most similar vectors from MongoDB Database

Benefits
This feature will automate the finding of top n most similar vectors to the given face to help identify the employee

Tasks
Explore the MongoDB vector search tutorial
Write a function to return the most similar vectors

Checklist
  • Modify API/database.pyd6366eb Edit
  • Running GitHub Actions for API/database.pyEdit
  • Modify API/route.py7b8ca4e Edit
  • Running GitHub Actions for API/route.pyEdit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.