UniFace: A Unified Face Analysis Library for Python | Detection, alignment, landmarks, face-mesh, recognition, parsing, gaze, attributes and anti-spoofing under one API.
Python computer-visiondeep-learningface-alignmentface-analysisface-anonymizationface-anti-spoofingface-attributesface-detectionface-meshface-parsingface-quality-assessmentface-recognitionface-segmentationface-trackingfacial-landmarksgaze-estimationhead-pose-estimationonnxruntimeportrait-mattingpython
feat: Add AdaFace: Quality Adaptive Margin for Face Recognition (#61)
Yakhyokhuja Valikhujaev68179d1e2d1c
diff --git a/docs/concepts/overview.md b/docs/concepts/overview.mdindex b1fa511..4bdf2c7 100644--- a/docs/concepts/overview.md+++ b/docs/concepts/overview.md@@ -98,7 +98,7 @@ def detect(self, image: np.ndarray) -> list[Face]:```uniface/├── detection/ # Face detection (RetinaFace, SCRFD, YOLOv5Face)-├── recognition/ # Face recognition (ArcFace, MobileFace, SphereFace)+├── recognition/ # Face recognition (AdaFace, ArcFace, MobileFace, SphereFace)├── landmark/ # 106-point landmarks├── attribute/ # Age, gender, emotion, race├── parsing/ # Face semantic segmentationdiff --git a/docs/index.md b/docs/index.mdindex 9d8afa8..41108da 100644--- a/docs/index.md+++ b/docs/index.md@@ -31,7 +31,7 @@ ONNX-optimized RetinaFace, SCRFD, and YOLOv5-Face models with 5-point landmarks.<div class="feature-card" markdown>### :material-account-check: Face Recognition-ArcFace, MobileFace, and SphereFace embeddings for identity verification.+AdaFace, ArcFace, MobileFace, and SphereFace embeddings for identity verification.</div><div class="feature-card" markdown>diff --git a/docs/models.md b/docs/models.mdindex 55fc4fe..f0fcd7c 100644--- a/docs/models.md+++ b/docs/models.md@@ -64,6 +64,27 @@ YOLOv5-Face models provide excellent detection accuracy with 5-point facial land## Face Recognition Models+### AdaFace++High-quality face recognition using adaptive margin based on image quality. Achieves state-of-the-art results on challenging benchmarks.++| Model Name | Backbone | Dataset | Size | IJB-B TAR | IJB-C TAR | Use Case |+| ----------- | -------- | ----------- | ------ | --------- | --------- | --------------------- |+| `IR_18` :material-check-circle: | IR-18 | WebFace4M | 92 MB | 93.03% | 94.99% | **Balanced (default)** |+| `IR_101` | IR-101 | WebFace12M | 249 MB | - | 97.66% | Maximum accuracy |++!!! info "Training Data & Accuracy"+ **Dataset**: WebFace4M (4M images) / WebFace12M (12M images)++ **Accuracy**: IJB-B and IJB-C benchmarks, TAR@FAR=0.01%++!!! tip "Key Innovation"+ AdaFace introduces adaptive margin that adjusts based on image quality, providing better performance on low-quality images compared to fixed-margin approaches.++**Reference**: [AdaFace: Quality Adaptive Margin for Face Recognition](https://github.com/mk-minchul/AdaFace) | [ONNX Export](https://github.com/yakhyo/adaface-onnx)++---+### ArcFaceState-of-the-art face recognition using additive angular margin loss.@@ -300,6 +321,8 @@ Models are automatically downloaded and cached on first use.- **RetinaFace Training**: [yakhyo/retinaface-pytorch](https://github.com/yakhyo/retinaface-pytorch) - PyTorch implementation and training code- **YOLOv5-Face Original**: [deepcam-cn/yolov5-face](https://github.com/deepcam-cn/yolov5-face) - Original PyTorch implementation- **YOLOv5-Face ONNX**: [yakhyo/yolov5-face-onnx-inference](https://github.com/yakhyo/yolov5-face-onnx-inference) - ONNX inference implementation+- **AdaFace Original**: [mk-minchul/AdaFace](https://github.com/mk-minchul/AdaFace) - Original PyTorch implementation+- **AdaFace ONNX**: [yakhyo/adaface-onnx](https://github.com/yakhyo/adaface-onnx) - ONNX export and inference- **Face Recognition Training**: [yakhyo/face-recognition](https://github.com/yakhyo/face-recognition) - ArcFace, MobileFace, SphereFace training code- **Gaze Estimation Training**: [yakhyo/gaze-estimation](https://github.com/yakhyo/gaze-estimation) - MobileGaze training code and pretrained weights- **Face Parsing Training**: [yakhyo/face-parsing](https://github.com/yakhyo/face-parsing) - BiSeNet training code and pretrained weights@@ -312,6 +335,7 @@ Models are automatically downloaded and cached on first use.- **RetinaFace**: [Single-Shot Multi-Level Face Localisation in the Wild](https://arxiv.org/abs/1905.00641)- **SCRFD**: [Sample and Computation Redistribution for Efficient Face Detection](https://arxiv.org/abs/2105.04714)- **YOLOv5-Face**: [YOLO5Face: Why Reinventing a Face Detector](https://arxiv.org/abs/2105.12931)+- **AdaFace**: [AdaFace: Quality Adaptive Margin for Face Recognition](https://arxiv.org/abs/2204.00964)- **ArcFace**: [Additive Angular Margin Loss for Deep Face Recognition](https://arxiv.org/abs/1801.07698)- **SphereFace**: [Deep Hypersphere Embedding for Face Recognition](https://arxiv.org/abs/1704.08063)- **BiSeNet**: [Bilateral Segmentation Network for Real-time Semantic Segmentation](https://arxiv.org/abs/1808.00897)diff --git a/docs/modules/recognition.md b/docs/modules/recognition.mdindex e4ea328..4c62599 100644--- a/docs/modules/recognition.md+++ b/docs/modules/recognition.md@@ -8,12 +8,57 @@ Face recognition extracts embeddings for identity verification and face search.| Model | Backbone | Size | Embedding Dim | Best For ||-------|----------|------|---------------|----------|+| **AdaFace** | IR-18/IR-101 | 92-249 MB | 512 | High-quality recognition || **ArcFace** | MobileNet/ResNet | 8-166 MB | 512 | General use (recommended) || **MobileFace** | MobileNet V2/V3 | 1-10 MB | 512 | Mobile/Edge || **SphereFace** | Sphere20/36 | 50-92 MB | 512 | Research |---+## AdaFace++High-quality face recognition using adaptive margin based on image quality. AdaFace achieves state-of-the-art results on challenging benchmarks like IJB-B and IJB-C.++### Basic Usage++```python+from uniface import RetinaFace, AdaFace++detector = RetinaFace()+recognizer = AdaFace()++# 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}") # (1, 512)+```++### Model Variants++```python+from uniface import AdaFace+from uniface.constants import AdaFaceWeights++# Lightweight (default)+recognizer = AdaFace(model_name=AdaFaceWeights.IR_18)++# High accuracy+recognizer = AdaFace(model_name=AdaFaceWeights.IR_101)+```++| Variant | Dataset | Size | IJB-B | IJB-C | Use Case |+|---------|---------|------|-------|-------|----------|+| **IR_18** :material-check-circle: | WebFace4M | 92 MB | 93.03% | 94.99% | Balanced (default) |+| IR_101 | WebFace12M | 249 MB | - | 97.66% | Maximum accuracy |++!!! info "Benchmark Metrics"+ IJB-B and IJB-C accuracy reported as TAR@FAR=0.01%++---+## ArcFaceState-of-the-art recognition using additive angular margin loss.@@ -228,7 +273,9 @@ else:```pythonfrom uniface import create_recognizer+# Available methods: 'arcface', 'adaface', 'mobileface', 'sphereface'recognizer = create_recognizer('arcface')+recognizer = create_recognizer('adaface')```---diff --git a/docs/quickstart.md b/docs/quickstart.mdindex 0a50a2f..0befe80 100644--- a/docs/quickstart.md+++ b/docs/quickstart.md@@ -366,7 +366,7 @@ For detailed model comparisons, benchmarks, and selection guidance, see the [Mod| Detection (balanced) | `RetinaFace` (MNET_V2) | `YOLOv5Face` (YOLOV5S) || Detection (speed) | `RetinaFace` (MNET_025) | `SCRFD` (SCRFD_500M) || Detection (accuracy) | `SCRFD` (SCRFD_10G) | `RetinaFace` (RESNET34) |-| Recognition | `ArcFace` (MNET) | `MobileFace` (MNET_V2) |+| Recognition | `ArcFace` (MNET) | `AdaFace` (IR_18) || Gaze | `MobileGaze` (RESNET34) | `MobileGaze` (MOBILEONE_S0) || Parsing | `BiSeNet` (RESNET18) | `BiSeNet` (RESNET34) |diff --git a/pyproject.toml b/pyproject.tomlindex 49d0f1a..c797963 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[project]name = "uniface"-version = "2.0.2"+version = "2.1.0"description = "UniFace: A Comprehensive Library for Face Detection, Recognition, Landmark Analysis, Face Parsing, Gaze Estimation, Age, and Gender Detection"readme = "README.md"license = "MIT"diff --git a/tests/test_age_gender.py b/tests/test_age_gender.pyindex 109f608..4b29b27 100644--- a/tests/test_age_gender.py+++ b/tests/test_age_gender.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tests/test_factory.py b/tests/test_factory.pyindex c4c2ed1..b2fffaa 100644--- a/tests/test_factory.py+++ b/tests/test_factory.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tests/test_landmark.py b/tests/test_landmark.pyindex a8afe5a..e73b561 100644--- a/tests/test_landmark.py+++ b/tests/test_landmark.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tests/test_parsing.py b/tests/test_parsing.pyindex dbd4b5d..670c5b7 100644--- a/tests/test_parsing.py+++ b/tests/test_parsing.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tests/test_recognition.py b/tests/test_recognition.pyindex 6bbbcee..ac32a2e 100644--- a/tests/test_recognition.py+++ b/tests/test_recognition.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tests/test_retinaface.py b/tests/test_retinaface.pyindex e118129..590174a 100644--- a/tests/test_retinaface.py+++ b/tests/test_retinaface.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tests/test_scrfd.py b/tests/test_scrfd.pyindex bd78018..6c849f7 100644--- a/tests/test_scrfd.py+++ b/tests/test_scrfd.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tests/test_types.py b/tests/test_types.pyindex 97a06ca..9a05cd8 100644--- a/tests/test_types.py+++ b/tests/test_types.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tests/test_utils.py b/tests/test_utils.pyindex 9891e11..5f0dc21 100644--- a/tests/test_utils.py+++ b/tests/test_utils.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tools/age_gender.py b/tools/age_gender.pyindex ab634c6..06ac66d 100644--- a/tools/age_gender.py+++ b/tools/age_gender.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tools/batch_process.py b/tools/batch_process.pyindex 140a351..512c98a 100644--- a/tools/batch_process.py+++ b/tools/batch_process.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tools/detection.py b/tools/detection.pyindex 1b0465d..746c3aa 100644--- a/tools/detection.py+++ b/tools/detection.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tools/face_analyzer.py b/tools/face_analyzer.pyindex fa03836..9b87a47 100644--- a/tools/face_analyzer.py+++ b/tools/face_analyzer.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tools/face_anonymize.py b/tools/face_anonymize.pyindex a413569..ce886b1 100644--- a/tools/face_anonymize.py+++ b/tools/face_anonymize.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tools/face_emotion.py b/tools/face_emotion.pyindex 68997a4..da304ba 100644--- a/tools/face_emotion.py+++ b/tools/face_emotion.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tools/face_parsing.py b/tools/face_parsing.pyindex 799bc9d..1692459 100644--- a/tools/face_parsing.py+++ b/tools/face_parsing.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tools/face_search.py b/tools/face_search.pyindex b82f10f..d038192 100644--- a/tools/face_search.py+++ b/tools/face_search.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tools/fairface.py b/tools/fairface.pyindex 5abad94..0bdd82b 100644--- a/tools/fairface.py+++ b/tools/fairface.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tools/gaze_estimation.py b/tools/gaze_estimation.pyindex d0d6292..ff39cdc 100644--- a/tools/gaze_estimation.py+++ b/tools/gaze_estimation.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tools/landmarks.py b/tools/landmarks.pyindex 48199e5..928445f 100644--- a/tools/landmarks.py+++ b/tools/landmarks.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tools/recognition.py b/tools/recognition.pyindex e64566b..4b12ca5 100644--- a/tools/recognition.py+++ b/tools/recognition.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tools/spoofing.py b/tools/spoofing.pyindex e7a6cb3..19fd6d2 100644--- a/tools/spoofing.py+++ b/tools/spoofing.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/tools/video_detection.py b/tools/video_detection.pyindex e69e81b..7b0cc21 100644--- a/tools/video_detection.py+++ b/tools/video_detection.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/__init__.py b/uniface/__init__.pyindex 96422dd..0270182 100644--- a/uniface/__init__.py+++ b/uniface/__init__.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev## Licensed under the MIT License.# You may obtain a copy of the License at@@ -15,7 +15,7 @@This library provides unified APIs for:- Face detection (RetinaFace, SCRFD, YOLOv5Face)-- Face recognition (ArcFace, MobileFace, SphereFace)+- Face recognition (AdaFace, ArcFace, MobileFace, SphereFace)- Facial landmarks (106-point detection)- Face parsing (semantic segmentation)- Gaze estimation@@ -28,7 +28,7 @@ from __future__ import annotations__license__ = 'MIT'__author__ = 'Yakhyokhuja Valikhujaev'-__version__ = '2.0.2'+__version__ = '2.1.0'from uniface.face_utils import compute_similarity, face_alignmentfrom uniface.log import Logger, enable_logging@@ -49,7 +49,7 @@ from .gaze import MobileGaze, create_gaze_estimatorfrom .landmark import Landmark106, create_landmarkerfrom .parsing import BiSeNet, create_face_parserfrom .privacy import BlurFace, anonymize_faces-from .recognition import ArcFace, MobileFace, SphereFace, create_recognizer+from .recognition import AdaFace, ArcFace, MobileFace, SphereFace, create_recognizerfrom .spoofing import MiniFASNet, create_spooferfrom .types import AttributeResult, EmotionResult, Face, GazeResult, SpoofingResult@@ -82,6 +82,7 @@ __all__ = ['SCRFD','YOLOv5Face',# Recognition models+ 'AdaFace','ArcFace','MobileFace','SphereFace',diff --git a/uniface/analyzer.py b/uniface/analyzer.pyindex 5c966e6..a94775e 100644--- a/uniface/analyzer.py+++ b/uniface/analyzer.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/attribute/__init__.py b/uniface/attribute/__init__.pyindex 7f96923..84ccd03 100644--- a/uniface/attribute/__init__.py+++ b/uniface/attribute/__init__.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/attribute/age_gender.py b/uniface/attribute/age_gender.pyindex cd5798d..7f80a39 100644--- a/uniface/attribute/age_gender.py+++ b/uniface/attribute/age_gender.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/attribute/base.py b/uniface/attribute/base.pyindex 7287846..2fb8e70 100644--- a/uniface/attribute/base.py+++ b/uniface/attribute/base.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/attribute/emotion.py b/uniface/attribute/emotion.pyindex a722427..62b184b 100644--- a/uniface/attribute/emotion.py+++ b/uniface/attribute/emotion.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/attribute/fairface.py b/uniface/attribute/fairface.pyindex abb8e42..b1f9b8d 100644--- a/uniface/attribute/fairface.py+++ b/uniface/attribute/fairface.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/common.py b/uniface/common.pyindex 73207b2..75128e7 100644--- a/uniface/common.py+++ b/uniface/common.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/constants.py b/uniface/constants.pyindex 3cc8cdb..e24c48e 100644--- a/uniface/constants.py+++ b/uniface/constants.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyo@@ -32,6 +32,15 @@ class ArcFaceWeights(str, Enum):MNET = "arcface_mnet"RESNET = "arcface_resnet"++class AdaFaceWeights(str, Enum):+ """+ AdaFace model weights trained on WebFace datasets.+ https://github.com/yakhyo/adaface-onnx+ """+ IR_18 = "adaface_ir_18"+ IR_101 = "adaface_ir_101"+class RetinaFaceWeights(str, Enum):"""Trained on WIDER FACE dataset.@@ -160,6 +169,9 @@ MODEL_URLS: dict[Enum, str] = {# ArcFaceArcFaceWeights.MNET: 'https://github.com/yakhyo/uniface/releases/download/weights/w600k_mbf.onnx',ArcFaceWeights.RESNET: 'https://github.com/yakhyo/uniface/releases/download/weights/w600k_r50.onnx',+ # AdaFace+ AdaFaceWeights.IR_18: 'https://github.com/yakhyo/adaface-onnx/releases/download/weights/adaface_ir_18.onnx',+ AdaFaceWeights.IR_101: 'https://github.com/yakhyo/adaface-onnx/releases/download/weights/adaface_ir_101.onnx',# SCRFDSCRFDWeights.SCRFD_10G_KPS: 'https://github.com/yakhyo/uniface/releases/download/weights/scrfd_10g_kps.onnx',SCRFDWeights.SCRFD_500M_KPS: 'https://github.com/yakhyo/uniface/releases/download/weights/scrfd_500m_kps.onnx',@@ -209,6 +221,9 @@ MODEL_SHA256: dict[Enum, str] = {# ArcFaceArcFaceWeights.MNET: '9cc6e4a75f0e2bf0b1aed94578f144d15175f357bdc05e815e5c4a02b319eb4f',ArcFaceWeights.RESNET: '4c06341c33c2ca1f86781dab0e829f88ad5b64be9fba56e56bc9ebdefc619e43',+ # AdaFace+ AdaFaceWeights.IR_18: '6b6a35772fb636cdd4fa86520c1a259d0c41472a76f70f802b351837a00d9870',+ AdaFaceWeights.IR_101: 'f2eb07d03de0af560a82e1214df799fec5e09375d43521e2868f9dc387e5a43e',# SCRFDSCRFDWeights.SCRFD_10G_KPS: '5838f7fe053675b1c7a08b633df49e7af5495cee0493c7dcf6697200b85b5b91',SCRFDWeights.SCRFD_500M_KPS: '5e4447f50245bbd7966bd6c0fa52938c61474a04ec7def48753668a9d8b4ea3a',diff --git a/uniface/detection/__init__.py b/uniface/detection/__init__.pyindex d7317ed..f9b4b34 100644--- a/uniface/detection/__init__.py+++ b/uniface/detection/__init__.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/detection/base.py b/uniface/detection/base.pyindex 2b700f5..b95e3a1 100644--- a/uniface/detection/base.py+++ b/uniface/detection/base.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/detection/retinaface.py b/uniface/detection/retinaface.pyindex d8d11b6..1866a1d 100644--- a/uniface/detection/retinaface.py+++ b/uniface/detection/retinaface.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/detection/scrfd.py b/uniface/detection/scrfd.pyindex 7d5c750..e683689 100644--- a/uniface/detection/scrfd.py+++ b/uniface/detection/scrfd.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/detection/yolov5.py b/uniface/detection/yolov5.pyindex 7f99771..d8d20ee 100644--- a/uniface/detection/yolov5.py+++ b/uniface/detection/yolov5.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/face_utils.py b/uniface/face_utils.pyindex 7882545..be08775 100644--- a/uniface/face_utils.py+++ b/uniface/face_utils.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/gaze/__init__.py b/uniface/gaze/__init__.pyindex a1a7571..48b4158 100644--- a/uniface/gaze/__init__.py+++ b/uniface/gaze/__init__.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/gaze/base.py b/uniface/gaze/base.pyindex 525fc2d..85c2e52 100644--- a/uniface/gaze/base.py+++ b/uniface/gaze/base.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/gaze/models.py b/uniface/gaze/models.pyindex 26c4a25..032a303 100644--- a/uniface/gaze/models.py+++ b/uniface/gaze/models.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/landmark/__init__.py b/uniface/landmark/__init__.pyindex b851403..e2a20e5 100644--- a/uniface/landmark/__init__.py+++ b/uniface/landmark/__init__.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/landmark/base.py b/uniface/landmark/base.pyindex d167906..4498ddb 100644--- a/uniface/landmark/base.py+++ b/uniface/landmark/base.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/landmark/models.py b/uniface/landmark/models.pyindex 7666f9c..7c2276c 100644--- a/uniface/landmark/models.py+++ b/uniface/landmark/models.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/log.py b/uniface/log.pyindex 5126b9a..7a0fa01 100644--- a/uniface/log.py+++ b/uniface/log.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/model_store.py b/uniface/model_store.pyindex e9688e6..ce8bc7e 100644--- a/uniface/model_store.py+++ b/uniface/model_store.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/onnx_utils.py b/uniface/onnx_utils.pyindex 6df21d9..c232edb 100644--- a/uniface/onnx_utils.py+++ b/uniface/onnx_utils.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/parsing/__init__.py b/uniface/parsing/__init__.pyindex a6e91ab..5613158 100644--- a/uniface/parsing/__init__.py+++ b/uniface/parsing/__init__.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/parsing/base.py b/uniface/parsing/base.pyindex abff023..2472f6b 100644--- a/uniface/parsing/base.py+++ b/uniface/parsing/base.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/parsing/bisenet.py b/uniface/parsing/bisenet.pyindex f22d7f0..5cdd3a3 100644--- a/uniface/parsing/bisenet.py+++ b/uniface/parsing/bisenet.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/privacy/__init__.py b/uniface/privacy/__init__.pyindex a11585d..b825beb 100644--- a/uniface/privacy/__init__.py+++ b/uniface/privacy/__init__.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/privacy/blur.py b/uniface/privacy/blur.pyindex a271e75..0931b55 100644--- a/uniface/privacy/blur.py+++ b/uniface/privacy/blur.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/recognition/__init__.py b/uniface/recognition/__init__.pyindex c836429..139eb96 100644--- a/uniface/recognition/__init__.py+++ b/uniface/recognition/__init__.py@@ -1,8 +1,9 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyo+from .adaface import AdaFacefrom .base import BaseRecognizerfrom .models import ArcFace, MobileFace, SphereFace@@ -13,11 +14,11 @@ def create_recognizer(method: str = 'arcface', **kwargs) -> BaseRecognizer:This function initializes and returns a face recognizer instance based on thespecified method. It acts as a high-level interface to the underlying- model classes like ArcFace, MobileFace, etc.+ model classes like ArcFace, AdaFace, MobileFace, etc.Args:method (str): The recognition method to use.- Options: 'arcface' (default), 'mobileface', 'sphereface'.+ Options: 'arcface' (default), 'adaface', 'mobileface', 'sphereface'.**kwargs: Model-specific parameters passed to the recognizer's constructor.For example, `model_name` can be used to select a specificpre-trained weight from the available enums (e.g., `ArcFaceWeights.MNET`).@@ -32,6 +33,10 @@ def create_recognizer(method: str = 'arcface', **kwargs) -> BaseRecognizer:>>> # Create the default ArcFace recognizer>>> recognizer = create_recognizer()+ >>> # Create an AdaFace recognizer+ >>> from uniface.constants import AdaFaceWeights+ >>> recognizer = create_recognizer('adaface', model_name=AdaFaceWeights.IR_101)+>>> # Create a specific MobileFace recognizer>>> from uniface.constants import MobileFaceWeights>>> recognizer = create_recognizer('mobileface', model_name=MobileFaceWeights.MNET_V2)@@ -43,13 +48,15 @@ def create_recognizer(method: str = 'arcface', **kwargs) -> BaseRecognizer:if method == 'arcface':return ArcFace(**kwargs)+ elif method == 'adaface':+ return AdaFace(**kwargs)elif method == 'mobileface':return MobileFace(**kwargs)elif method == 'sphereface':return SphereFace(**kwargs)else:- available = ['arcface', 'mobileface', 'sphereface']+ available = ['arcface', 'adaface', 'mobileface', 'sphereface']raise ValueError(f"Unsupported method: '{method}'. Available: {available}")-__all__ = ['ArcFace', 'BaseRecognizer', 'MobileFace', 'SphereFace', 'create_recognizer']+__all__ = ['AdaFace', 'ArcFace', 'BaseRecognizer', 'MobileFace', 'SphereFace', 'create_recognizer']diff --git a/uniface/recognition/adaface.py b/uniface/recognition/adaface.pynew file mode 100644index 0000000..795a7e4--- /dev/null+++ b/uniface/recognition/adaface.py@@ -0,0 +1,87 @@+# Copyright 2025-2026 Yakhyokhuja Valikhujaev+# Author: Yakhyokhuja Valikhujaev+# GitHub: https://github.com/yakhyo++from __future__ import annotations++import cv2+import numpy as np++from uniface.constants import AdaFaceWeights+from uniface.model_store import verify_model_weights++from .base import BaseRecognizer, PreprocessConfig++__all__ = ['AdaFace']+++class AdaFace(BaseRecognizer):+ """AdaFace model for high-quality face recognition.++ AdaFace introduces adaptive margin based on image quality, achieving+ state-of-the-art results on challenging benchmarks like IJB-B and IJB-C.++ Key difference from other recognizers: AdaFace uses BGR color space+ (no RGB conversion) during preprocessing.++ Args:+ model_name (AdaFaceWeights): The specific AdaFace model variant to use.+ - IR_18: Smaller model trained on WebFace4M (92 MB)+ - IR_101: Larger model trained on WebFace12M (249 MB)+ Defaults to `AdaFaceWeights.IR_18`.+ preprocessing (Optional[PreprocessConfig]): An optional custom preprocessing+ configuration. If None, a default config for AdaFace is used.++ Example:+ >>> from uniface.recognition import AdaFace+ >>> recognizer = AdaFace()+ >>> # embedding = recognizer.get_normalized_embedding(image, landmarks)++ Reference:+ https://github.com/mk-minchul/AdaFace+ https://github.com/yakhyo/adaface-onnx+ """++ def __init__(+ self,+ model_name: AdaFaceWeights = AdaFaceWeights.IR_18,+ preprocessing: PreprocessConfig | 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)++ def preprocess(self, face_img: np.ndarray) -> np.ndarray:+ """Preprocess the image: resize, normalize, and convert to blob.++ AdaFace uses BGR color space (no RGB conversion).++ Args:+ face_img: Input image in BGR format.++ Returns:+ Preprocessed image as a NumPy array ready for inference.+ """+ resized_img = cv2.resize(face_img, self.input_size)++ if isinstance(self.input_std, list | tuple):+ # Per-channel normalization (keep BGR)+ mean_array = np.array(self.input_mean, dtype=np.float32)+ std_array = np.array(self.input_std, dtype=np.float32)+ normalized_img = (resized_img.astype(np.float32) - mean_array) / std_array++ # Change to NCHW format (batch, channels, height, width)+ blob = np.transpose(normalized_img, (2, 0, 1)) # CHW+ blob = np.expand_dims(blob, axis=0) # NCHW+ else:+ # Single-value normalization using cv2.dnn (keep BGR, swapRB=False)+ blob = cv2.dnn.blobFromImage(+ resized_img,+ scalefactor=1.0 / self.input_std,+ size=self.input_size,+ mean=(self.input_mean, self.input_mean, self.input_mean),+ swapRB=False, # Keep BGR for AdaFace+ )++ return blobdiff --git a/uniface/recognition/base.py b/uniface/recognition/base.pyindex 57f3588..7db6f0a 100644--- a/uniface/recognition/base.py+++ b/uniface/recognition/base.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/recognition/models.py b/uniface/recognition/models.pyindex 18c2689..1ce5917 100644--- a/uniface/recognition/models.py+++ b/uniface/recognition/models.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/spoofing/__init__.py b/uniface/spoofing/__init__.pyindex 2ffa6aa..68a9fc4 100644--- a/uniface/spoofing/__init__.py+++ b/uniface/spoofing/__init__.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/spoofing/base.py b/uniface/spoofing/base.pyindex 7f41b01..52ad5bf 100644--- a/uniface/spoofing/base.py+++ b/uniface/spoofing/base.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/spoofing/minifasnet.py b/uniface/spoofing/minifasnet.pyindex f14b020..5105ecf 100644--- a/uniface/spoofing/minifasnet.py+++ b/uniface/spoofing/minifasnet.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/types.py b/uniface/types.pyindex 1581e22..e7e0c1f 100644--- a/uniface/types.py+++ b/uniface/types.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyodiff --git a/uniface/visualization.py b/uniface/visualization.pyindex 3b034e2..ae95558 100644--- a/uniface/visualization.py+++ b/uniface/visualization.py@@ -1,4 +1,4 @@-# Copyright 2025 Yakhyokhuja Valikhujaev+# Copyright 2025-2026 Yakhyokhuja Valikhujaev# Author: Yakhyokhuja Valikhujaev# GitHub: https://github.com/yakhyo