Start by creating the deepface
image from the latest tensorflow/tensorflow
release. Add a weights
folder to be used to persists downloaded model weights. I did not include the image I used here - you have to place your own in notebooks/assets
:
docker build -t tensorflow/deepface .
mkdir weights
mkdir notebooks/assets
The command below starts the Docker container with GPU support - to actually use your GPU you need to change the base image to tensorflow/tensorflow-gpu
and make sure that the Nvidia Toolkit is installed on your system - e.g. Enable Docker GPU support on Arch Linux - all measurements below were taken without GPU support on an older Intel i7-7700 (8) @ 4.200GHz
CPU:
docker run --ipc=host --gpus all -ti --rm \
-v $(pwd)/notebooks:/opt/app/notebooks \
-v $(pwd)/weights:/root/.deepface/weights \
-p 8888:8888 --name deepface \
tensorflow/deepface
The Jupyter Notebook will then be available on:
http://127.0.0.1:8888/tree?token=<Security Token>
And give access to the Deepface.ipynb
notebook. The following is a (selective / not exhaustive) comparison of different face recognition / face detection models that can be used with DeepFace:
I am seeing the best detection and separation with Facenet512 and YOLOv8 Face:
result = DeepFace.find(
img_path = "assets/Eiza_Gonzalez_03.jpg",
db_path = "assets",
model_name = "Facenet512",
distance_metric = "cosine",
enforce_detection = True,
detector_backend = "yolov8",
align = True,
expand_percentage = 0,
threshold = 0.90,
normalization = "base",
silent = False,
)