GithubHelp home page GithubHelp logo

freefly518 / face-recognition Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anktplwl91/face-recognition

0.0 0.0 0.0 12 KB

Face Detection using open-cv and Face Recognition using Siamese networks using Keras and TensorFlow

Python 100.00%

face-recognition's Introduction

Face-Recognition

Face Detection using open-cv and Face Recognition using Siamese networks using Keras and TensorFlow

This project can be used to train a Siamese network for Face Recognition based on either Contrastive Loss and Triplet Loss as well. I have implemented this project using Keras (with TensorFlow backend) and open-cv in Python 3.6.

The complete pipeline for training the network is as follows:

  1. Extract faces from human images, which are stored in separate person-wise directories. You can use face_detection.py for this purpose. This python script takes two inputs,

    (i) -n/--new_image-dir which stores the faces of all people in seperate person-wise directories, and

    (ii) -o/--orig_image_dir which is a list of original directory names. Keep in mind that all directories mentioned after -o flag must contain images of all people in seperate folders. Sample call is like

                   python face_recognition.py -n face_images -o people_dir_1 people_dir_2
    
  2. Having face images stored in the directory mentioned above, you can now run either face_recog_contrastive.py or face_recog_triplet.py based on whether Contrastive Loss or Triplet Loss is to be used to train the network. Both python scripts takes same inputs, namely

    (i) -b/--batch_size represents the batch-size of inputs to be given to network, it defaults to 16.

    (ii) -d/--img_dir represents directory which was mentioned as target directory above containing face images.

    (iii) -m/--model represents the TensorFlow model which is to be used as base model for Siamese networks. Allowed values are - mobilenet(MobileNetV2), inception(InceptionV3), vgg(VGG19), xception(Xception), resnet(ResNet50) and inception-resnet (Inception-ResNet), defaults to mobilenet.

    (iv) -o/--optim represents the optimizer to be used to train the network. Allowed values are sgd (default), rmsprop and adam. All optimizers are used with default parameters.

    (v) -e/--epochs represents the number of epochs for which the model is to be trained, defaults to 5.

    Sample call is like

                 python face_recog_contrastive.py -b 32 -d face_dirs -m resnet -o rmsprop -e 20
    
  3. To generate predictions from your trained and saved model, you can use test_predictions.py. This python script takes following input parameters

    (i) -d/--test_dir represents the directory where you have test set of images saved. Keep in mind the directory structure should be same as we created for training set, i.e. person-wise directories of images.

    (ii) -t/--target_dir represents directory where predicted results will be saved.

    (iii) -m/--model_file represents saved model file which will be used for making predictions.

    (iv) -l/--loss represents which model will be used, used to determine the model input, contrastive or triplet

    (v) -n/--num_images represents number of image pairs you want to test accuracy on

    Sample call is like

     python test_predictions.py -d test_dir -t results_dir -m contrastive_resnet_model.h5 -l contrastive -n 10
    

face-recognition's People

Contributors

anktplwl91 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.