Skip to content

UniFace: A Unified Face Analysis Library for Python | Detection, alignment, landmarks, face-mesh, recognition, parsing, gaze, attributes and anti-spoofing under one API.

feat: Add EdgeFace recognition model (#105)

Yakhyokhuja Valikhujaev9bf54f5f780d
diff --git a/CLAUDE.md b/CLAUDE.md
index 46246ac..a48b7f1 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -54,7 +54,7 @@ pre-commit run --all-files
```
uniface/ # Main package
detection/ # Face detection models (SCRFD, RetinaFace, YOLOv5, YOLOv8)
- recognition/ # Face recognition/verification (AdaFace)
+ recognition/ # Face recognition/verification (AdaFace, ArcFace, EdgeFace, MobileFace, SphereFace)
landmark/ # Facial landmark models
tracking/ # Object tracking (ByteTrack)
parsing/ # Face parsing/segmentation (BiSeNet, XSeg)
diff --git a/README.md b/README.md
index 326a781..045ae97 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@
## Features
- **Face Detection** — RetinaFace, SCRFD, YOLOv5-Face, and YOLOv8-Face with 5-point landmarks
-- **Face Recognition** — ArcFace, MobileFace, and SphereFace embeddings
+- **Face Recognition** — AdaFace, ArcFace, EdgeFace, MobileFace, and SphereFace embeddings
- **Face Tracking** — Multi-object tracking with [BYTETracker](https://github.com/yakhyo/bytetrack-tracker) for persistent IDs across video frames
- **Facial Landmarks** — 106-point landmark localization module (separate from 5-point detector landmarks)
- **Face Parsing** — BiSeNet semantic segmentation (19 classes), XSeg face masking
@@ -242,6 +242,7 @@ https://yakhyo.github.io/uniface/concepts/execution-providers/
| Recognition | MS1MV2 | MobileFace, SphereFace |
| Recognition | WebFace600K | ArcFace |
| Recognition | WebFace4M / 12M | AdaFace |
+| Recognition | MS1MV2 | EdgeFace |
| Gaze | Gaze360 | MobileGaze |
| Head Pose | 300W-LP | HeadPose (ResNet, MobileNet) |
| Parsing | CelebAMask-HQ | BiSeNet |
@@ -273,6 +274,7 @@ If you plan commercial use, verify model license compatibility.
| Detection | [yolov8-face-onnx-inference](https://github.com/yakhyo/yolov8-face-onnx-inference) | - | YOLOv8-Face ONNX Inference |
| Tracking | [bytetrack-tracker](https://github.com/yakhyo/bytetrack-tracker) | - | BYTETracker Multi-Object Tracking |
| Recognition | [face-recognition](https://github.com/yakhyo/face-recognition) | ✓ | MobileFace, SphereFace Training |
+| Recognition | [edgeface-onnx](https://github.com/yakhyo/edgeface-onnx) | - | EdgeFace ONNX Inference |
| Parsing | [face-parsing](https://github.com/yakhyo/face-parsing) | ✓ | BiSeNet Face Parsing |
| Parsing | [face-segmentation](https://github.com/yakhyo/face-segmentation) | - | XSeg Face Segmentation |
| Gaze | [gaze-estimation](https://github.com/yakhyo/gaze-estimation) | ✓ | MobileGaze Training |
diff --git a/docs/concepts/overview.md b/docs/concepts/overview.md
index 4138c38..b97734b 100644
--- a/docs/concepts/overview.md
+++ b/docs/concepts/overview.md
@@ -115,7 +115,7 @@ def detect(self, image: np.ndarray) -> list[Face]:
```
uniface/
├── detection/ # Face detection (RetinaFace, SCRFD, YOLOv5Face, YOLOv8Face)
-├── recognition/ # Face recognition (AdaFace, ArcFace, MobileFace, SphereFace)
+├── recognition/ # Face recognition (AdaFace, ArcFace, EdgeFace, MobileFace, SphereFace)
├── tracking/ # Multi-object tracking (BYTETracker)
├── landmark/ # 106-point landmarks
├── attribute/ # Age, gender, emotion, race
diff --git a/docs/index.md b/docs/index.md
index 1d40e3e..d47f9db 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -36,7 +36,7 @@ ONNX-optimized detectors (RetinaFace, SCRFD, YOLO) with 5-point landmarks.
<div class="feature-card" markdown>
### :material-account-check: Face Recognition
-AdaFace, ArcFace, MobileFace, and SphereFace embeddings for identity verification.
+AdaFace, ArcFace, EdgeFace, MobileFace, and SphereFace embeddings for identity verification.
</div>
<div class="feature-card" markdown>
diff --git a/docs/models.md b/docs/models.md
index bcb4b6f..7e40913 100644
--- a/docs/models.md
+++ b/docs/models.md
@@ -156,6 +156,24 @@ Face recognition using angular softmax loss.
---
+### EdgeFace
+
+Efficient face recognition designed for edge devices, using EdgeNeXt backbone with optional LoRA compression.
+
+| Model Name | Backbone | Params | MFLOPs | Size | LFW | CALFW | CPLFW | CFP-FP | AgeDB-30 |
+| --------------- | -------- | ------ | ------ | ----- | ------ | ------ | ------ | ------ | -------- |
+| `XXS` :material-check-circle: | EdgeNeXt | 1.24M | 94 | ~5 MB | 99.57% | 94.83% | 90.27% | 93.63% | 94.92% |
+| `XS_GAMMA_06` | EdgeNeXt | 1.77M | 154 | ~7 MB | 99.73% | 95.28% | 91.58% | 94.71% | 96.08% |
+| `S_GAMMA_05` | EdgeNeXt | 3.65M | 306 | ~14 MB | 99.78% | 95.55% | 92.48% | 95.74% | 97.03% |
+| `BASE` | EdgeNeXt | 18.2M | 1399 | ~70 MB | 99.83% | 96.07% | 93.75% | 97.01% | 97.60% |
+
+!!! info "Training Data & Reference"
+ **Paper**: [EdgeFace: Efficient Face Recognition Model for Edge Devices](https://arxiv.org/abs/2307.01838v2) (IEEE T-BIOM 2024)
+
+ **Source**: [github.com/otroshi/edgeface](https://github.com/otroshi/edgeface) | [github.com/yakhyo/edgeface-onnx](https://github.com/yakhyo/edgeface-onnx)
+
+---
+
## Facial Landmark Models
### 106-Point Landmark Detection
diff --git a/docs/modules/recognition.md b/docs/modules/recognition.md
index a90493c..d333b36 100644
--- a/docs/modules/recognition.md
+++ b/docs/modules/recognition.md
@@ -15,6 +15,7 @@ Face recognition extracts embeddings for identity verification and face search.
|-------|----------|------|---------------|
| **AdaFace** | IR-18/IR-101 | 92-249 MB | 512 |
| **ArcFace** | MobileNet/ResNet | 8-166 MB | 512 |
+| **EdgeFace** | EdgeNeXt/LoRA | 5-70 MB | 512 |
| **MobileFace** | MobileNet V2/V3 | 1-10 MB | 512 |
| **SphereFace** | Sphere20/36 | 50-92 MB | 512 |
@@ -118,6 +119,64 @@ recognizer = ArcFace(providers=['CPUExecutionProvider'])
---
+## EdgeFace
+
+Efficient face recognition designed for edge devices, using an EdgeNeXt backbone with optional LoRA low-rank compression. Competition-winning entry (compact track) at EFaR 2023, IJCB.
+
+### Basic Usage
+
+```python
+from uniface.detection import RetinaFace
+from uniface.recognition import EdgeFace
+
+detector = RetinaFace()
+recognizer = EdgeFace()
+
+# Detect face
+faces = detector.detect(image)
+
+# Extract embedding
+if faces:
+ embedding = recognizer.get_normalized_embedding(image, faces[0].landmarks)
+ print(f"Embedding shape: {embedding.shape}") # (512,)
+```
+
+### Model Variants
+
+```python
+from uniface.recognition import EdgeFace
+from uniface.constants import EdgeFaceWeights
+
+# Ultra-compact (default)
+recognizer = EdgeFace(model_name=EdgeFaceWeights.XXS)
+
+# Compact with LoRA
+recognizer = EdgeFace(model_name=EdgeFaceWeights.XS_GAMMA_06)
+
+# Small with LoRA
+recognizer = EdgeFace(model_name=EdgeFaceWeights.S_GAMMA_05)
+
+# Full-size
+recognizer = EdgeFace(model_name=EdgeFaceWeights.BASE)
+
+# Force CPU execution
+recognizer = EdgeFace(providers=['CPUExecutionProvider'])
+```
+
+| Variant | Params | MFLOPs | Size | LFW | CALFW | CPLFW | CFP-FP | AgeDB-30 |
+|---------|--------|--------|------|-----|-------|-------|--------|----------|
+| **XXS** :material-check-circle: | 1.24M | 94 | ~5 MB | 99.57% | 94.83% | 90.27% | 93.63% | 94.92% |
+| XS_GAMMA_06 | 1.77M | 154 | ~7 MB | 99.73% | 95.28% | 91.58% | 94.71% | 96.08% |
+| S_GAMMA_05 | 3.65M | 306 | ~14 MB | 99.78% | 95.55% | 92.48% | 95.74% | 97.03% |
+| BASE | 18.2M | 1399 | ~70 MB | 99.83% | 96.07% | 93.75% | 97.01% | 97.60% |
+
+!!! info "Reference"
+ **Paper**: [EdgeFace: Efficient Face Recognition Model for Edge Devices](https://arxiv.org/abs/2307.01838v2) (IEEE T-BIOM 2024)
+
+ **Source**: [github.com/otroshi/edgeface](https://github.com/otroshi/edgeface)
+
+---
+
## MobileFace
Lightweight face recognition models with MobileNet backbones.
@@ -292,9 +351,10 @@ else:
```python
from uniface.recognition import create_recognizer
-# Available methods: 'arcface', 'adaface', 'mobileface', 'sphereface'
+# Available methods: 'arcface', 'adaface', 'edgeface', 'mobileface', 'sphereface'
recognizer = create_recognizer('arcface')
recognizer = create_recognizer('adaface')
+recognizer = create_recognizer('edgeface')
```
---
diff --git a/pyproject.toml b/pyproject.toml
index 21a6254..75966a3 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "uniface"
-version = "3.3.0"
+version = "3.4.0"
description = "UniFace: A Comprehensive Library for Face Detection, Recognition, Tracking, Landmark Analysis, Face Parsing, Gaze Estimation, Age, and Gender Detection"
readme = "README.md"
license = "MIT"
diff --git a/tests/test_factory.py b/tests/test_factory.py
index c98d5ea..f62105e 100644
--- a/tests/test_factory.py
+++ b/tests/test_factory.py
@@ -91,6 +91,12 @@ def test_create_recognizer_sphereface():
assert recognizer is not None, 'Failed to create SphereFace recognizer'
+def test_create_recognizer_edgeface():
+ """Test creating an EdgeFace recognizer using factory function."""
+ recognizer = create_recognizer('edgeface')
+ assert recognizer is not None, 'Failed to create EdgeFace recognizer'
+
+
def test_create_recognizer_invalid_method():
"""
Test that invalid recognizer method raises an error.
diff --git a/tests/test_recognition.py b/tests/test_recognition.py
index fcc3dad..0e3b33b 100644
--- a/tests/test_recognition.py
+++ b/tests/test_recognition.py
@@ -8,7 +8,7 @@ from __future__ import annotations
import numpy as np
import pytest
-from uniface.recognition import ArcFace, MobileFace, SphereFace
+from uniface.recognition import ArcFace, EdgeFace, MobileFace, SphereFace
@pytest.fixture
@@ -35,6 +35,12 @@ def sphereface_model():
return SphereFace()
+def edgeface_model():
+ """Fixture to initialize the EdgeFace model for testing."""
+ return EdgeFace()
+
+
@pytest.fixture
def mock_aligned_face():
"""
@@ -176,6 +182,45 @@ def test_sphereface_normalized_embedding(sphereface_model, mock_landmarks):
assert np.isclose(norm, 1.0, atol=1e-5), f'Normalized embedding should have norm 1.0, got {norm}'
+# EdgeFace Tests
+def test_edgeface_initialization(edgeface_model):
+ """Test that the EdgeFace model initializes correctly."""
+ assert edgeface_model is not None, 'EdgeFace model initialization failed.'
+
+
+def test_edgeface_embedding_shape(edgeface_model, mock_aligned_face):
+ """Test that EdgeFace produces embeddings with the correct shape."""
+ embedding = edgeface_model.get_embedding(mock_aligned_face)
+
+ assert embedding.shape[1] == 512, f'Expected 512-dim embedding, got {embedding.shape[1]}'
+ assert embedding.shape[0] == 1, 'Embedding should have batch dimension of 1'
+
+
+def test_edgeface_normalized_embedding(edgeface_model, mock_landmarks):
+ """Test that EdgeFace normalized embeddings have unit length."""
+ mock_image = np.random.randint(0, 255, (640, 640, 3), dtype=np.uint8)
+
+ embedding = edgeface_model.get_normalized_embedding(mock_image, mock_landmarks)
+
+ assert embedding.shape == (512,), f'Expected shape (512,), got {embedding.shape}'
+ norm = np.linalg.norm(embedding)
+ assert np.isclose(norm, 1.0, atol=1e-5), f'Normalized embedding should have norm 1.0, got {norm}'
+
+
+def test_edgeface_embedding_dtype(edgeface_model, mock_aligned_face):
+ """Test that EdgeFace embeddings have the correct data type."""
+ embedding = edgeface_model.get_embedding(mock_aligned_face)
+ assert embedding.dtype == np.float32, f'Expected float32, got {embedding.dtype}'
+
+
+def test_edgeface_consistency(edgeface_model, mock_aligned_face):
+ """Test that the same input produces the same EdgeFace embedding."""
+ embedding1 = edgeface_model.get_embedding(mock_aligned_face)
+ embedding2 = edgeface_model.get_embedding(mock_aligned_face)
+
+ assert np.allclose(embedding1, embedding2), 'Same input should produce same embedding'
+
+
# Cross-model comparison tests
def test_different_models_different_embeddings(arcface_model, mobileface_model, mock_aligned_face):
"""
diff --git a/tools/download_model.py b/tools/download_model.py
index 2316b19..1b1f1b5 100644
--- a/tools/download_model.py
+++ b/tools/download_model.py
@@ -1,9 +1,11 @@
import argparse
from uniface.constants import (
+ AdaFaceWeights,
AgeGenderWeights,
ArcFaceWeights,
DDAMFNWeights,
+ EdgeFaceWeights,
HeadPoseWeights,
LandmarkWeights,
MobileFaceWeights,
@@ -15,9 +17,11 @@ from uniface.model_store import verify_model_weights
MODEL_TYPES = {
'retinaface': RetinaFaceWeights,
- 'sphereface': SphereFaceWeights,
- 'mobileface': MobileFaceWeights,
+ 'adaface': AdaFaceWeights,
'arcface': ArcFaceWeights,
+ 'edgeface': EdgeFaceWeights,
+ 'mobileface': MobileFaceWeights,
+ 'sphereface': SphereFaceWeights,
'scrfd': SCRFDWeights,
'ddamfn': DDAMFNWeights,
'agegender': AgeGenderWeights,
diff --git a/tools/recognize.py b/tools/recognize.py
index 0d1fd18..c5beaef 100644
--- a/tools/recognize.py
+++ b/tools/recognize.py
@@ -16,16 +16,22 @@ import numpy as np
from uniface.detection import SCRFD, RetinaFace
from uniface.face_utils import compute_similarity
-from uniface.recognition import ArcFace, MobileFace, SphereFace
+from uniface.recognition import AdaFace, ArcFace, EdgeFace, MobileFace, SphereFace
+
+RECOGNIZERS = {
+ 'arcface': ArcFace,
+ 'adaface': AdaFace,
+ 'edgeface': EdgeFace,
+ 'mobileface': MobileFace,
+ 'sphereface': SphereFace,
+}
def get_recognizer(name: str):
- if name == 'arcface':
- return ArcFace()
- elif name == 'mobileface':
- return MobileFace()
- else:
- return SphereFace()
+ cls = RECOGNIZERS.get(name)
+ if cls is None:
+ raise ValueError(f"Unknown recognizer: '{name}'. Available: {list(RECOGNIZERS)}")
+ return cls()
def run_inference(detector, recognizer, image_path: str):
@@ -91,7 +97,7 @@ def main():
'--recognizer',
type=str,
default='arcface',
- choices=['arcface', 'mobileface', 'sphereface'],
+ choices=list(RECOGNIZERS),
)
args = parser.parse_args()
diff --git a/uniface/__init__.py b/uniface/__init__.py
index afd1d7f..f5c0b25 100644
--- a/uniface/__init__.py
+++ b/uniface/__init__.py
@@ -15,7 +15,7 @@
This library provides unified APIs for:
- Face detection (RetinaFace, SCRFD, YOLOv5Face, YOLOv8Face)
-- Face recognition (AdaFace, ArcFace, MobileFace, SphereFace)
+- Face recognition (AdaFace, ArcFace, EdgeFace, MobileFace, SphereFace)
- Face tracking (ByteTrack with Kalman filtering)
- Facial landmarks (106-point detection)
- Face parsing (semantic segmentation)
@@ -30,7 +30,7 @@ from __future__ import annotations
__license__ = 'MIT'
__author__ = 'Yakhyokhuja Valikhujaev'
-__version__ = '3.3.0'
+__version__ = '3.4.0'
import contextlib
@@ -53,7 +53,7 @@ from .headpose import HeadPose, create_head_pose_estimator
from .landmark import Landmark106, create_landmarker
from .parsing import BiSeNet, XSeg, create_face_parser
from .privacy import BlurFace
-from .recognition import AdaFace, ArcFace, MobileFace, SphereFace, create_recognizer
+from .recognition import AdaFace, ArcFace, EdgeFace, MobileFace, SphereFace, create_recognizer
from .spoofing import MiniFASNet, create_spoofer
from .tracking import BYTETracker
from .types import AttributeResult, EmotionResult, Face, GazeResult, HeadPoseResult, SpoofingResult
@@ -87,6 +87,7 @@ __all__ = [
# Recognition models
'AdaFace',
'ArcFace',
+ 'EdgeFace',
'MobileFace',
'SphereFace',
# Landmark models
diff --git a/uniface/constants.py b/uniface/constants.py
index 67e817a..48841e2 100644
--- a/uniface/constants.py
+++ b/uniface/constants.py
@@ -57,6 +57,18 @@ class AdaFaceWeights(str, Enum):
IR_18 = "adaface_ir_18"
IR_101 = "adaface_ir_101"
+class EdgeFaceWeights(str, Enum):
+ """
+ EdgeFace: Efficient Face Recognition Model for Edge Devices.
+ Based on EdgeNeXt backbone with optional LoRA low-rank compression.
+ All models output 512-D embeddings from 112x112 aligned face crops.
+ https://github.com/yakhyo/edgeface-onnx
+ """
+ XXS = "edgeface_xxs"
+ XS_GAMMA_06 = "edgeface_xs_gamma_06"
+ S_GAMMA_05 = "edgeface_s_gamma_05"
+ BASE = "edgeface_base"
+
class RetinaFaceWeights(str, Enum):
"""
Trained on WIDER FACE dataset.
@@ -278,6 +290,24 @@ MODEL_REGISTRY: dict[Enum, ModelInfo] = {
sha256='f2eb07d03de0af560a82e1214df799fec5e09375d43521e2868f9dc387e5a43e'
),
+ # EdgeFace
+ EdgeFaceWeights.XXS: ModelInfo(
+ url='https://github.com/yakhyo/edgeface-onnx/releases/download/weights/edgeface_xxs.onnx',
+ sha256='dc674de4cbc77fa0bf9a82d5149558ab8581d82a2cd3bb60f28fd1a5d3ff8a2f'
+ ),
+ EdgeFaceWeights.XS_GAMMA_06: ModelInfo(
+ url='https://github.com/yakhyo/edgeface-onnx/releases/download/weights/edgeface_xs_gamma_06.onnx',
+ sha256='9206e2eb13a2761d7b5b76e13016d4b9acd3fa3535a9a09939f3adacd139a5ff'
+ ),
+ EdgeFaceWeights.S_GAMMA_05: ModelInfo(
+ url='https://github.com/yakhyo/edgeface-onnx/releases/download/weights/edgeface_s_gamma_05.onnx',
+ sha256='b850767cf791bda585600b5c4c7d7432b2f998ccd862caae34ef1afa967d2e54'
+ ),
+ EdgeFaceWeights.BASE: ModelInfo(
+ url='https://github.com/yakhyo/edgeface-onnx/releases/download/weights/edgeface_base.onnx',
+ sha256='b56942f072c67385f44734b9458b0ccc4a2226888a113f77e0c802ad0c77b4c3'
+ ),
+
# SCRFD
SCRFDWeights.SCRFD_10G_KPS: ModelInfo(
url='https://github.com/yakhyo/uniface/releases/download/weights/scrfd_10g_kps.onnx',
diff --git a/uniface/recognition/__init__.py b/uniface/recognition/__init__.py
index 139eb96..02bb22b 100644
--- a/uniface/recognition/__init__.py
+++ b/uniface/recognition/__init__.py
@@ -4,8 +4,11 @@
from .adaface import AdaFace
+from .arcface import ArcFace
from .base import BaseRecognizer
-from .models import ArcFace, MobileFace, SphereFace
+from .edgeface import EdgeFace
+from .mobileface import MobileFace
+from .sphereface import SphereFace
def create_recognizer(method: str = 'arcface', **kwargs) -> BaseRecognizer:
@@ -18,7 +21,7 @@ def create_recognizer(method: str = 'arcface', **kwargs) -> BaseRecognizer:
Args:
method (str): The recognition method to use.
- Options: 'arcface' (default), 'adaface', 'mobileface', 'sphereface'.
+ Options: 'arcface' (default), 'adaface', 'edgeface', 'mobileface', 'sphereface'.
**kwargs: Model-specific parameters passed to the recognizer's constructor.
For example, `model_name` can be used to select a specific
pre-trained weight from the available enums (e.g., `ArcFaceWeights.MNET`).
@@ -43,6 +46,10 @@ def create_recognizer(method: str = 'arcface', **kwargs) -> BaseRecognizer:
>>> # Create a SphereFace recognizer
>>> recognizer = create_recognizer('sphereface')
+
+ >>> # Create an EdgeFace recognizer
+ >>> from uniface.constants import EdgeFaceWeights
+ >>> recognizer = create_recognizer('edgeface', model_name=EdgeFaceWeights.XXS)
"""
method = method.lower()
@@ -50,13 +57,15 @@ def create_recognizer(method: str = 'arcface', **kwargs) -> BaseRecognizer:
return ArcFace(**kwargs)
elif method == 'adaface':
return AdaFace(**kwargs)
+ elif method == 'edgeface':
+ return EdgeFace(**kwargs)
elif method == 'mobileface':
return MobileFace(**kwargs)
elif method == 'sphereface':
return SphereFace(**kwargs)
else:
- available = ['arcface', 'adaface', 'mobileface', 'sphereface']
+ available = ['arcface', 'adaface', 'edgeface', 'mobileface', 'sphereface']
raise ValueError(f"Unsupported method: '{method}'. Available: {available}")
-__all__ = ['AdaFace', 'ArcFace', 'BaseRecognizer', 'MobileFace', 'SphereFace', 'create_recognizer']
+__all__ = ['AdaFace', 'ArcFace', 'BaseRecognizer', 'EdgeFace', 'MobileFace', 'SphereFace', 'create_recognizer']
diff --git a/uniface/recognition/arcface.py b/uniface/recognition/arcface.py
new file mode 100644
index 0000000..c6ae256
--- /dev/null
+++ b/uniface/recognition/arcface.py
@@ -0,0 +1,49 @@
+# Copyright 2025-2026 Yakhyokhuja Valikhujaev
+# Author: Yakhyokhuja Valikhujaev
+# GitHub: https://github.com/yakhyo
+
+from __future__ import annotations
+
+from uniface.constants import ArcFaceWeights
+from uniface.model_store import verify_model_weights
+
+from .base import BaseRecognizer, PreprocessConfig
+
+__all__ = ['ArcFace']
+
+
+class ArcFace(BaseRecognizer):
+ """ArcFace model for robust face recognition.
+
+ This class provides a concrete implementation of the BaseRecognizer,
+ pre-configured for ArcFace models. It handles the loading of specific
+ ArcFace weights and sets up the appropriate default preprocessing.
+
+ Args:
+ model_name (ArcFaceWeights): The specific ArcFace model variant to use.
+ Defaults to `ArcFaceWeights.MNET`.
+ preprocessing (Optional[PreprocessConfig]): An optional custom preprocessing
+ configuration. If None, a default config for ArcFace is used.
+ providers (list[str] | None): ONNX Runtime execution providers. If None, auto-detects
+ the best available provider. Example: ['CPUExecutionProvider'] to force CPU.
+
+ Example:
+ >>> from uniface.recognition import ArcFace
+ >>> recognizer = ArcFace()
+ >>> # embedding = recognizer.get_normalized_embedding(image, landmarks)
+
+ Reference:
+ https://arxiv.org/abs/1801.07698
+ https://github.com/yakhyo/face-reidentification
+ """
+
+ def __init__(
+ self,
+ model_name: ArcFaceWeights = ArcFaceWeights.MNET,
+ preprocessing: PreprocessConfig | None = None,
+ providers: list[str] | None = None,
+ ) -> None:
+ if preprocessing is None:
+ preprocessing = PreprocessConfig(input_mean=127.5, input_std=127.5, input_size=(112, 112))
+ model_path = verify_model_weights(model_name)
+ super().__init__(model_path=model_path, preprocessing=preprocessing, providers=providers)
diff --git a/uniface/recognition/edgeface.py b/uniface/recognition/edgeface.py
new file mode 100644
index 0000000..de161a7
--- /dev/null
+++ b/uniface/recognition/edgeface.py
@@ -0,0 +1,57 @@
+# Copyright 2025-2026 Yakhyokhuja Valikhujaev
+# Author: Yakhyokhuja Valikhujaev
+# GitHub: https://github.com/yakhyo
+
+from __future__ import annotations
+
+from uniface.constants import EdgeFaceWeights
+from uniface.model_store import verify_model_weights
+
+from .base import BaseRecognizer, PreprocessConfig
+
+__all__ = ['EdgeFace']
+
+
+class EdgeFace(BaseRecognizer):
+ """EdgeFace: Efficient Face Recognition Model for Edge Devices.
+
+ EdgeFace uses an EdgeNeXt backbone with optional LoRA low-rank
+ compression, offering a strong accuracy-efficiency trade-off for
+ deployment on resource-constrained hardware. Competition-winning
+ entry (compact track) at EFaR 2023, IJCB.
+
+ All variants output 512-D embeddings from 112x112 aligned face crops.
+
+ Args:
+ model_name (EdgeFaceWeights): The specific EdgeFace model variant to use.
+ - XXS: Ultra-compact (1.24M params, ~5 MB)
+ - XS_GAMMA_06: Compact with LoRA (1.77M params, ~7 MB)
+ - S_GAMMA_05: Small with LoRA (3.65M params, ~14 MB)
+ - BASE: Full-size model (18.2M params, ~70 MB)
+ Defaults to `EdgeFaceWeights.XXS`.
+ preprocessing (Optional[PreprocessConfig]): An optional custom preprocessing
+ configuration. If None, a default config for EdgeFace is used.
+ providers (list[str] | None): ONNX Runtime execution providers. If None, auto-detects
+ the best available provider. Example: ['CPUExecutionProvider'] to force CPU.
+
+ Example:
+ >>> from uniface.recognition import EdgeFace
+ >>> recognizer = EdgeFace()
+ >>> # embedding = recognizer.get_normalized_embedding(image, landmarks)
+
+ Reference:
+ https://arxiv.org/abs/2307.01838v2
+ https://github.com/otroshi/edgeface
+ https://github.com/yakhyo/edgeface-onnx
+ """
+
+ def __init__(
+ self,
+ model_name: EdgeFaceWeights = EdgeFaceWeights.XXS,
+ preprocessing: PreprocessConfig | None = None,
+ providers: list[str] | None = None,
+ ) -> None:
+ if preprocessing is None:
+ preprocessing = PreprocessConfig(input_mean=127.5, input_std=127.5, input_size=(112, 112))
+ model_path = verify_model_weights(model_name)
+ super().__init__(model_path=model_path, preprocessing=preprocessing, providers=providers)
diff --git a/uniface/recognition/mobileface.py b/uniface/recognition/mobileface.py
new file mode 100644
index 0000000..e5ce092
--- /dev/null
+++ b/uniface/recognition/mobileface.py
@@ -0,0 +1,49 @@
+# Copyright 2025-2026 Yakhyokhuja Valikhujaev
+# Author: Yakhyokhuja Valikhujaev
+# GitHub: https://github.com/yakhyo
+
+from __future__ import annotations
+
+from uniface.constants import MobileFaceWeights
+from uniface.model_store import verify_model_weights
+
+from .base import BaseRecognizer, PreprocessConfig
+
+__all__ = ['MobileFace']
+
+
+class MobileFace(BaseRecognizer):
+ """Lightweight MobileFaceNet model for fast face recognition.
+
+ This class provides a concrete implementation of the BaseRecognizer,
+ pre-configured for MobileFaceNet models. It is optimized for speed,
+ making it suitable for edge devices.
+
+ Args:
+ model_name (MobileFaceWeights): The specific MobileFaceNet model variant to use.
+ Defaults to `MobileFaceWeights.MNET_V2`.
+ preprocessing (Optional[PreprocessConfig]): An optional custom preprocessing
+ configuration. If None, a default config for MobileFaceNet is used.
+ providers (list[str] | None): ONNX Runtime execution providers. If None, auto-detects
+ the best available provider. Example: ['CPUExecutionProvider'] to force CPU.
+
+ Example:
+ >>> from uniface.recognition import MobileFace
+ >>> recognizer = MobileFace()
+ >>> # embedding = recognizer.get_normalized_embedding(image, landmarks)
+
+ Reference:
+ https://arxiv.org/abs/1804.07573
+ https://github.com/yakhyo/face-recognition
+ """
+
+ def __init__(
+ self,
+ model_name: MobileFaceWeights = MobileFaceWeights.MNET_V2,
+ preprocessing: PreprocessConfig | None = None,
+ providers: list[str] | None = None,
+ ) -> None:
+ if preprocessing is None:
+ preprocessing = PreprocessConfig(input_mean=127.5, input_std=127.5, input_size=(112, 112))
+ model_path = verify_model_weights(model_name)
+ super().__init__(model_path=model_path, preprocessing=preprocessing, providers=providers)
diff --git a/uniface/recognition/models.py b/uniface/recognition/models.py
deleted file mode 100644
index 5c23e57..0000000
--- a/uniface/recognition/models.py
+++ /dev/null
@@ -1,112 +0,0 @@
-# Copyright 2025-2026 Yakhyokhuja Valikhujaev
-# Author: Yakhyokhuja Valikhujaev
-# GitHub: https://github.com/yakhyo
-
-from __future__ import annotations
-
-from uniface.constants import ArcFaceWeights, MobileFaceWeights, SphereFaceWeights
-from uniface.model_store import verify_model_weights
-
-from .base import BaseRecognizer, PreprocessConfig
-
-__all__ = ['ArcFace', 'MobileFace', 'SphereFace']
-
-
-class ArcFace(BaseRecognizer):
- """ArcFace model for robust face recognition.
-
- This class provides a concrete implementation of the BaseRecognizer,
- pre-configured for ArcFace models. It handles the loading of specific
- ArcFace weights and sets up the appropriate default preprocessing.
-
- Args:
- model_name (ArcFaceWeights): The specific ArcFace model variant to use.
- Defaults to `ArcFaceWeights.MNET`.
- preprocessing (Optional[PreprocessConfig]): An optional custom preprocessing
- configuration. If None, a default config for ArcFace is used.
- providers (list[str] | None): ONNX Runtime execution providers. If None, auto-detects
- the best available provider. Example: ['CPUExecutionProvider'] to force CPU.
-
- Example:
- >>> from uniface.recognition import ArcFace
- >>> recognizer = ArcFace()
- >>> # embedding = recognizer.get_normalized_embedding(image, landmarks)
- """
-
- def __init__(
- self,
- model_name: ArcFaceWeights = ArcFaceWeights.MNET,
- preprocessing: PreprocessConfig | None = None,
- providers: list[str] | None = None,
- ) -> None:
- if preprocessing is None:
- preprocessing = PreprocessConfig(input_mean=127.5, input_std=127.5, input_size=(112, 112))
- model_path = verify_model_weights(model_name)
- super().__init__(model_path=model_path, preprocessing=preprocessing, providers=providers)
-
-
-class MobileFace(BaseRecognizer):
- """Lightweight MobileFaceNet model for fast face recognition.
-
- This class provides a concrete implementation of the BaseRecognizer,
- pre-configured for MobileFaceNet models. It is optimized for speed,
- making it suitable for edge devices.
-
- Args:
- model_name (MobileFaceWeights): The specific MobileFaceNet model variant to use.
- Defaults to `MobileFaceWeights.MNET_V2`.
- preprocessing (Optional[PreprocessConfig]): An optional custom preprocessing
- configuration. If None, a default config for MobileFaceNet is used.
- providers (list[str] | None): ONNX Runtime execution providers. If None, auto-detects
- the best available provider. Example: ['CPUExecutionProvider'] to force CPU.
-
- Example:
- >>> from uniface.recognition import MobileFace
- >>> recognizer = MobileFace()
- >>> # embedding = recognizer.get_normalized_embedding(image, landmarks)
- """
-
- def __init__(
- self,
- model_name: MobileFaceWeights = MobileFaceWeights.MNET_V2,
- preprocessing: PreprocessConfig | None = None,
- providers: list[str] | None = None,
- ) -> None:
- if preprocessing is None:
- preprocessing = PreprocessConfig(input_mean=127.5, input_std=127.5, input_size=(112, 112))
- model_path = verify_model_weights(model_name)
- super().__init__(model_path=model_path, preprocessing=preprocessing, providers=providers)
-
-
-class SphereFace(BaseRecognizer):
- """SphereFace model using angular margin for face recognition.
-
- This class provides a concrete implementation of the BaseRecognizer,
- pre-configured for SphereFace models, which were among the first to
- introduce angular margin loss functions.
-
- Args:
- model_name (SphereFaceWeights): The specific SphereFace model variant to use.
- Defaults to `SphereFaceWeights.SPHERE20`.
- preprocessing (Optional[PreprocessConfig]): An optional custom preprocessing
- configuration. If None, a default config for SphereFace is used.
- providers (list[str] | None): ONNX Runtime execution providers. If None, auto-detects
- the best available provider. Example: ['CPUExecutionProvider'] to force CPU.
-
- Example:
- >>> from uniface.recognition import SphereFace
- >>> recognizer = SphereFace()
- >>> # embedding = recognizer.get_normalized_embedding(image, landmarks)
- """
-
- def __init__(
- self,
- model_name: SphereFaceWeights = SphereFaceWeights.SPHERE20,
- preprocessing: PreprocessConfig | None = None,
- providers: list[str] | None = None,
- ) -> None:
- if preprocessing is None:
- preprocessing = PreprocessConfig(input_mean=127.5, input_std=127.5, input_size=(112, 112))
-
- model_path = verify_model_weights(model_name)
- super().__init__(model_path=model_path, preprocessing=preprocessing, providers=providers)
diff --git a/uniface/recognition/sphereface.py b/uniface/recognition/sphereface.py
new file mode 100644
index 0000000..8766441
--- /dev/null
+++ b/uniface/recognition/sphereface.py
@@ -0,0 +1,50 @@
+# Copyright 2025-2026 Yakhyokhuja Valikhujaev
+# Author: Yakhyokhuja Valikhujaev
+# GitHub: https://github.com/yakhyo
+
+from __future__ import annotations
+
+from uniface.constants import SphereFaceWeights
+from uniface.model_store import verify_model_weights
+
+from .base import BaseRecognizer, PreprocessConfig
+
+__all__ = ['SphereFace']
+
+
+class SphereFace(BaseRecognizer):
+ """SphereFace model using angular margin for face recognition.
+
+ This class provides a concrete implementation of the BaseRecognizer,
+ pre-configured for SphereFace models, which were among the first to
+ introduce angular margin loss functions.
+
+ Args:
+ model_name (SphereFaceWeights): The specific SphereFace model variant to use.
+ Defaults to `SphereFaceWeights.SPHERE20`.
+ preprocessing (Optional[PreprocessConfig]): An optional custom preprocessing
+ configuration. If None, a default config for SphereFace is used.
+ providers (list[str] | None): ONNX Runtime execution providers. If None, auto-detects
+ the best available provider. Example: ['CPUExecutionProvider'] to force CPU.
+
+ Example:
+ >>> from uniface.recognition import SphereFace
+ >>> recognizer = SphereFace()
+ >>> # embedding = recognizer.get_normalized_embedding(image, landmarks)
+
+ Reference:
+ https://arxiv.org/abs/1704.08063
+ https://github.com/yakhyo/face-recognition
+ """
+
+ def __init__(
+ self,
+ model_name: SphereFaceWeights = SphereFaceWeights.SPHERE20,
+ preprocessing: PreprocessConfig | None = None,
+ providers: list[str] | None = None,
+ ) -> None:
+ if preprocessing is None:
+ preprocessing = PreprocessConfig(input_mean=127.5, input_std=127.5, input_size=(112, 112))
+
+ model_path = verify_model_weights(model_name)
+ super().__init__(model_path=model_path, preprocessing=preprocessing, providers=providers)