FaceRec
FaceRec copied to clipboard
divide by 0 in align_custom.py
this is the points(landmarks): [108 124 108 106 119 19 22 32 41 44]
this line, abs(points[1] - points[2]) / abs(points[0] - points[2]) > 2: throws RuntimeWarning: divide by zero encountered in long_scalars, because [0] and [2] are same, subtracting them results in 0.
i have same problem with you how can i fix it?
just go to AlignCustom def getPos(self, points): and add the following try:
if abs(points[0] - points[2]) / abs(points[1] - points[2]) > 2:
return "Right"
elif abs(points[1] - points[2]) / abs(points[0] - points[2]) > 2:
return "Left"
return "Center"
except expression as identifier:
return "Center"