Skip to content

A lightweight Python tool that compares a person's selfie with their ID card photo using DeepFace. Designed for local use with no external APIs, making it ideal for secure and offline identity verification workflows.

License

Notifications You must be signed in to change notification settings

usman-369/face-matcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧔‍♂️ Face Matcher for ID Card Verification

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.


🚀 Features

  • 🔐 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).

⚙️ How It Works

  • 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).

📦 Installation

Install required packages from the requirements.txt file:

pip install -r requirements.txt

Note: This will install all the necessary dependencies, including deepface, opencv-python, and any other libraries used in the project.


🗂️ Project Structure

.
├── 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.jpg

🏎️🏁 Quick Start

You can quickly test the face_matcher using the provided script with built-in sample images:

python tests/test_face_matcher.py

You 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.jpg

Or 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")

🖼️ Supported Models

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")

📜 License

This project is licensed under the MIT License.


👤 Author

👤 Contributor


🧾 Version

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.)

About

A lightweight Python tool that compares a person's selfie with their ID card photo using DeepFace. Designed for local use with no external APIs, making it ideal for secure and offline identity verification workflows.

Topics

Resources

License

Stars

Watchers

Forks

Languages