Face Detection
BiWAKO.YuNet
Face Detection model.
Attributes:
Name | Type | Description |
---|---|---|
model |
onnxruntime.InferenceSession |
ONNX model. |
input_name |
str |
name of input node. |
output_names |
list |
names of three output nodes. |
input_shape |
list |
shape of input image. Set to [160, 120] by default. |
conf_th |
float |
confidence threshold. Set to 0.6 by default. |
nms_th |
float |
non-maximum suppression threshold. Set to 0.3 by default. |
topk |
int |
keep top-k results. Set to 5000 by default. |
priors |
np.ndarray |
prior boxes. |
__init__(self, model='yunet_120_160', input_shape=[160, 120], conf_th=0.6, nms_th=0.3, topk=5000, keep_topk=750)
special
Initialize YuNet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
str |
model name. Set to "yunet_120_160" by default. |
'yunet_120_160' |
input_shape |
list |
Input image shape. Defaults to [160, 120]. |
[160, 120] |
conf_th |
float |
Confidence level threshold. Defaults to 0.6. |
0.6 |
nms_th |
float |
NMS threshold. Defaults to 0.3. |
0.3 |
topk |
int |
Number of faces to detect. Defaults to 5000. |
5000 |
keep_topk |
int |
Number of predictions to save. Defaults to 750. |
750 |
predict(self, image)
Return the face detection result.
The prediction result is a tuple of three lists.
First list is bounding boxes, second list is landmarks, and third list is scores.
For example, accesing 2nd parson's bounding box is done by prediction[1][0]
, and prediction[1][1]
is landmarks of 2nd person.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
Image |
image to be detected. Accept path or cv2 image. |
required |
Returns:
Type | Description |
---|---|
Tuple[list, list, list] |
Tuple of three lists of bounding box, landmark, and score. |
render(self, prediction, image)
Render the bounding box and landmarks on the original image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prediction |
tuple |
prediction result returned by predict(). |
required |
image |
Image |
original image in str or cv2 image. |
required |
Returns:
Type | Description |
---|---|
np.ndarray |
Original image with bounding box and landmarks. |