2025-12-30 00:20:34 +09:00
|
|
|
# Copyright 2025 Yakhyokhuja Valikhujaev
|
|
|
|
|
# Author: Yakhyokhuja Valikhujaev
|
|
|
|
|
# GitHub: https://github.com/yakhyo
|
|
|
|
|
|
|
|
|
|
"""Tests for factory functions (create_detector, create_recognizer, etc.)."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
import numpy as np
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from uniface import (
|
|
|
|
|
create_detector,
|
|
|
|
|
create_landmarker,
|
|
|
|
|
create_recognizer,
|
|
|
|
|
detect_faces,
|
|
|
|
|
list_available_detectors,
|
|
|
|
|
)
|
|
|
|
|
from uniface.constants import RetinaFaceWeights, SCRFDWeights
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# create_detector tests
|
|
|
|
|
def test_create_detector_retinaface():
|
|
|
|
|
"""
|
|
|
|
|
Test creating a RetinaFace detector using factory function.
|
|
|
|
|
"""
|
2025-11-30 20:32:07 +09:00
|
|
|
detector = create_detector('retinaface')
|
|
|
|
|
assert detector is not None, 'Failed to create RetinaFace detector'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_create_detector_scrfd():
|
|
|
|
|
"""
|
|
|
|
|
Test creating a SCRFD detector using factory function.
|
|
|
|
|
"""
|
2025-11-30 20:32:07 +09:00
|
|
|
detector = create_detector('scrfd')
|
|
|
|
|
assert detector is not None, 'Failed to create SCRFD detector'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_create_detector_with_config():
|
|
|
|
|
"""
|
|
|
|
|
Test creating detector with custom configuration.
|
|
|
|
|
"""
|
|
|
|
|
detector = create_detector(
|
2025-11-30 20:32:07 +09:00
|
|
|
'retinaface',
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
model_name=RetinaFaceWeights.MNET_V2,
|
2025-12-30 00:20:34 +09:00
|
|
|
confidence_threshold=0.8,
|
|
|
|
|
nms_threshold=0.3,
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
)
|
2025-11-30 20:32:07 +09:00
|
|
|
assert detector is not None, 'Failed to create detector with custom config'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_create_detector_invalid_method():
|
|
|
|
|
"""
|
|
|
|
|
Test that invalid detector method raises an error.
|
|
|
|
|
"""
|
|
|
|
|
with pytest.raises((ValueError, KeyError)):
|
2025-11-30 20:32:07 +09:00
|
|
|
create_detector('invalid_method')
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_create_detector_scrfd_with_model():
|
|
|
|
|
"""
|
|
|
|
|
Test creating SCRFD detector with specific model.
|
|
|
|
|
"""
|
2025-12-30 00:20:34 +09:00
|
|
|
detector = create_detector('scrfd', model_name=SCRFDWeights.SCRFD_10G_KPS, confidence_threshold=0.5)
|
2025-11-30 20:32:07 +09:00
|
|
|
assert detector is not None, 'Failed to create SCRFD with specific model'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# create_recognizer tests
|
|
|
|
|
def test_create_recognizer_arcface():
|
|
|
|
|
"""
|
|
|
|
|
Test creating an ArcFace recognizer using factory function.
|
|
|
|
|
"""
|
2025-11-30 20:32:07 +09:00
|
|
|
recognizer = create_recognizer('arcface')
|
|
|
|
|
assert recognizer is not None, 'Failed to create ArcFace recognizer'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_create_recognizer_mobileface():
|
|
|
|
|
"""
|
|
|
|
|
Test creating a MobileFace recognizer using factory function.
|
|
|
|
|
"""
|
2025-11-30 20:32:07 +09:00
|
|
|
recognizer = create_recognizer('mobileface')
|
|
|
|
|
assert recognizer is not None, 'Failed to create MobileFace recognizer'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_create_recognizer_sphereface():
|
|
|
|
|
"""
|
|
|
|
|
Test creating a SphereFace recognizer using factory function.
|
|
|
|
|
"""
|
2025-11-30 20:32:07 +09:00
|
|
|
recognizer = create_recognizer('sphereface')
|
|
|
|
|
assert recognizer is not None, 'Failed to create SphereFace recognizer'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_create_recognizer_invalid_method():
|
|
|
|
|
"""
|
|
|
|
|
Test that invalid recognizer method raises an error.
|
|
|
|
|
"""
|
|
|
|
|
with pytest.raises((ValueError, KeyError)):
|
2025-11-30 20:32:07 +09:00
|
|
|
create_recognizer('invalid_method')
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# create_landmarker tests
|
|
|
|
|
def test_create_landmarker():
|
|
|
|
|
"""
|
|
|
|
|
Test creating a Landmark106 detector using factory function.
|
|
|
|
|
"""
|
2025-11-30 20:32:07 +09:00
|
|
|
landmarker = create_landmarker('2d106det')
|
|
|
|
|
assert landmarker is not None, 'Failed to create Landmark106 detector'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_create_landmarker_default():
|
|
|
|
|
"""
|
|
|
|
|
Test creating landmarker with default parameters.
|
|
|
|
|
"""
|
|
|
|
|
landmarker = create_landmarker()
|
2025-11-30 20:32:07 +09:00
|
|
|
assert landmarker is not None, 'Failed to create default landmarker'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_create_landmarker_invalid_method():
|
|
|
|
|
"""
|
|
|
|
|
Test that invalid landmarker method raises an error.
|
|
|
|
|
"""
|
|
|
|
|
with pytest.raises((ValueError, KeyError)):
|
2025-11-30 20:32:07 +09:00
|
|
|
create_landmarker('invalid_method')
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# detect_faces tests
|
|
|
|
|
def test_detect_faces_retinaface():
|
|
|
|
|
"""
|
|
|
|
|
Test high-level detect_faces function with RetinaFace.
|
|
|
|
|
"""
|
|
|
|
|
mock_image = np.random.randint(0, 255, (640, 640, 3), dtype=np.uint8)
|
2025-11-30 20:32:07 +09:00
|
|
|
faces = detect_faces(mock_image, method='retinaface')
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
2025-11-30 20:32:07 +09:00
|
|
|
assert isinstance(faces, list), 'detect_faces should return a list'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_detect_faces_scrfd():
|
|
|
|
|
"""
|
|
|
|
|
Test high-level detect_faces function with SCRFD.
|
|
|
|
|
"""
|
|
|
|
|
mock_image = np.random.randint(0, 255, (640, 640, 3), dtype=np.uint8)
|
2025-11-30 20:32:07 +09:00
|
|
|
faces = detect_faces(mock_image, method='scrfd')
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
2025-11-30 20:32:07 +09:00
|
|
|
assert isinstance(faces, list), 'detect_faces should return a list'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_detect_faces_with_threshold():
|
|
|
|
|
"""
|
|
|
|
|
Test detect_faces with custom confidence threshold.
|
|
|
|
|
"""
|
|
|
|
|
mock_image = np.random.randint(0, 255, (640, 640, 3), dtype=np.uint8)
|
2025-12-30 00:20:34 +09:00
|
|
|
faces = detect_faces(mock_image, method='retinaface', confidence_threshold=0.8)
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
2025-11-30 20:32:07 +09:00
|
|
|
assert isinstance(faces, list), 'detect_faces should return a list'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
# All detections should respect threshold
|
|
|
|
|
for face in faces:
|
2025-12-30 00:20:34 +09:00
|
|
|
assert face.confidence >= 0.8, 'All detections should meet confidence threshold'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_detect_faces_default_method():
|
|
|
|
|
"""
|
|
|
|
|
Test detect_faces with default method (should use retinaface).
|
|
|
|
|
"""
|
|
|
|
|
mock_image = np.random.randint(0, 255, (640, 640, 3), dtype=np.uint8)
|
|
|
|
|
faces = detect_faces(mock_image) # No method specified
|
|
|
|
|
|
2025-11-30 20:32:07 +09:00
|
|
|
assert isinstance(faces, list), 'detect_faces should return a list with default method'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_detect_faces_empty_image():
|
|
|
|
|
"""
|
|
|
|
|
Test detect_faces on a blank image.
|
|
|
|
|
"""
|
|
|
|
|
empty_image = np.zeros((640, 640, 3), dtype=np.uint8)
|
2025-11-30 20:32:07 +09:00
|
|
|
faces = detect_faces(empty_image, method='retinaface')
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
2025-11-30 20:32:07 +09:00
|
|
|
assert isinstance(faces, list), 'Should return a list even for empty image'
|
|
|
|
|
assert len(faces) == 0, 'Should detect no faces in blank image'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# list_available_detectors tests
|
|
|
|
|
def test_list_available_detectors():
|
|
|
|
|
"""
|
|
|
|
|
Test that list_available_detectors returns a dictionary.
|
|
|
|
|
"""
|
|
|
|
|
detectors = list_available_detectors()
|
|
|
|
|
|
2025-11-30 20:32:07 +09:00
|
|
|
assert isinstance(detectors, dict), 'Should return a dictionary of detectors'
|
|
|
|
|
assert len(detectors) > 0, 'Should have at least one detector available'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_list_available_detectors_contents():
|
|
|
|
|
"""
|
|
|
|
|
Test that list includes known detectors.
|
|
|
|
|
"""
|
|
|
|
|
detectors = list_available_detectors()
|
|
|
|
|
|
|
|
|
|
# Should include at least these detectors
|
2025-11-30 20:32:07 +09:00
|
|
|
assert 'retinaface' in detectors, "Should include 'retinaface'"
|
|
|
|
|
assert 'scrfd' in detectors, "Should include 'scrfd'"
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Integration tests
|
|
|
|
|
def test_detector_inference_from_factory():
|
|
|
|
|
"""
|
|
|
|
|
Test that detector created from factory can perform inference.
|
|
|
|
|
"""
|
2025-11-30 20:32:07 +09:00
|
|
|
detector = create_detector('retinaface')
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
mock_image = np.random.randint(0, 255, (640, 640, 3), dtype=np.uint8)
|
|
|
|
|
|
|
|
|
|
faces = detector.detect(mock_image)
|
2025-11-30 20:32:07 +09:00
|
|
|
assert isinstance(faces, list), 'Detector should return list of faces'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_recognizer_inference_from_factory():
|
|
|
|
|
"""
|
|
|
|
|
Test that recognizer created from factory can perform inference.
|
|
|
|
|
"""
|
2025-11-30 20:32:07 +09:00
|
|
|
recognizer = create_recognizer('arcface')
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
mock_image = np.random.randint(0, 255, (112, 112, 3), dtype=np.uint8)
|
|
|
|
|
|
|
|
|
|
embedding = recognizer.get_embedding(mock_image)
|
2025-11-30 20:32:07 +09:00
|
|
|
assert embedding is not None, 'Recognizer should return embedding'
|
|
|
|
|
assert embedding.shape[1] == 512, 'Should return 512-dimensional embedding'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_landmarker_inference_from_factory():
|
|
|
|
|
"""
|
|
|
|
|
Test that landmarker created from factory can perform inference.
|
|
|
|
|
"""
|
2025-11-30 20:32:07 +09:00
|
|
|
landmarker = create_landmarker('2d106det')
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
mock_image = np.random.randint(0, 255, (640, 640, 3), dtype=np.uint8)
|
|
|
|
|
mock_bbox = [100, 100, 300, 300]
|
|
|
|
|
|
|
|
|
|
landmarks = landmarker.get_landmarks(mock_image, mock_bbox)
|
2025-11-30 20:32:07 +09:00
|
|
|
assert landmarks is not None, 'Landmarker should return landmarks'
|
|
|
|
|
assert landmarks.shape == (106, 2), 'Should return 106 landmarks'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_multiple_detector_creation():
|
|
|
|
|
"""
|
|
|
|
|
Test that multiple detectors can be created independently.
|
|
|
|
|
"""
|
2025-11-30 20:32:07 +09:00
|
|
|
detector1 = create_detector('retinaface')
|
|
|
|
|
detector2 = create_detector('scrfd')
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
assert detector1 is not None
|
|
|
|
|
assert detector2 is not None
|
2025-11-30 20:32:07 +09:00
|
|
|
assert detector1 is not detector2, 'Should create separate instances'
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_detector_with_different_configs():
|
|
|
|
|
"""
|
|
|
|
|
Test creating multiple detectors with different configurations.
|
|
|
|
|
"""
|
2025-12-30 00:20:34 +09:00
|
|
|
detector_high_thresh = create_detector('retinaface', confidence_threshold=0.9)
|
|
|
|
|
detector_low_thresh = create_detector('retinaface', confidence_threshold=0.3)
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
|
|
|
|
mock_image = np.random.randint(0, 255, (640, 640, 3), dtype=np.uint8)
|
|
|
|
|
|
|
|
|
|
faces_high = detector_high_thresh.detect(mock_image)
|
|
|
|
|
faces_low = detector_low_thresh.detect(mock_image)
|
|
|
|
|
|
|
|
|
|
# Both should work
|
|
|
|
|
assert isinstance(faces_high, list)
|
|
|
|
|
assert isinstance(faces_low, list)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_factory_returns_correct_types():
|
|
|
|
|
"""
|
|
|
|
|
Test that factory functions return instances of the correct types.
|
|
|
|
|
"""
|
2025-12-03 23:35:56 +09:00
|
|
|
from uniface import ArcFace, Landmark106, RetinaFace
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
2025-11-30 20:32:07 +09:00
|
|
|
detector = create_detector('retinaface')
|
|
|
|
|
recognizer = create_recognizer('arcface')
|
|
|
|
|
landmarker = create_landmarker('2d106det')
|
ref: Add comprehensive test suite and enhance model functionality
- Add new test files for age_gender, factory, landmark, recognition, scrfd, and utils
- Add new scripts for age_gender, landmarks, and video detection
- Update documentation in README.md, MODELS.md, QUICKSTART.md
- Improve model constants and face utilities
- Update detection models (retinaface, scrfd) with enhanced functionality
- Update project configuration in pyproject.toml
2025-11-15 21:09:37 +09:00
|
|
|
|
2025-11-30 20:32:07 +09:00
|
|
|
assert isinstance(detector, RetinaFace), 'Should return RetinaFace instance'
|
|
|
|
|
assert isinstance(recognizer, ArcFace), 'Should return ArcFace instance'
|
|
|
|
|
assert isinstance(landmarker, Landmark106), 'Should return Landmark106 instance'
|