High-accuracy face matching library for comparing faces from images, files, or base64 strings.
Project description
face-matching-king
A simple, high-accuracy face matching library for verifying whether two face images belong to the same person.
Compare faces from file paths, numpy arrays, or base64 strings with a single method call.
Installation
pip install face-matching-king
GPU support (CUDA): install with the
gpuextra to getonnxruntime-gpu:pip install "face-matching-king[gpu]"
Quick Start
from face_matching_king import FaceMatcher
matcher = FaceMatcher()
# --- from file paths ---
result = matcher.match_from_path("photo.jpg", "id_card.jpg")
# --- from numpy arrays (BGR, OpenCV format) ---
import cv2
img1 = cv2.imread("photo.jpg")
img2 = cv2.imread("id_card.jpg")
result = matcher.match(img1, img2)
# --- from base64 strings (raw or data-URI) ---
result = matcher.match_from_base64(base64_str_1, base64_str_2)
print(result.similarity) # e.g. 0.82 (display score, 0.0 – 1.0)
print(result.match) # True / False
print(result.threshold) # threshold used for this comparison
print(result.to_dict())
# {
# "similarity": 0.82,
# "match": True,
# "threshold": 0.70,
# }
API Reference
FaceMatcher(threshold, det_size, providers)
| Parameter | Type | Description |
|---|---|---|
threshold |
float |
Similarity cut-off for the match/no-match decision |
det_size |
(int, int) |
Face detector input resolution (default 640×640) |
providers |
list[str] |
ONNX Runtime execution providers |
Methods
| Method | Input | Description |
|---|---|---|
match(img1, img2) |
np.ndarray (BGR) |
Compare two OpenCV images |
match_from_path(p1, p2) |
str | Path |
Compare two image files |
match_from_base64(b1, b2) |
str |
Compare two base64 strings or data-URIs |
All methods accept an optional threshold keyword to override the instance default for a single call.
MatchResult
| Field | Type | Description |
|---|---|---|
similarity |
float |
Display similarity score in the range 0.0 – 1.0 |
match |
bool |
True if similarity >= threshold |
threshold |
float |
Threshold used for this comparison |
License
MIT © Raja Kaushal
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file face_matching_king-0.1.2.tar.gz.
File metadata
- Download URL: face_matching_king-0.1.2.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba060299331b20efec8acf229eff41e47e293031687ea5b5d24c4e34db35b8d3
|
|
| MD5 |
a0311924d31c0d5a2dc71fe7a8119287
|
|
| BLAKE2b-256 |
d921d1424e7d2108ba105017002f0979c5b04aecea277b967ec319781afca454
|
File details
Details for the file face_matching_king-0.1.2-py3-none-any.whl.
File metadata
- Download URL: face_matching_king-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4d66a2a728726c52b0f1ed49ee8f474cb91b23004c78955d040efe369d57e05
|
|
| MD5 |
0a6d058924406d49d1c812fa060df436
|
|
| BLAKE2b-256 |
69ca2fc9bf127e60335b436df2714af398e89083828cc08a17a9f40e6e3f3c92
|