ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
53.34k stars 13.48k forks source link

Basic Troubleshooting? #252

Closed McCannDahl closed 4 years ago

McCannDahl commented 6 years ago

Description

I am just starting out, but for some reason, I can't get it to detect any faces in any of my pictures. Are there any basic beginning steps you would recommend?

What I Did

~/faceRec$ python3 find_faces_in_picture.py 
I found 0 face(s) in this photograph.

The unnknown.jpg image is in the same folder that im running the script in (faceRec)


from PIL import Image
import face_recognition

# Load the jpg file into a numpy array
image = face_recognition.load_image_file("unknown.jpg")

# Find all the faces in the image using the default HOG-based model.
# This method is fairly accurate, but not as accurate as the CNN model and not GPU accelerated.
# See also: find_faces_in_picture_cnn.py
face_locations = face_recognition.face_locations(image)

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

for face_location in face_locations:

    # Print the location of each face in this image
    top, right, bottom, left = face_location
    print("A face is located at pixel location Top: {}, Left: {}, Bottom: {}, Right: {}".format(top$

    # You can access the actual face itself like this:
    face_image = image[top:bottom, left:right]
    pil_image = Image.fromarray(face_image)
    pil_image.show()
ageitgey commented 6 years ago
  1. Is unknown.jpg a file included in the examples folder or one of your own files? All the example should "just work"
  2. If it is one of your own image files, is it possible it's a jpeg image where the image is actually sideways but the image has an embedded EXIF rotation tag telling the program it needs to rotate the image before displaying it? If that's the case, you need to rotate the image yourself. This library won't do that automatically. This is a common source of problems if you originally took the picture on an iphone, for example. See this for more info.