load the jpg file into a numpy array find all the faces in the image using a pretrained convolutional neural network this method is more accurate than the default hog model but it s slower unless you have an nvidia gpu and dlib compiled with cuda extensions but if you do this will use gpu acceleration and perform well see also findfacesinpicture py print the location of each face in this image you can access the actual face itself like this load the jpg file into a numpy array find all the faces in the image using a pre trained convolutional neural network this method is more accurate than the default hog model but it s slower unless you have an nvidia gpu and dlib compiled with cuda extensions but if you do this will use gpu acceleration and perform well see also find_faces_in_picture py print the location of each face in this image you can access the actual face itself like this
from PIL import Image
import face_recognition


image = face_recognition.load_image_file("biden.jpg")






face_locations = face_recognition.face_locations(image, number_of_times_to_upsample=0, model="cnn")

print("I found {} face(s) in this photograph.".format(len(face_locations)))

for face_location in face_locations:

    
    top, right, bottom, left = face_location
    print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top, left, bottom, right))

    
    face_image = image[top:bottom, left:right]
    pil_image = Image.fromarray(face_image)
    pil_image.show()