A deep learning-based face search application using two different models: MobileFaceNet and InsightFace.
- Download images from Google Drive using PyDrive.
- Detect and extract faces using MTCNN or InsightFace's built-in detector.
- Generate face embeddings with either MobileFaceNet or InsightFace.
- Search for similar faces in a directory using cosine similarity.
- Save matched results with bounding boxes.
-
MobileFaceNet:
Used insearchUsingMobileNet.py. This script uses MTCNN for face detection and MobileFaceNet for generating face embeddings. It is suitable for lightweight, efficient face recognition tasks. -
InsightFace:
Used insearchUsingInsightFace.py. This script leverages the InsightFace library for both face detection and embedding extraction, providing robust and accurate face recognition.
- Python 3.8+
- PyTorch
- torchvision
- scikit-learn
- opencv-python
- mtcnn
- insightface
- PyDrive
-
Clone the repository:
git clone https://github.com/your-username/FaceSearch.git cd FaceSearch -
Install dependencies:
pip install -r requirements.txt
-
Google Drive API setup:
- Place your
client_secrets.jsonin the project directory. - Enable the Google Drive API for your Google Cloud project.
- Place your
-
Download images from Google Drive:
python downloadPydrive.py
-
Run face search with MobileFaceNet:
python searchUsingMobileNet.py
-
Run face search with InsightFace:
python faceSearch.py
downloadPydrive.py- Downloads images from a Google Drive folder.searchUsingMobileNet.py- Searches for similar faces using MobileFaceNet.searchUsingInsightFace.py- Searches for similar faces using InsightFace.mobileFaceNet.py- MobileFaceNet model definition.client_secrets.json- Google API credentials (not tracked by git).output/- Saved images with matched faces.
- Make sure to update
reference_image_pathandsearch_directoryin the scripts as needed. - Model checkpoint file (
*.ckpt) should be present in the project directory for MobileFaceNet.
This project is for educational purposes.