A Deep Learning application for one-shot face verification using Triplet Loss.
This project implements a Siamese Neural Network (SNN) designed to perform facial recognition through embedding similarity, rather than traditional classification. By using Triplet Loss, the network learns to minimize the distance between images of the same person (anchor and positive) while maximizing the distance from a different person (negative).
The model was trained on the Celebrity Faces Dataset, achieving near-perfect verification accuracy on 5-, 10-, 15-, and 20-way tests, and 98% accuracy on 25-way tests — demonstrating robust and generalizable embeddings.
- Build a CNN-based embedding model capable of learning discriminative facial features.
- Train the model using Triplet Loss to improve similarity learning.
- Evaluate model performance across multiple n-way identification tests.
- Visualize embeddings and verify the ability to generalize to unseen faces.
- Python 3.10
- TensorFlow / Keras
- NumPy | Matplotlib | OpenCV
- Google Colab + GPU Runtime
- VS Code (local testing)
- Git & GitHub (version control)
The embedding model is a sequential CNN comprising:
- Convolution → BatchNorm → MaxPooling → Dropout (3× blocks)
- Flatten → Dense(128, ReLU)
- Lambda Layer for L2 normalization of embeddings
The embeddings for (anchor, positive, negative) images are concatenated to form the Siamese structure.
| Parameter | Value |
|---|---|
| Optimizer | Adam |
| Loss | Triplet Loss |
| Input Shape | 105×105×1 (grayscale) |
| Embedding Size | 128 |
| Epochs | 10 |
| Batch Size | 4 |
Training Results
Epoch 1–10: Loss steadily reduced to 8.17e-05
Verification Accuracy
| Test Type | Accuracy |
|---|---|
| 5-way | 100% |
| 10-way | 100% |
| 15-way | 100% |
| 20-way | 100% |
| 25-way | 98% |
- Triplet Loss directly optimizes similarity relationships, not classification.
- L2-normalized embeddings stabilize cosine distance comparisons.
- Preprocessing (grayscale, resize, normalize) removed noise and ensured consistency.
- CNN feature extractor learned compact, robust facial representations.
-
Clone the repo:
git clone https://github.com/JDede1/advanced-machine-learning-applications1.git cd advanced-machine-learning-applications1 -
Create and activate your virtual environment:
python3 -m venv ml-env source ml-env/bin/activate # (Linux/Mac) ml-env\Scripts\activate # (Windows)
-
Install dependencies:
pip install -r requirements.txt
-
Run the notebook or Python script:
jupyter notebook notebooks/Facial_recoginition_Project.ipynb # or python notebooks/facial_recoginition_project.py
- Employee or student identity verification systems
- Access control and attendance tracking
- Customer identification in retail / banking
- Face-based authentication for smart devices
- Integrate face detection preprocessing (e.g., MTCNN).
- Use FaceNet-style transfer learning for larger datasets.
- Deploy via FastAPI + TensorFlow Serving for real-time inference.
- Add monitoring (e.g., model drift detection using embeddings).
- Store embeddings securely for privacy compliance.
Ajibola Jeremiah Dedenuola University of Arizona — MIS/ML Program Role: Machine Learning Engineer / Data Scientist GitHub Profile
