When running the simple FaceDB example in the README.md and setting the module to deepface
, I get the following error/s:
.../deepface/.venv/lib/python3.10/site-packages/facedb/db.py:263: UserWarning: Deepface module is not calibrated for vector database. Use `face_recognition` instead.
warnings.warn(
Traceback (most recent call last):
File ".../deepface/.venv/lib/python3.10/site-packages/facedb/db.py", line 49, in load_module
from deepface.commons import distance as deepface_distance
ImportError: cannot import name 'distance' from 'deepface.commons' (.../deepface/.venv/lib/python3.10/site-packages/deepface/commons/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "~/deepface/test_facedb.py", line 24, in <module>
db = FaceDB(
File ".../deepface/.venv/lib/python3.10/site-packages/facedb/db.py", line 307, in __init__
load_module(module)
File ".../deepface/.venv/lib/python3.10/site-packages/facedb/db.py", line 51, in load_module
raise ImportError(
ImportError: Please install `deepface` to use `deepface` module.
from facedb import FaceDB
# Create a FaceDB instance
db = FaceDB(
path="facedata", module="deepface"
)
# Add a new face to the database
face_id = db.add("robonxt", img="dataset/robonxt/robonxt01.png")
# Recognize a face
result = db.recognize(img="test.jpg")
# Check if the recognized face is similar to the one in the database
if result and result["id"] == face_id:
print(f"Recognized as {result['name']}")
else:
print(f"Unknown face")