Skip to content

Commit

Permalink
Updated README.md (#59)
Browse files Browse the repository at this point in the history
* Updated README.md

* chore: add sequence diagram to readme

* chore: update pre-commit hooks

---------

Co-authored-by: Devasy Patel <[email protected]>
  • Loading branch information
jaidh01 and Devasy23 authored Oct 12, 2024
1 parent 2466d50 commit 6b984ef
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 131 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 24.8.0 # Use the latest stable version of Black
rev: 24.10.0 # Use the latest stable version of Black
hooks:
- id: black

Expand Down
209 changes: 79 additions & 130 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<h1> Face Recognition Project </h1>

**FaceRec** is an innovative face recognition project utilizing **Flask**, **FastAPI**, **DeepFace**, and **MongoDB** to create a Face recognition system. This application empowers users to register faces along with associated metadata, update their information, and delete their data, creating a comprehensive face recognition system.

<p align="center">
<a href="https://github.com/devansh-shah-11/FaceRec/actions/workflows/python-app.yml"><img src="https://github.com/devansh-shah-11/FaceRec/actions/workflows/python-app.yml/badge.svg" alt="Python application"></a>
<a href="https://github.com/devansh-shah-11/FaceRec/actions/workflows/codeql.yml"><img src="https://github.com/devansh-shah-11/FaceRec/actions/workflows/codeql.yml/badge.svg" alt="CodeQL"></a>
Expand All @@ -15,176 +19,121 @@
<a href="https://sonarcloud.io/dashboard?id=Devasy23_FaceRec"><img src="https://sonarcloud.io/api/project_badges/measure?project=Devasy23_FaceRec&metric=vulnerabilities" alt="Vulnerabilities"></a>
</p>

<h1> Face Recognition Project </h1>
## 🚀 Features

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.
- **Real-Time Face Recognition:** Detect and recognize faces seamlessly in real-time.
- **User-Friendly Interface:** Easy to use with a clean design for enhanced user experience.
- **Metadata Management:** Register, update, and delete face entries with ease.
- **Scalable Architecture:** Built to handle multiple users and extensive datasets.

### Get started
## 📦 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development.
These instructions will guide you through setting up the project 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

```bash
git clone https://github.com/Devasy23/FaceRec.git
```
Make sure you have **Python 3.10 or later** installed.

2. Navigate to the project directory:
### Installation Steps

```bash
cd FaceRec
```
1. **Clone the Repository:**
```bash
git clone https://github.com/Devasy23/FaceRec.git
```

3. Install the required packages:

```bash
pip install -r requirements.txt
```
2. **Navigate to the Project Directory:**
```bash
cd FaceRec
```

3. **Install the Required Packages:**
```bash
pip install -r requirements.txt
```

### Running the Server
To start FLask and FastAPI, run the given command:

To start the Flask and FastAPI applications, run the following command:
```bash
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`
Your application will be available at `http://localhost:5000`.

3. Add data by importing json file:
From 'database.mongo' folder -> `{DatabaseName}.{CollectionName}.json`
<details>
<summary> <span style="font-size: 1.5em;"><strong>Project Structure</strong></span></summary>

The database contains a `faceEntries` collection with the following schema:
- `requirements.txt`: Contains the Python dependencies for the project.
- `API/`: Contains the code for the FastAPI application.
- `FaceRec/`: Contains all files related to the HTML, CSS, and Flask application.
- `Model-Training/`: Contains scripts for training models.
- `docs/`: Contains documentation files.
- `test-faces/`: Contains test data for face recognition.
- `main.py`: Contains code to start both FastAPI and Flask applications.

- `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.
</details>

## 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
1. `create_new_faceEntry()`: Receives a POST request with an image and metadata. It extracts the face, calculates the embeddings, and stores the data in the database.
2. `Data()`: Sends a GET request to the `/data` endpoint of the FastAPI app to get the list of Face Entries from MongoDB.
3. `update()`: Updates the details of the face entry in the database.
4. `read()`: Sends a GET request with a specific `Employeecode` to read the related information.
5. `delete()`: Deletes the specific employee data.

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

### Prerequisites
This project requires Python 3.7 or later.
### Installing
1. Clone this repository to your local system using link
```bash
git clone "https://dev.azure.com/tmspl/FaceRec/_git/FaceRec-Employee-Enrollment.python"
```

2. Navigate to the project directory:

```bash
cd FaceRec
```
![image.png](sequence-diagram.png)

3. Install the required packages:
## 🗄️ Database Schema

```bash
pip install -r requirements.txt
```
1. **Create a New Connection in MongoDB** using the following URL:
```
mongodb://localhost:27017/8000
```

2. **Create a Database:**
- **Database Name**: `DatabaseName`
- **Collection Name**: `CollectionName`

### Running the Server
To start FLask and FastAPI, run the given command:
```bash
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.
3. **Import Data by Using a JSON File:**
- From the `database.mongo` folder -> `{DatabaseName}.{CollectionName}.json`

## 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:
### The `faceEntries` Collection Schema:

- `id`: A unique identifier for the face entry.
- `Employeecode`: A unique employee ID associated with the image.
- `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.
- `Department`: The department of the person.
- `time`: The timestamp of when 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.
- `Image`: Base64 encoded image file.

5. `delete()` : This function is used to delete the specific Employee Data.
## 🔄 Function Flow

## Testing
1. **`create_new_faceEntry()`**: 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()`**: Sends a GET request to the `/data` endpoint of the FastAPI app to retrieve the list of face entries from MongoDB.

3. **`update()`**: Updates the details of a face entry in the database.

4. **`read()`**: Sends a GET request with a specific `Employeecode` to retrieve related information.

5. **`delete()`**: Deletes a specific employee's data from the database.

To run the tests, use the following command:
## 🧪 Testing

To run the tests for this project, use the following command:
```bash
pytest
```

## License
## 👥 Our Valuable Contributors ❤️✨
Thanks to all the amazing people who have contributed to **FaceRec**! 💖

[![Contributors](https://contrib.rocks/image?repo=Devasy23/FaceRec)](https://github.com/Devasy23/FaceRec/graphs/contributor)

## 📄 License

This project is licensed under the APACHE License - see the [LICENSE](LICENSE) file for details.
This project is licensed under the **APACHE License** - see the [LICENSE](LICENSE) file for details.
Binary file added sequence-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6b984ef

Please sign in to comment.