facenet-pytorch
facenet-pytorch copied to clipboard
torch.cat error with empty boxes
Hi, I have an error when no boxes are detected for the whole batch, even in the first stage (is that expected? I work with images where there may be no faces)
It is caused by facenet_pytorch/models/utils/detect_face.py:83
: boxes = torch.cat(boxes, dim=0)
If it is expected, I guess a simple fix would be to test if len(boxes) > 0
like in the other stages
Full traceback is https://gist.github.com/PaulLerner/9b3b6feb95065d8395b4db1dca76241b
It happens with this image which has an unusual aspect ratio:
OK now I got it:
it’s because the image height is so small (smaller than min_face_size
) then in here https://github.com/timesler/facenet-pytorch/blob/master/models/utils/detect_face.py#L57 the scales
list is empty, thus the boxes
is also empty
So a fix would be to check whether minl >= minsize
(min_face_size
name in detect_face)