@@ -116,15 +116,15 @@ def face_locations(img, number_of_times_to_upsample=1, model="hog"):
116
116
return [_trim_css_to_bounds (_rect_to_css (face ), img .shape ) for face in _raw_face_locations (img , number_of_times_to_upsample , model )]
117
117
118
118
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 ):
120
120
"""
121
121
Returns an 2d array of dlib rects of human faces in a image using the cnn face detector
122
122
123
123
:param img: A list of images (each as a numpy array)
124
124
:param number_of_times_to_upsample: How many times to upsample the image looking for faces. Higher numbers find smaller faces.
125
125
:return: A list of dlib 'rect' objects of found face locations
126
126
"""
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 )
128
128
129
129
130
130
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):
141
141
def convert_cnn_detections_to_css (detections ):
142
142
return [_trim_css_to_bounds (_rect_to_css (face .rect ), images [0 ].shape ) for face in detections ]
143
143
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 )
145
145
146
146
return list (map (convert_cnn_detections_to_css , raw_detections_batched ))
147
147
0 commit comments