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 throwing an error: 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 of a stretch to use negative coordinates for this.
My code wasn’t checking for negative coordinates and was building the NumPy
array incorrectly. However, after reading the
issue, although I’m still not convinced
that it’s a good approach, I added a few if statements and the problem was solved.