The face_matcher is a lightweight Python package powered by DeepFace. It compares a person's ID card photo with a selfie to verify if they belong to the same individual. This is useful in identity verification flows like user onboarding or KYC (Know Your Customer) processes.
- 🔐 Offline & Secure – No external API calls or internet required.
- 🧬 DeepFace Integration – Supports multiple face recognition models.
- 📷 Flexible Input – Works with image files or in-memory images.
- 📊 Matching Logs – Logs confidence score and result (optional).
- 🛠️ Easy to Integrate – Perfect for Python backends (like Django or Flask).
- Compares two images: one from an ID card, and one selfie.
- Uses OpenCV for image handling and processing.
- Detects and compares faces using deep learning.
- Returns a match status (True or False) and confidence score.
- Logs comparison results (optional).
Install required packages from the requirements.txt file:
pip install -r requirements.txtNote: This will install all the necessary dependencies, including
deepface, opencv-python, and any other libraries used in the project.
.
├── face_matcher
│ ├── constants.py
│ ├── face_matcher.py
│ ├── __init__.py
│ ├── logger.py
│ └── utils.py
├── LICENSE
├── README.md
├── requirements.txt
└── tests
├── test_face_matcher.py
├── test_id_card.jpg
└── test_selfie.jpgYou can quickly test the face_matcher using the provided script with built-in sample images:
python tests/test_face_matcher.pyYou can also pass your own ID card and selfie image paths:
python tests/test_face_matcher.py path/to/id_card.jpg path/to/selfie.jpgOr use it directly in your Python or Django project:
from face_matcher import FaceMatcher
matcher = FaceMatcher(id_card_file, selfie_file)
match = matcher.match_faces()
print("Matched!" if match else "No match")You can choose any of the following models:
- ArcFace
- Facenet512
- DeepFace
- Facenet
- VGG-Face
- Dlib
- DeepID
- OpenFace
To use a specific model:
matcher = FaceMatcher(id_card_file, selfie_file, model_name="model_name")This project is licensed under the MIT License.
- Name: Usman Ghani
- GitHub: usman-369
- Name: Imran Nawaz
- GitHub: codewithimran-786
Current Release: 2.0.0
This is the only version available and the recommended one for all users.
(Note: This package is not published on PyPI yet. You can get it directly from GitHub.)