Numpy ValueError while using dlib's face detector

Posted on Prş 25 Ekim 2018 in new • 1 min read

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 ifs and the problem is solved.