Skip to content

Commit d0ffc1b

Browse files
Amend quirk behavior of mod operator
1 parent 923f2cf commit d0ffc1b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

deepface/detectors/DetectorWrapper.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@ def rotate_facial_area(
164164
"""
165165

166166
# Normalize the witdh of the angle so we don't have to
167-
# worry about rotations greater than 360 degrees
168-
angle = angle % 360
167+
# worry about rotations greater than 360 degrees.
168+
# We workaround the quirky behavior of the modulo operator
169+
# for negative angle values.
170+
direction = (1, -1)[angle < 0]
171+
angle = abs(angle) % 360
169172
if angle == 0:
170-
return facial_area # No rotation needed
171-
direction = 1 if angle > 0 else -1
173+
return facial_area
172174

173175
# Angle in radians
174176
angle = angle * np.pi / 180

0 commit comments

Comments
 (0)