Karan Singh

Code Never Lies, Comments Sometime Do !!

Deep Learning: Face Recognition Without Coding

| Comments

face-recogination

Today, its 27th of October 2017 15:00 EEST, i am still in transit to home, after attending Spark Summit Europe 2017. The top two trends of this summit was

1. Machine Learning

2. Streaming workloads

I am fascinated by the advancement happened lately in the field of Machine Learning, Deep Learning and Artificial Intelligence.This technology is the biggest thing now, and is destined to be human scale.

As they say “The hardest part of any journey is taking that first step

So with that, i am all set to take my first step, where i am going to do my first Machine Learning toy lesson

Project #1: Face Recognition using face_recogination library (without coding)

  • Install dependencies cmake and boost-python which are required for face_recogination library
1
2
3
$ brew install cmake
$ brew install boost-python
$ pip install face_recognition
  • Once installation is done verify libraries dlib and face_recogination by importing them in python shell. If you encounter any problems while importing these libraries, you need to fix those before moving forward.
1
2
3
4
5
6
7
8
karasing-OSX:~$ python
Python 2.7.14 |Anaconda, Inc.| (default, Oct  5 2017, 02:28:52)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
>>> import face_recognition
>>> import cv2
>>> exit ()
  • To get our first image recognition project working you need a few images. Training images and images that you need to recognize.
  • For simplicity create two directories known_images and unknown_images.
  • As the name suggest under known_images directory add a few images of faces your want your system to know (save the images as the label you want to be known).

face-recogination

  • Similarly for unknown_images directory add images your system wil detect based on known_images data.

face-recogination

  • In my setup i have 3 known_images and 4 unknown_images as shown below
1
2
3
4
5
6
7
8
9
10
11
12
13
14
karasing-OSX:~/temp/Face-Detection$ ls -l *
known_images:
total 304
[email protected] 1 karasing  staff  51757 Oct 28 17:47 modi.jpg
[email protected] 1 karasing  staff  13789 Oct 28 17:46 obama.jpg
[email protected] 1 karasing  staff  83468 Oct 28 17:46 trump.jpg

unknown_images:
total 1528
[email protected] 1 karasing  staff  646240 Oct 28 17:49 modi-obama-trump.png
[email protected] 1 karasing  staff   50081 Oct 28 17:41 modi-obama.jpg
[email protected] 1 karasing  staff   45142 Oct 28 17:44 trump-modi.jpg
[email protected] 1 karasing  staff   31671 Oct 28 17:45 trump-obama.jpg
karasing-OSX:~/temp/Face-Detection$
  • Now i have both known and unknown images. I will trigger face_recogination command which will use face_recigination library under the hood and detect faces in unknown images.
1
$ face_recognition <Directory_Path_of_known_images> <Directory_Path_of_unknown_images>
  • This program will detect faces in the unknown images and return the lable (name), as shown below.
1
2
3
4
5
6
7
8
9
10
11
12
13
karasing-OSX:~/temp/Face-Detection$ face_recognition known_images unknown_images
unknown_images/modi-obama-trump.png,trump
unknown_images/modi-obama-trump.png,obama
unknown_images/modi-obama-trump.png,modi

unknown_images/modi-obama.jpg,obama
unknown_images/modi-obama.jpg,modi

unknown_images/trump-modi.jpg,trump
unknown_images/trump-modi.jpg,modi

unknown_images/trump-obama.jpg,trump
unknown_images/trump-obama.jpg,obama

\o/ YaY .. we just created the most easiest face recogination system ever !!!

I would like to thank Adam Geitgey for creating this super handy and easy to use library.

Comments