SHARE
TWEET

Untitled

a guest Jun 19th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from PIL import Image
  2. import face_recognition
  3.  
  4. # Load the jpg file into a numpy array
  5. image = face_recognition.load_image_file("biden.jpg")
  6.  
  7. # Find all the faces in the image using the default HOG-based model.
  8. # This method is fairly accurate, but not as accurate as the CNN model and not GPU accelerated.
  9. # See also: find_faces_in_picture_cnn.py
  10. face_locations = face_recognition.face_locations(image)
  11.  
  12. print("I found {} face(s) in this photograph.".format(len(face_locations)))
  13.  
  14. for face_location in face_locations:
  15.  
  16.     # Print the location of each face in this image
  17.     top, right, bottom, left = face_location
  18.     print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top, left, bottom, right))
  19.  
  20.     # You can access the actual face itself like this:
  21.     face_image = image[top:bottom, left:right]
  22.     pil_image = Image.fromarray(face_image)
  23.     pil_image.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top