Skip to content

Commit 8a178d0

Browse files
committed
docstring updated
1 parent 745b4b8 commit 8a178d0

File tree

4 files changed

+39
-12
lines changed

4 files changed

+39
-12
lines changed

deepface/DeepFace.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,9 @@ def extract_faces(
476476
477477
- "facial_area" (Dict[str, Any]): The detected face's regions as a dictionary containing:
478478
- keys 'x', 'y', 'w', 'h' with int values
479-
- keys 'left_eye', 'right_eye' with a tuple of 2 ints as values
479+
- keys 'left_eye', 'right_eye' with a tuple of 2 ints as values. left and right eyes
480+
are eyes on the left and right respectively with respect to the person itself
481+
instead of observer.
480482
481483
- "confidence" (float): The confidence score associated with the detected face.
482484
"""

deepface/detectors/DetectorWrapper.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ def detect_faces(
7676
7777
- img (np.ndarray): The detected face as a NumPy array.
7878
79-
- facial_area (FacialAreaRegion): The facial area region represented as x, y, w, h
79+
- facial_area (FacialAreaRegion): The facial area region represented as x, y, w, h,
80+
left_eye and right eye. left eye and right eye are eyes on the left and right
81+
with respect to the person instead of observer.
8082
8183
- confidence (float): The confidence score associated with the detected face.
8284
"""
@@ -123,13 +125,11 @@ def detect_faces(
123125
img=img, left_eye=left_eye, right_eye=right_eye
124126
)
125127
rotated_x1, rotated_y1, rotated_x2, rotated_y2 = rotate_facial_area(
126-
facial_area=(x, y, x + w, y + h),
127-
angle=angle,
128-
size=(img.shape[0], img.shape[1])
128+
facial_area=(x, y, x + w, y + h), angle=angle, size=(img.shape[0], img.shape[1])
129129
)
130130
detected_face = aligned_img[
131-
int(rotated_y1) : int(rotated_y2),
132-
int(rotated_x1) : int(rotated_x2)]
131+
int(rotated_y1) : int(rotated_y2), int(rotated_x1) : int(rotated_x2)
132+
]
133133

134134
result = DetectedFace(
135135
img=detected_face,
@@ -143,9 +143,7 @@ def detect_faces(
143143

144144

145145
def rotate_facial_area(
146-
facial_area: Tuple[int, int, int, int],
147-
angle: float,
148-
size: Tuple[int, int]
146+
facial_area: Tuple[int, int, int, int], angle: float, size: Tuple[int, int]
149147
) -> Tuple[int, int, int, int]:
150148
"""
151149
Rotate the facial area around its center.

deepface/models/Detector.py

+26-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ def detect_faces(self, img: np.ndarray) -> List["FacialAreaRegion"]:
2020
where each object contains:
2121
2222
- facial_area (FacialAreaRegion): The facial area region represented
23-
as x, y, w, h, left_eye and right_eye
23+
as x, y, w, h, left_eye and right_eye. left eye and right eye are
24+
eyes on the left and right respectively with respect to the person
25+
instead of observer.
2426
"""
2527
pass
2628

@@ -44,6 +46,21 @@ def __init__(
4446
right_eye: Optional[Tuple[int, int]] = None,
4547
confidence: Optional[float] = None,
4648
):
49+
"""
50+
Initialize a Face object.
51+
52+
Args:
53+
x (int): The x-coordinate of the top-left corner of the bounding box.
54+
y (int): The y-coordinate of the top-left corner of the bounding box.
55+
w (int): The width of the bounding box.
56+
h (int): The height of the bounding box.
57+
left_eye (tuple): The coordinates (x, y) of the left eye with respect to
58+
the person instead of observer. Default is None.
59+
right_eye (tuple): The coordinates (x, y) of the right eye with respect to
60+
the person instead of observer. Default is None.
61+
confidence (float, optional): Confidence score associated with the face detection.
62+
Default is None.
63+
"""
4764
self.x = x
4865
self.y = y
4966
self.w = w
@@ -59,6 +76,14 @@ class DetectedFace:
5976
confidence: float
6077

6178
def __init__(self, img: np.ndarray, facial_area: FacialAreaRegion, confidence: float):
79+
"""
80+
Initialize detected face object.
81+
82+
Args:
83+
img (np.ndarray): detected face image as numpy array
84+
facial_area (FacialAreaRegion): detected face's metadata (e.g. bounding box)
85+
confidence (float): confidence score for face detection
86+
"""
6287
self.img = img
6388
self.facial_area = facial_area
6489
self.confidence = confidence

deepface/modules/detection.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ def extract_faces(
6868
6969
- "facial_area" (Dict[str, Any]): The detected face's regions as a dictionary containing:
7070
- keys 'x', 'y', 'w', 'h' with int values
71-
- keys 'left_eye', 'right_eye' with a tuple of 2 ints as values
71+
- keys 'left_eye', 'right_eye' with a tuple of 2 ints as values.
72+
left eye and right eye are eyes on the left and right respectively with respect
73+
to the person itself instead of observer.
7274
7375
- "confidence" (float): The confidence score associated with the detected face.
7476
"""

0 commit comments

Comments
 (0)