-
-
Notifications
You must be signed in to change notification settings - Fork 106
Description
I was surprised by the output of predict_jsons()
when the input image did not contain any face.
The expected behaviour would have been an empty list, so that I could find the number of detected faces as len(annotations)
.
Instead, there is a list with 1 element, with empty bounding-boxes and a score of -1, due to the following line:
retinaface/retinaface/predict_single.py
Lines 92 to 93 in 29611c7
if boxes.shape[0] == 0: | |
return [{"bbox": [], "score": -1, "landmarks": []}] |
I think it is unintuitive and can lead to some confusion for the user.
A more consistent and intuitive behaviour would return annotations
as initialized here:
retinaface/retinaface/predict_single.py
Line 66 in 29611c7
annotations: List[Dict[str, Union[List, float]]] = [] |
Indeed:
- if new faces are detected, they are appended to
annotations
, - otherwise,
annotations
would be returned exactly as it was initialized.
retinaface/retinaface/predict_single.py
Lines 124 to 130 in 29611c7
annotations += [ | |
{ | |
"bbox": bbox.tolist(), | |
"score": scores[box_id], | |
"landmarks": landmarks[box_id].reshape(-1, 2).tolist(), | |
} | |
] |