Inside a conda
or venv
virtual environment:
pip install --upgrade pip
# install requirements for all face detection
pip install -r requirements.txt # required for face_extraction
# install model specific requirements
pip install -r face_detection_and_extraction/requirements/mobile_facenet.txt
pip install -r face_detection_and_extraction/requirements/blazeface.txt
pip install -r face_detection_and_extraction/requirements/mtcnn.txt
pip install -r face_detection_and_extraction/requirements/opencv.txt
pip install -r face_detection_and_extraction/requirements/openvino.txt
pip install -r face_detection_and_extraction/requirements/yolov5-face.txt
# Note for trt_server and python>=3.10, install wheel pkg first
pip install wheel
pip install -r face_detection_and_extraction/requirements/trt_server.txt
Download the model weights using the instructions below.
CPU Performance recorded on a MacBook Pro with a 2.4 GHz 8-Core Intel Core i9 processor and 16 GB 2400 MHz DDR4 memory with no intensive programs running in the background on a video (original resolution 576x1024) with two detectable faces.
Model | FPS | Types | Supported |
---|---|---|---|
blazeface | 21 16 30 |
front-camera pytorch back-camera pytorch back-camera onnx |
✅ ✅ |
mtcnn | 2 | mtcnn from facenet | ✅ |
opencv face-detection | 18 19 |
caffemodel tensorflow graphdef |
✅ ✅ |
openvino face-detection | 25 28 |
MobileNetV2 + multiple SSD SqueezeNet light + single SSD |
✅ ✅ |
yolov5-face | 13 13 |
yolov5s yolov5n |
✅ ✅ |
arcface | TODO | arcface | ⬜ |
Performance recorded with same parameters as face-detection above.
Model | FPS | Types | Supported |
---|---|---|---|
opencv | 12 | Age and Gender Model | ✅ |
Instructions inside face_detection_and_extraction directory for face detection in images, video, and webcam feed along with face extraction from a dataset of images.
Download weights.zip
and unzip weights using gdown
or directly from this Google Drive link
pip install gdown
gdown 12807If9AlrX3hADgl820Kxl7sT7imtH-
unzip weights.zip -d face_detection_and_extraction/
rm weights.zip
Or, download weights individually from the GitHub.
wget https://github.com/SamSamhuns/face_detection_and_recognition/releases/download/v2.0.0/weights.zip -O face_detection_and_extraction/weights.zip
unzip face_detection_and_extraction/weights.zip -d face_detection_and_extraction/
rm face_detection_and_extraction/weights.zip
Extract faces from a face dataset that are similiar to a reference face dataset for cleaning face data. Instructions inside the similar_face_filtering directory readme.
Download weights from GitHub.
mkdir -p similar_face_filtering/models/facenet/
wget https://github.com/SamSamhuns/face_detection_and_recognition/releases/download/v2.0.0/facenet_keras_p38.zip -O similar_face_filtering/models/facenet/facenet_keras_p38.zip
unzip similar_face_filtering/models/facenet/facenet_keras_p38.zip -d similar_face_filtering/models/facenet/
rm similar_face_filtering/models/facenet/facenet_keras_p38.zip