A robust face recognition system built using FaceNet architecture trained on Siamese Framework. The system can identify and classify faces across 16 different celebrity classes with high accuracy.
- Face detection using MTCNN (Multi-task Cascaded Convolutional Networks)
- Face recognition using FaceNet architecture
- Siamese Network training framework with triplet loss
- Real-time face recognition capabilities
- Web interface using Streamlit
- REST API server using FastAPI
- Support for custom dataset training
The system uses a combination of powerful deep learning models:
- MTCNN: For accurate face detection and alignment
- FaceNet: Pre-trained model modified and fine-tuned for feature extraction
- Siamese Network: Training framework using triplet loss (anchor, positive, negative samples)
tensorflow
keras
opencv-python
mtcnn
scikit-learn
joblib
numpy
pandas
streamlit
pillow
requests
tempfile
fastapi
uvicorn
Install dependencies using:
pip install tensorflow keras opencv-python mtcnn scikit-learn joblib numpy pandas streamlit pillow requests tempfile fastapi uvicorn
Before training, ensure your dataset follows this specific structure:
dataset/
├── Class1/
│ ├── img1.jpg
│ ├── img2.jpg
│ └── ...
├── Class2/
│ ├── img1.jpg
│ ├── img2.jpg
│ └── ...
└── ...
Each class should be in a separate folder containing multiple images of the same person/subject. This structure is crucial for the proper functioning of the training pipeline.
To train the model:
python train.py
Important: Before running the training script, you need to modify the train.py file:
- Locate the train_model function call
- Update the data_directory parameter with the path to your dataset:
train_model(data_dir='path/to/your/dataset')
To evaluate model performance:
python evaluate.py
To perform face recognition on images:
python recognize.py
Note: Before running recognition:
- Open recognize.py in your preferred editor
- Locate the image path variable
- Update it with the path to your test image: image_path = 'path/to/your/test/image.jpg'
- Start the server:
cd Server
python main.py
- In a new terminal, start the client:
cd Client
streamlit run client.py
The web interface will be accessible through your browser at localhost:8501
- data_preprocessing.py: Handles dataset preparation and augmentation
- loss.py: Contains implementation of triplet loss function
- model.py: FaceNet model architecture and Siamese network implementation
- recognize.py: Script for face recognition inference
- train.py: Training script with Siamese network
- evaluate.py: Model evaluation script
- Client/: Contains Streamlit web interface
- Server/: Contains FastAPI server implementation and main.py for server startup
Contributions are welcome! Please feel free to submit a Pull Request. Make sure to:
- Fork the repository
- Create a new branch for your feature
- Add your changes
- Submit a pull request with a comprehensive description of changes
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- Thanks to the original FaceNet paper authors
- MTCNN implementation references
- Siamese Networks research papers
- The open-source community for various dependencies
For any queries or support, please open an issue in the repository.
- Clone the repository
- Install dependencies: pip install -r requirements.txt
- Prepare your dataset following the specified structure
- Run the preprocessing script
- Train the model with your dataset
- Start the server and client for the web interface
- Begin recognizing faces!
For detailed troubleshooting and additional information, please refer to the issues section of the repository.