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.
- 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.
These instructions will guide you through setting up the project on your local machine for development.
Make sure you have Python 3.10 or later installed.
-
Clone the Repository:
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 the Flask and FastAPI applications, run the following command:
python main.py
Your application will be available at http://localhost:5000
.
Project Structure
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.
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.Data()
: Sends a GET request to the/data
endpoint of the FastAPI app to get the list of Face Entries from MongoDB.update()
: Updates the details of the face entry in the database.read()
: Sends a GET request with a specificEmployeecode
to read the related information.delete()
: Deletes the specific employee data.
-
Create a New Connection in MongoDB using the following URL:
mongodb://localhost:27017/8000
-
Create a Database:
- Database Name:
DatabaseName
- Collection Name:
CollectionName
- Database Name:
-
Import Data by Using a JSON File:
- From the
database.mongo
folder ->{DatabaseName}.{CollectionName}.json
- From the
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 timestamp of when the face entry was created.embeddings
: The embeddings of the face image.Image
: Base64 encoded image file.
-
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. -
Data()
: Sends a GET request to the/data
endpoint of the FastAPI app to retrieve the list of face entries from MongoDB. -
update()
: Updates the details of a face entry in the database. -
read()
: Sends a GET request with a specificEmployeecode
to retrieve related information. -
delete()
: Deletes a specific employee's data from the database.
To run the tests for this project, use the following command:
pytest
Thanks to all the amazing people who have contributed to FaceRec! π
For detailed API documentation, please refer to the API Documentation file.
This project is licensed under the APACHE License - see the LICENSE file for details.
deeptune
is a Python package designed to help you fine-tune and train models of siamese architecture. It provides different backend options and loss functions like triplet loss and arcface loss.
- Model Fine-Tuning: Fine-tune pre-trained models with ease.
- Training: Train models with different backend options and loss functions.
- Evaluation: Evaluate models using various metrics.
- CLI Support: Interact with the package through the command line.
To install the package, clone the repository and install the required packages:
git clone https://github.com/Devasy23/FaceRec.git
cd FaceRec/deeptune
pip install -r requirements.txt
The package provides a CLI to interact with the model fine-tuning and training functionalities.
To evaluate a model, use the following command:
python -m deeptune.cli.cli evaluate_model <model_path> <dataset_path>
Replace <model_path>
with the path to your model file and <dataset_path>
with the path to your dataset.
Here is an example of how to use the package in your Python code:
from deeptune.evaluation.eval_mark_I import (
load_and_preprocess_image,
generate_embeddings,
calculate_intra_cluster_distances,
)
from keras.models import load_model
import numpy as np
# Load the pre-trained model
model_path = "path_to_your_model.h5"
model = load_model(model_path)
# Path to the dataset
dataset_path = "path_to_your_dataset"
# Generate embeddings
embeddings, labels = generate_embeddings(model, dataset_path)
# Calculate intra-cluster distances
intra_distances = calculate_intra_cluster_distances(embeddings, labels)
# Output the results
print(f"Intra-Cluster Distances: {intra_distances}")
print(f"Mean Distance: {np.mean(intra_distances)}")
deeptune/
: Main package directory.__init__.py
: Makesdeeptune
a Python package.data/
: Sub-package for data-related functionalities.models/
: Sub-package for model-related functionalities.training/
: Sub-package for training-related functionalities.evaluation/
: Sub-package for evaluation-related functionalities.utils/
: Sub-package for utility functions.cli/
: Sub-package for CLI-related functionalities.config.py
: Configuration file for storing settings or parameters.requirements.txt
: Lists the dependencies for the package.cli/cli.py
: CLI script to interact with the package.
This project is licensed under the APACHE License - see the LICENSE file for details.