Skip to content

Commit df83b44

Browse files
zxu7ageitgey
authored andcommitted
make batch_size effective in _raw_face_locations_batched
1 parent 746a293 commit df83b44

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

face_recognition/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ def face_locations(img, number_of_times_to_upsample=1, model="hog"):
116116
return [_trim_css_to_bounds(_rect_to_css(face), img.shape) for face in _raw_face_locations(img, number_of_times_to_upsample, model)]
117117

118118

119-
def _raw_face_locations_batched(images, number_of_times_to_upsample=1):
119+
def _raw_face_locations_batched(images, number_of_times_to_upsample=1, batch_size=128):
120120
"""
121121
Returns an 2d array of dlib rects of human faces in a image using the cnn face detector
122122
123123
:param img: A list of images (each as a numpy array)
124124
:param number_of_times_to_upsample: How many times to upsample the image looking for faces. Higher numbers find smaller faces.
125125
:return: A list of dlib 'rect' objects of found face locations
126126
"""
127-
return cnn_face_detector(images, number_of_times_to_upsample)
127+
return cnn_face_detector(images, number_of_times_to_upsample, batch_size=batch_size)
128128

129129

130130
def batch_face_locations(images, number_of_times_to_upsample=1, batch_size=128):
@@ -141,7 +141,7 @@ def batch_face_locations(images, number_of_times_to_upsample=1, batch_size=128):
141141
def convert_cnn_detections_to_css(detections):
142142
return [_trim_css_to_bounds(_rect_to_css(face.rect), images[0].shape) for face in detections]
143143

144-
raw_detections_batched = _raw_face_locations_batched(images, number_of_times_to_upsample)
144+
raw_detections_batched = _raw_face_locations_batched(images, number_of_times_to_upsample, batch_size)
145145

146146
return list(map(convert_cnn_detections_to_css, raw_detections_batched))
147147

0 commit comments

Comments
 (0)