Face Detection
Xircuits Face Detection Project Template
This template allows you to apply face detection on images or with webcam in real-time.
It consists of 2 components:
FaceDetector: Face detection with popular face detectors. It takes folder or image as input and detects face with speficied backend (default:
mtcnn
). If folder, result will be saved inoutput
folder besides the same directory provided, else, result will be saved at the root directory here (Check the message printed out at the terminal).CamInference: Camera inference with popular face detectors. It will open your webcam and detect face.
Prerequisites
Python 3.9
If you would like to use dlib
face detector:
- Microsoft Visual Studio for C++
(Note: Ignore the dlib installation error during installation if you want to skip this step. Also, avoid backend=2 or backend='dlib'.)
Installation
- Clone this repository
git clone https://github.com/XpressAI/template-face_detection.git
- Create a virtual environment and install the required python packages
pip install -r requirements.txt
- Run xircuits from the root directory
xircuits
Workflow in this Template
Inference
FaceDetector.xircuits
Where to Provide Input?
Input is taken by img_path
of Component FaceDetector
. Check out the example below.
You may provide folder or image file as input. Relative path or absolute path both are accepted (Noted that your folder in path should be separated by /
).
Which Backend Should I Use?
RetinaFace
and MTCNN
seems to overperform in detection but they are much slower. If the speed of your pipeline is more important, then you should use opencv
, ssd
or mediapipe
. On the other hand, if you consider the accuracy, then you should use retinaface
, mtcnn
or dlib
.
Recommended for inference: retinaface
, mtcnn
or dlib
.
Available backend:
- 0 - opencv
- 1 - ssd
- 2 - dlib
- 3 - mtcnn
- 4 - retinaface
- 5 - mediapipe
Where to Find Output?
If your input is folder, the output folder will be located besides your input folder. \ Example:
- Input:
resource/sample
- Output:
resource/output/sample
If your input is image file, the output will be located in this github root directory (the same directory as this README) at output.jpg
and output.txt
.
FaceDetector Example
Real-time Inference
CamInference.xircuits
Which Backend Should I Use?
Recommended for real-time inference: opencv
, ssd
or mediapipe
.
Available backend:
- 0 - opencv
- 1 - ssd
- 2 - dlib
- 3 - mtcnn
- 4 - retinaface
- 5 - mediapipe
CamInference Example
Possible Issue
- Error to load weights while using 'ssd' backend
Details:FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\user_name/.deepface/weights'
Solution: Restart Xircuits.