mirror of
https://github.com/yakhyo/uniface.git
synced 2025-12-30 09:02:25 +00:00
chore: Code style formatting changes
This commit is contained in:
@@ -16,7 +16,7 @@ def test_create_detector_retinaface():
|
||||
"""
|
||||
Test creating a RetinaFace detector using factory function.
|
||||
"""
|
||||
detector = create_detector('retinaface')
|
||||
detector = create_detector("retinaface")
|
||||
assert detector is not None, "Failed to create RetinaFace detector"
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ def test_create_detector_scrfd():
|
||||
"""
|
||||
Test creating a SCRFD detector using factory function.
|
||||
"""
|
||||
detector = create_detector('scrfd')
|
||||
detector = create_detector("scrfd")
|
||||
assert detector is not None, "Failed to create SCRFD detector"
|
||||
|
||||
|
||||
@@ -33,10 +33,10 @@ def test_create_detector_with_config():
|
||||
Test creating detector with custom configuration.
|
||||
"""
|
||||
detector = create_detector(
|
||||
'retinaface',
|
||||
"retinaface",
|
||||
model_name=RetinaFaceWeights.MNET_V2,
|
||||
conf_thresh=0.8,
|
||||
nms_thresh=0.3
|
||||
nms_thresh=0.3,
|
||||
)
|
||||
assert detector is not None, "Failed to create detector with custom config"
|
||||
|
||||
@@ -46,18 +46,14 @@ def test_create_detector_invalid_method():
|
||||
Test that invalid detector method raises an error.
|
||||
"""
|
||||
with pytest.raises((ValueError, KeyError)):
|
||||
create_detector('invalid_method')
|
||||
create_detector("invalid_method")
|
||||
|
||||
|
||||
def test_create_detector_scrfd_with_model():
|
||||
"""
|
||||
Test creating SCRFD detector with specific model.
|
||||
"""
|
||||
detector = create_detector(
|
||||
'scrfd',
|
||||
model_name=SCRFDWeights.SCRFD_10G_KPS,
|
||||
conf_thresh=0.5
|
||||
)
|
||||
detector = create_detector("scrfd", model_name=SCRFDWeights.SCRFD_10G_KPS, conf_thresh=0.5)
|
||||
assert detector is not None, "Failed to create SCRFD with specific model"
|
||||
|
||||
|
||||
@@ -66,7 +62,7 @@ def test_create_recognizer_arcface():
|
||||
"""
|
||||
Test creating an ArcFace recognizer using factory function.
|
||||
"""
|
||||
recognizer = create_recognizer('arcface')
|
||||
recognizer = create_recognizer("arcface")
|
||||
assert recognizer is not None, "Failed to create ArcFace recognizer"
|
||||
|
||||
|
||||
@@ -74,7 +70,7 @@ def test_create_recognizer_mobileface():
|
||||
"""
|
||||
Test creating a MobileFace recognizer using factory function.
|
||||
"""
|
||||
recognizer = create_recognizer('mobileface')
|
||||
recognizer = create_recognizer("mobileface")
|
||||
assert recognizer is not None, "Failed to create MobileFace recognizer"
|
||||
|
||||
|
||||
@@ -82,7 +78,7 @@ def test_create_recognizer_sphereface():
|
||||
"""
|
||||
Test creating a SphereFace recognizer using factory function.
|
||||
"""
|
||||
recognizer = create_recognizer('sphereface')
|
||||
recognizer = create_recognizer("sphereface")
|
||||
assert recognizer is not None, "Failed to create SphereFace recognizer"
|
||||
|
||||
|
||||
@@ -91,7 +87,7 @@ def test_create_recognizer_invalid_method():
|
||||
Test that invalid recognizer method raises an error.
|
||||
"""
|
||||
with pytest.raises((ValueError, KeyError)):
|
||||
create_recognizer('invalid_method')
|
||||
create_recognizer("invalid_method")
|
||||
|
||||
|
||||
# create_landmarker tests
|
||||
@@ -99,7 +95,7 @@ def test_create_landmarker():
|
||||
"""
|
||||
Test creating a Landmark106 detector using factory function.
|
||||
"""
|
||||
landmarker = create_landmarker('2d106det')
|
||||
landmarker = create_landmarker("2d106det")
|
||||
assert landmarker is not None, "Failed to create Landmark106 detector"
|
||||
|
||||
|
||||
@@ -116,7 +112,7 @@ def test_create_landmarker_invalid_method():
|
||||
Test that invalid landmarker method raises an error.
|
||||
"""
|
||||
with pytest.raises((ValueError, KeyError)):
|
||||
create_landmarker('invalid_method')
|
||||
create_landmarker("invalid_method")
|
||||
|
||||
|
||||
# detect_faces tests
|
||||
@@ -125,7 +121,7 @@ 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)
|
||||
faces = detect_faces(mock_image, method='retinaface')
|
||||
faces = detect_faces(mock_image, method="retinaface")
|
||||
|
||||
assert isinstance(faces, list), "detect_faces should return a list"
|
||||
|
||||
@@ -135,7 +131,7 @@ 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)
|
||||
faces = detect_faces(mock_image, method='scrfd')
|
||||
faces = detect_faces(mock_image, method="scrfd")
|
||||
|
||||
assert isinstance(faces, list), "detect_faces should return a list"
|
||||
|
||||
@@ -145,13 +141,13 @@ 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)
|
||||
faces = detect_faces(mock_image, method='retinaface', conf_thresh=0.8)
|
||||
faces = detect_faces(mock_image, method="retinaface", conf_thresh=0.8)
|
||||
|
||||
assert isinstance(faces, list), "detect_faces should return a list"
|
||||
|
||||
# All detections should respect threshold
|
||||
for face in faces:
|
||||
assert face['confidence'] >= 0.8, "All detections should meet confidence threshold"
|
||||
assert face["confidence"] >= 0.8, "All detections should meet confidence threshold"
|
||||
|
||||
|
||||
def test_detect_faces_default_method():
|
||||
@@ -169,7 +165,7 @@ def test_detect_faces_empty_image():
|
||||
Test detect_faces on a blank image.
|
||||
"""
|
||||
empty_image = np.zeros((640, 640, 3), dtype=np.uint8)
|
||||
faces = detect_faces(empty_image, method='retinaface')
|
||||
faces = detect_faces(empty_image, method="retinaface")
|
||||
|
||||
assert isinstance(faces, list), "Should return a list even for empty image"
|
||||
assert len(faces) == 0, "Should detect no faces in blank image"
|
||||
@@ -193,8 +189,8 @@ def test_list_available_detectors_contents():
|
||||
detectors = list_available_detectors()
|
||||
|
||||
# Should include at least these detectors
|
||||
assert 'retinaface' in detectors, "Should include 'retinaface'"
|
||||
assert 'scrfd' in detectors, "Should include 'scrfd'"
|
||||
assert "retinaface" in detectors, "Should include 'retinaface'"
|
||||
assert "scrfd" in detectors, "Should include 'scrfd'"
|
||||
|
||||
|
||||
# Integration tests
|
||||
@@ -202,7 +198,7 @@ def test_detector_inference_from_factory():
|
||||
"""
|
||||
Test that detector created from factory can perform inference.
|
||||
"""
|
||||
detector = create_detector('retinaface')
|
||||
detector = create_detector("retinaface")
|
||||
mock_image = np.random.randint(0, 255, (640, 640, 3), dtype=np.uint8)
|
||||
|
||||
faces = detector.detect(mock_image)
|
||||
@@ -213,7 +209,7 @@ def test_recognizer_inference_from_factory():
|
||||
"""
|
||||
Test that recognizer created from factory can perform inference.
|
||||
"""
|
||||
recognizer = create_recognizer('arcface')
|
||||
recognizer = create_recognizer("arcface")
|
||||
mock_image = np.random.randint(0, 255, (112, 112, 3), dtype=np.uint8)
|
||||
|
||||
embedding = recognizer.get_embedding(mock_image)
|
||||
@@ -225,7 +221,7 @@ def test_landmarker_inference_from_factory():
|
||||
"""
|
||||
Test that landmarker created from factory can perform inference.
|
||||
"""
|
||||
landmarker = create_landmarker('2d106det')
|
||||
landmarker = create_landmarker("2d106det")
|
||||
mock_image = np.random.randint(0, 255, (640, 640, 3), dtype=np.uint8)
|
||||
mock_bbox = [100, 100, 300, 300]
|
||||
|
||||
@@ -238,8 +234,8 @@ def test_multiple_detector_creation():
|
||||
"""
|
||||
Test that multiple detectors can be created independently.
|
||||
"""
|
||||
detector1 = create_detector('retinaface')
|
||||
detector2 = create_detector('scrfd')
|
||||
detector1 = create_detector("retinaface")
|
||||
detector2 = create_detector("scrfd")
|
||||
|
||||
assert detector1 is not None
|
||||
assert detector2 is not None
|
||||
@@ -250,8 +246,8 @@ def test_detector_with_different_configs():
|
||||
"""
|
||||
Test creating multiple detectors with different configurations.
|
||||
"""
|
||||
detector_high_thresh = create_detector('retinaface', conf_thresh=0.9)
|
||||
detector_low_thresh = create_detector('retinaface', conf_thresh=0.3)
|
||||
detector_high_thresh = create_detector("retinaface", conf_thresh=0.9)
|
||||
detector_low_thresh = create_detector("retinaface", conf_thresh=0.3)
|
||||
|
||||
mock_image = np.random.randint(0, 255, (640, 640, 3), dtype=np.uint8)
|
||||
|
||||
@@ -269,9 +265,9 @@ def test_factory_returns_correct_types():
|
||||
"""
|
||||
from uniface import RetinaFace, ArcFace, Landmark106
|
||||
|
||||
detector = create_detector('retinaface')
|
||||
recognizer = create_recognizer('arcface')
|
||||
landmarker = create_landmarker('2d106det')
|
||||
detector = create_detector("retinaface")
|
||||
recognizer = create_recognizer("arcface")
|
||||
landmarker = create_landmarker("2d106det")
|
||||
|
||||
assert isinstance(detector, RetinaFace), "Should return RetinaFace instance"
|
||||
assert isinstance(recognizer, ArcFace), "Should return ArcFace instance"
|
||||
|
||||
Reference in New Issue
Block a user