Learn practical skills, build real-world projects, and advance your career

Intruder Detection using Deep Learning version 2

Referenced from :
https://github.com/ageitgey/face_recognition/blob/master/examples/facerec_from_webcam.py

Here we use face_recognition python module. This module runs upon dlib a c++ based library.

It consists of 4 steps.
  • Step-1 : Encode the picture using the HOG algorithm to create a simplified version of the image.
  • Step-2 : Finding the main landmarks in the face like nose, mouth and ears.
  • Step-3 : Encoding Faces. Here we use a pre-trained Convolution Neural Network developed by OpenFace.
  • Step-4 : Finding the person’s name from the encoding.Compare which person has the closest measurements to our face’s measurements.
import glob
import face_recognition
import cv2
import numpy as np
import jovian

Data Set Understanding

paths = glob.glob('C:\\Users\\vsneh\\Udemy-notebooks\\face_rec_mod_testing\\data\\*')
names = []
images = []
image_encodings = []
image_names = []
count_img = 0
for i in paths:
    images.append(face_recognition.load_image_file(i))
    image_encodings.append(face_recognition.face_encodings(images[count_img])[0])
    image_names.append(i.split('\\')[-1].split('.')[0])
    count_img+=1
    print(image_names)
['bill gates'] ['bill gates', 'donald trump'] ['bill gates', 'donald trump', 'elon musk'] ['bill gates', 'donald trump', 'elon musk', 'jeff bezos'] ['bill gates', 'donald trump', 'elon musk', 'jeff bezos', 'obama'] ['bill gates', 'donald trump', 'elon musk', 'jeff bezos', 'obama', 'snehit2']