Numpy ValueError while using dlib's face detector
For two days, I was trying to find a bug in my code, because an assertion in the code that uses numpy.max
was giving an error like ValueError: zero-size array to reduction operation maximum which has no identity which didn’t seem reasonable.
I’m building a face recognizer with dlib’s frontal face detector, and today, I noticed that some of the results return negative coordinates in face detection. This means the detected face is partial, although it’s a bit a stretch to use negative coordinates for this.
My code wasn’t checking for negative coordinates and was building the numpy array incorrectly. But after reading the issue, although I’m not convinced that it’s a good approach, I added a few if
s and the problem is solved.