MCPcopy
hub / github.com/ageitgey/face_recognition / face_locations

Function face_locations

face_recognition/api.py:105–118  ·  view source on GitHub ↗

Returns an array of bounding boxes of human faces in a image :param img: An image (as a numpy array) :param number_of_times_to_upsample: How many times to upsample the image looking for faces. Higher numbers find smaller faces. :param model: Which face detection model to use. "hog"

(img, number_of_times_to_upsample=1, model="hog")

Source from the content-addressed store, hash-verified

103
104
105def face_locations(img, number_of_times_to_upsample=1, model="hog"):
106 """
107 Returns an array of bounding boxes of human faces in a image
108
109 :param img: An image (as a numpy array)
110 :param number_of_times_to_upsample: How many times to upsample the image looking for faces. Higher numbers find smaller faces.
111 :param model: Which face detection model to use. "hog" is less accurate but faster on CPUs. "cnn" is a more accurate
112 deep-learning model which is GPU/CUDA accelerated (if available). The default is "hog".
113 :return: A list of tuples of found face locations in css (top, right, bottom, left) order
114 """
115 if model == "cnn":
116 return [_trim_css_to_bounds(_rect_to_css(face.rect), img.shape) for face in _raw_face_locations(img, number_of_times_to_upsample, "cnn")]
117 else:
118 return [_trim_css_to_bounds(_rect_to_css(face), img.shape) for face in _raw_face_locations(img, number_of_times_to_upsample, model)]
119
120
121def _raw_face_locations_batched(images, number_of_times_to_upsample=1, batch_size=128):

Callers

nothing calls this directly

Calls 3

_trim_css_to_boundsFunction · 0.85
_rect_to_cssFunction · 0.85
_raw_face_locationsFunction · 0.85

Tested by

no test coverage detected