GithubHelp home page GithubHelp logo

facedetection's Introduction

Face Detection using python and Dlib/Face_recognition

It contains 3 parts

1. Gettings the data/Images from google image search

A file name "ImageDownload.py" will donload the image from google and store it in you local hard drive in Current working directory you can use the comand line arguments to specify which player image you want and how much images you want to download i.e run this command

      python ImageDownload.py --peopleList 'Albert Einstein','Nicola Tesla' --limit 5 

: -- peopleList argument expects list of peoples' images. you can specify single iamge or multiple seperated by comma.

: -- limit argument specifies how many images to download. here it will downlload 5 images for each person (i.e. Albert Einstein and Nicola Tesla)

The Data gets stored in the Folder structure format as follows : Parent Direcotry : FacesDB :

---- Albert Einstein-- 5 images

---- Nicola Tesla -- 5 images

all the images of people will be stored under FacesDB folder as shown here: (https://github.com/VaibhavKhamgaonkar/FaceDetection/blob/master/Screen%20Shot%202018-06-29%20at%202.56.38%20PM.png)

  • the next operation performed on the images is to crop the specific face area and replace the originial image. The command will take care of that thing as well. so finally you have al lthe face data created on your hard drive in working directory.

Note: If you are tying to get more than 100 images then you need have chrome driver and you need to update the file at for chrome driver path( I have added mine ) you will have to change that. Just google it for chrome driver you will get it.

2. Training the Data

  • Once the Data is availbale. You can simply run the belwo command which will start the training. Training mainly involved in identifying 68 facial Key points, affining them to suitable shape and then extracting the face embeddings (128 facial features).

  • After getting the features the data is then fed to SVM model for training.

  • I have used the face_recognition api to do this stuff.

  • After training is over the model gets saved into your local drive at the Encoding_Data/ folder.

    python FaceTraining.py
    

3. Testing the Program

  • Once the training is done we are ready to test the model on youtube streaming videos.

  • To test it get the youtube video url from youtube and pass it as an agrument to Main.py file

    python Main.py --url 'https://youtu.be/t27OqUlCSOg' --thresh 0.7
    
  • Thats it ...! The video will get played and faces will get identified automatiaclly. Also the video will get stored on current working directory.

  • you can change the threshold values as per your requirement.

4 : Person Finder:

  • The file FindPerson can find or tag the person in the Vidoe and it will create a bounding box arround the face.

  • if you want to find anyone in any video, just pass the name of person through command line argument and if the person is available then it will get tagged and box will get drawn on his face. If the person is not available in the frame then message will get appear "No Match!"

  • You can specify the multiple people in the argument whom you want to identify.

*Here in this example I want to find "Mesut Ozil', "Jerome Boateng", and "Manuel Neuer". check out how system responded to it. (results can be seen on this video : https://github.com/VaibhavKhamgaonkar/FaceDetection/blob/master/FindPerson.mp4)

  python FindPerson.py --url 'https://youtu.be/t27OqUlCSOg' --find 'Mesut Ozil','Jerome Boateng','Manuel Neuer'

5 : Add unknown faces on the go:

  • Added functionality to handle Unknown faces and incorporate these unknown faces into system.
  • This will now create the data set for unknown faces on the go for user to take action on whether they want to store the person information or discard it.

The Demostrations of how it will work is shown here on below link

Part 1 : https://www.linkedin.com/feed/update/urn:li:activity:6418826482981920768

part 2 : https://lnkd.in/fjVkZx3

=========================ALL DONE ===============================

Dependencies

  • The following packages shouldbe installed on your system before running the scripts
  1. Open cv (Cv2) 3.4
  2. dlib
  3. pickle
  4. pafy and youtube_dl for streaming youtube videos
  5. imutils
  6. face_recognition (pip install face_recognition) https://pypi.org/project/face_recognition/
  7. google_images_download (pip install google_images_download) https://pypi.org/project/google-images-download/1.0.1/ for downloading the images from google.
  8. numpy
  9. shutil (for creatingcopying images between folders)

===========xxxxxxxxxxxxxx=================

**You can modify the code as per your requirments. Any comments suggestions or feedback is much appreciated.

facedetection's People

Contributors

vaibhavkhamgaonkar avatar

Watchers

James Cloos avatar Rahul avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.