From e96ede3dedbb550f8302e63c23035cf093825102 Mon Sep 17 00:00:00 2001 From: Nat Lee Date: Tue, 17 Dec 2024 15:27:31 +0800 Subject: [PATCH] [update] add multiple faces testing --- tests/test_analyze.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_analyze.py b/tests/test_analyze.py index bad4426..976952b 100644 --- a/tests/test_analyze.py +++ b/tests/test_analyze.py @@ -135,3 +135,15 @@ def test_analyze_for_different_detectors(): assert result["gender"]["Man"] > result["gender"]["Woman"] else: assert result["gender"]["Man"] < result["gender"]["Woman"] + +def test_analyze_for_multiple_faces(): + img = "dataset/img4.jpg" + # Copy and combine the same image to create multiple faces + img = cv2.imread(img) + img = cv2.hconcat([img, img]) + demography_objs = DeepFace.analyze(img, silent=True) + for demography in demography_objs: + logger.debug(demography) + assert demography["age"] > 20 and demography["age"] < 40 + assert demography["dominant_gender"] == "Woman" + logger.info("✅ test analyze for multiple faces done")