A production-ready Face Recognition library powered by ONNX
Project description
similarfaces: High-Performance Face Recognition
A production-ready, clean, and robust face recognition pipeline powered by ONNX Runtime.
🌟 Overview
similarfaces is a streamlined Python library for face detection, alignment, quality assessment, and recognition. It provides a simple functional API and automatically downloads optimized ONNX models on demand.
✨ Key Features
- 🏗️ Simple Functional API:
detect_faces,extract_features,compare_faces,align_face. - 📦 Dictionary-Based Results: Functions return standard Python dicts for easy JSON serialization.
- ⏬ Auto-Downloading: Models are automatically fetched from Hugging Face with a beautiful
tqdmprogress bar. - 🎯 Integrated Quality: Each detected face includes a quality score (0.0 to 1.0).
- ⚡ ONNX Powered: High-speed inference using ONNX Runtime.
🚀 Quick Start
Installation
pip install similarfaces
1. Simple Face Detection
from similarfaces import detect_faces
import cv2
image = cv2.imread("image.jpg")
faces = detect_faces(image)
for face in faces:
print(f"Found face with confidence {face['detection_score']:.2f}")
print(f"Quality Score: {face['quality_score']:.2f}")
print(f"Bounding Box: {face['bbox']}")
print(f"Landmarks: {face['landmarks']}")
2. Compare Two Faces
import cv2
from similarfaces import detect_faces, extract_features, compare_faces
# Load images
img1, img2 = cv2.imread("face1.jpg"), cv2.imread("face2.jpg")
# 1. Detect (returns list of dicts)
face1 = detect_faces(img1)[0]
face2 = detect_faces(img2)[0]
# 2. Extract 512-d embeddings
face1["embedding"] = extract_features(img1, face1)["embedding"]
face2["embedding"] = extract_features(img2, face2)["embedding"]
# 3. Compare (returns 0.0 to 1.0)
similarity = compare_faces(face1, face2)
print(f"Similarity: {similarity:.4f}")
print("Same person!" if similarity > 0.6 else "Different people.")
🛠 Advanced Usage
Using the Face object
If you prefer objects over dictionaries, you can use the Face class:
from similarfaces import detect_faces, Face
faces_dicts = detect_faces(image)
face_obj = Face.from_dict(faces_dicts[0])
# Now use object methods
annotated_img = face_obj.draw(image)
cv2.imwrite("result.jpg", annotated_img)
📝 License
This project is licensed under the MIT License.
Developed with ❤️ by Narek Bektashyan
Project details
Release history Release notifications | RSS feed
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 similarfaces-1.0.2.tar.gz.
File metadata
- Download URL: similarfaces-1.0.2.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae5cf5bf99b33c55a10dc239c7d4fe674110b3b0943c90525fd6957dfa8bee2d
|
|
| MD5 |
fb590ef0d310f199014df59da8d1f324
|
|
| BLAKE2b-256 |
2386e6d4291e2808a039c1ea59544f81bddd1e257ba49e04c3e6a6b67bb9f897
|
File details
Details for the file similarfaces-1.0.2-py3-none-any.whl.
File metadata
- Download URL: similarfaces-1.0.2-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04045ffd1ca4cd75b58e5563a00246d070dd85775ce171ab48c6fce4fa18fc52
|
|
| MD5 |
15cd502d96e72381d83b8a578440b29f
|
|
| BLAKE2b-256 |
c684160137e31ce8886b6d9cf40c88b036e5969176c8ccf061a8f9967d84969e
|