Skip to content

Commit

Permalink
fix pylint warnings and update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
huulockt committed Dec 24, 2024
1 parent b490608 commit 5a0eea1
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions deepface/modules/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,13 @@ def expand_and_align_face(
# align original image, then find projection of detected face area after alignment
if align is True: # and left_eye is not None and right_eye is not None:
processed_face, new_x, new_y = alignment_preprocess(img=img, facial_area=(x,y,w,h))
aligned_img, angle = align_img_wrt_eyes(img=processed_face, left_eye=left_eye, right_eye=right_eye)
aligned_img, angle = align_img_wrt_eyes(
img=processed_face, left_eye=left_eye, right_eye=right_eye
)

rotated_x1, rotated_y1, rotated_x2, rotated_y2 = project_facial_area(
facial_area=(new_x, new_y, new_x + w, new_y + h),
angle=angle,
angle=angle,
size=(processed_face.shape[0], processed_face.shape[1])
)
detected_face = aligned_img[
Expand Down Expand Up @@ -318,17 +320,19 @@ def alignment_preprocess(
"""
Expand the facial region to ensure alignment does not shift the face outside the image.
This function doubles the height and width of the face region, and adds black pixels if necessary.
This function doubles the height and width of the face region,
and adds black pixels if necessary.
Args:
----
img (np.ndarray): pre-loaded image with detected face
facial_area (tuple of int): Representing the (x, y, w, h) of the facial area.
- img (np.ndarray): pre-loaded image with detected face
- facial_area (tuple of int): Representing the (x, y, w, h) of the facial area.
Returns:
----
expanded_face (np.ndarray): expanded facial image
new_x (int): adjusted x-coordinates relative to the expanded region
new_y (int): adjusted y-coordinates relative to the expanded region
- expanded_face (np.ndarray): expanded facial image
- new_x (int): adjusted x-coordinates relative to the expanded region
- new_y (int): adjusted y-coordinates relative to the expanded region
"""
x, y, w, h = facial_area
width_border = int(0.5 * w)
Expand All @@ -352,7 +356,7 @@ def alignment_preprocess(
start_x = max(0, width_border - x)
start_y = max(0, height_border - y)
expanded_image[
start_y:start_y + cropped_region.shape[0],
start_y:start_y + cropped_region.shape[0],
start_x:start_x + cropped_region.shape[1]
] = cropped_region
new_x, new_y = width_border, height_border
Expand Down

0 comments on commit 5a0eea1

Please sign in to comment.