This project is a deep learning-based fingerprint recognition and authorization system. It utilizes a Siamese Neural Network built on top of a pre-trained MobileNetV2 backbone to generate robust fingerprint embeddings. The model learns to map fingerprints from the same user close together while pushing fingerprints from different users apart using Contrastive Loss.
The system includes a complete pipeline for data preprocessing, training, user enrollment, evaluation (EER, FAR, FRR), and a Streamlit-based web application for real-time authentication.
app/: Contains the Streamlit web application (app.py) for the user-facing fingerprint authentication interface.data/: Handles dataset loading, splitting (data_loader.py), and the PyTorch Dataset class (dataset.py) for generating positive and negative Siamese pairs on-the-fly.models/: Defines the neural network architectures (model.py), including theEmbeddingNetand theContrastiveLossfunction.preprocessing/: Containspreprocess.py, responsible for image standardization (Grayscale conversion, CLAHE normalization, and resizing).scripts/:train.py: The main training loop with Automatic Mixed Precision (AMP) and Early Stopping.enrollment.py: Generates the master template database (enrollment_db.pkl) for authorized users.validate.py: Evaluates the model against Genuine and Impostor benchmarks, calculating the Equal Error Rate (EER) and optimal threshold.plot_results.py: Generates ROC curves, distance distributions, and learning curves.
results/: Output directory for trained models, enrollment databases, validation pickles, and plots.
This project is built around the SOCOFing (Sokoto Coventry Fingerprint Dataset). It contains real fingerprint scans alongside synthetically altered versions (Easy, Medium, Hard alterations like obliteration, central rotation, and z-cuts).
The SOCOFing dataset is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license. It is provided strictly for non-commercial, not-for-profit academic research purposes.
If you use this dataset or this project in any publications, technical reports, or manuals, you are required to cite the original dataset authors:
Shehu, Y.I., Ruiz-Garcia, A., Palade, V., James, A. (2018) "Detection of Fingerprint Alterations Using Deep Convolutional Neural Networks" in Proceedings of the International Conference on Artificial Neural Networks (ICANN 2018), Rhodes – Greece.
- Clone the repository and ensure you have Python 3.8+ installed.
- Install dependencies (PyTorch, OpenCV, Scikit-learn, Pandas, Matplotlib, Streamlit, python-dotenv).
- Environment Variables:
- Copy the
.env.samplefile and rename it to.env. - Update the
SOCOFING_DATASET_PATHto point to the root directory of your downloaded SOCOFing dataset.
- Copy the
The project is designed to be run sequentially.
Train the Siamese network to learn fingerprint embeddings. The script features caching options, Mixed Precision (AMP) for speed, and generates a .pth model checkpoint.
python scripts/train.pyNote: Training heavily utilizes the GPU. If you encounter memory issues, lower the BATCH_SIZE in train.py.
Once the model is trained, you need to enroll authorized users. This script processes a subset of genuine users and creates an aggregated, L2-normalized master template for each finger, saving it to results/enrollments/enrollment_db.pkl.
python scripts/enrollment.pyTo determine how accurate the system is, run the validation script. It tests the model against completely unseen Genuine (same user) and Impostor (different user) pairs.
python scripts/validate.pyThis script will output the Equal Error Rate (EER) and determine the optimal authorization threshold. It also reports the False Acceptance Rate (FAR) at strict standard False Rejection Rate (FRR) benchmarks (e.g., 0.1%).
After validating, you can generate visual plots (Learning Curves, Distance Distributions, ROC Curves) to analyze model performance.
python scripts/plot_results.pyPlots will be saved to the results/plots directory.
Launch the Streamlit interface to test the model interactively. You can upload a .BMP fingerprint scan, and the app will process the image, extract its embedding, compare it against the enrollment_db.pkl, and grant or deny access based on the EER threshold.
streamlit run app/app.py- CLAHE Preprocessing: Contrast Limited Adaptive Histogram Equalization is applied to enhance the visibility of fingerprint minutiae (ridges and bifurcations).
- MobileNetV2 Backbone: A lightweight, highly efficient CNN architecture fine-tuned specifically for feature extraction.
- Contrastive Loss: Directly optimizes the Euclidean distance between embedding vectors.
- Robust Enrollment: Master templates are created by averaging multiple authorized scans, resulting in a more stable vector resilient to minor cuts or sensor noise.