| 83 | |
| 84 | |
| 85 | def test_numpy_input(): |
| 86 | img_path = "dataset/img1.jpg" |
| 87 | img = cv2.imread(img_path)[:, :, ::-1] # BGR to RGB |
| 88 | for detector in detectors: |
| 89 | img_objs = DeepFace.extract_faces(img_path=img.copy(), detector_backend=detector) |
| 90 | # img_objs should be a list of dicts |
| 91 | assert isinstance(img_objs, list) |
| 92 | assert len(img_objs) == 1 |
| 93 | for img_obj in img_objs: |
| 94 | assert isinstance(img_obj, dict) |
| 95 | assert "face" in img_obj.keys() |
| 96 | assert "facial_area" in img_obj.keys() |
| 97 | face = img_obj["face"] |
| 98 | assert face.shape[0] > 0 and face.shape[1] > 0 |
| 99 | logger.info(f"✅ extract_faces for {detector} backend with numpy input test is done") |
| 100 | |
| 101 | |
| 102 | def test_backends_for_enforced_detection_with_non_facial_inputs(): |