A Simple Tutorial To Identify Human Face In a Given Image


  • Python3
  • PyCharm or any other python IDE
  • Homebrew
  • cmake (brew install cmake)
  • dlib (pip3 install dlib)

The steps in bracket are specific to mac.


import PIL.Image
import PIL.ImageDraw
import face_recognition
image = face_recognition.load_image_file("IMG_20190720_160311.jpg")
face_locations = face_recognition.face_locations(image)
number_of_faces = len(face_locations)
pil_image = PIL.Image.fromarray(image)
for face_location in face_locations:
top, right, bottom, left = face_location
draw = PIL.ImageDraw.Draw(pil_image)
draw.rectangle([left,top, right, bottom],outline="red",width=5)
view raw FindFace.py hosted with ❤ by GitHub

The algorithm behind will be covered in subsequent tutorial.

Test Input

Test Output


Linked In Course On Face Recognition

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: