Download backend/test_face.py from SolutionChallenge/solution_challenge_backend: direct link, hf CLI and curl.
- Browser
- Download file 683 Bytes
-
https://huggingface.co/spaces/SolutionChallenge/solution_challenge_backend/resolve/main/backend/test_face.py
- Command line
-
hf download hf://spaces/SolutionChallenge/solution_challenge_backend/backend/test_face.py
-
curl -L -o test_face.py https://huggingface.co/spaces/SolutionChallenge/solution_challenge_backend/resolve/main/backend/test_face.py
683 Bytes
| import cv2 | |
| import numpy as np | |
| import sys | |
| import os | |
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), "Face_Recognition")) | |
| from face_matcher import FaceMatcher | |
| fe = FaceMatcher() | |
| fe.reload_db() | |
| print(f"DB keys: {list(fe.db.keys())}") | |
| # Try to find a face image | |
| img_path = os.path.join("Face_Recognition", "face_database") | |
| # find first jpg | |
| for root, dirs, files in os.walk(img_path): | |
| for f in files: | |
| if f.endswith(".jpg"): | |
| path = os.path.join(root, f) | |
| print(f"Testing with {path}") | |
| frame = cv2.imread(path) | |
| res = fe.match_frame(frame) | |
| print(res) | |
| break | |
| else: | |
| continue | |
| break | |