Package: facenet-sandberg
Facial Recognition and AlignmentWhat's this?This repository contains a refactored implementation of David Sandberg'sFaceNetandInsightFacefor facial recognition. It also contains an implementation ofMTCNNandFaceboxesfor face cropping and alignment. What is in the refactor:Made algorithms easily and efficiently usable withconvenience classes.Added much more efficient methods of batch processing face recognition and alignmentAdded true face alignment (with affine transformation) to align face to bottom-center of image:codeAdded proportional margin to alignment as per thisissueAbility to easily switch betweeninsightfaceandfacenetatinference timeMore information on customizing and implementing new face detection algorithms can be foundhere.InstallationTo use in other projects, this implementation can be pip installed as follows:pip install facenet_sandbergTo use locally:Clone repocd to base directory with setup.pyrun:pip install -e .^(installs package indevelopment mode)Important RequirementsPython 3.5Tensorflow==1.7Tensorlayer==1.7
The rest is specified inrequirements.txtModelsLinks to pretrained models:FacenetUses RGB images of size 160x160Insightface.zipUses BGR images of size 112x112DatasetsLinks to download training datasets (!big files!):EmoreMSM_refined_112x112VGG2_112x112Image directory structureThis repo assumes images are inLFW format:-/base_images_folder
  -/person_1
    -person_1_0001.jpg
    -person_1_0002.jpg
    -person_1_0003.jpg
  -/person_2
    -person_2_0001.jpg
    -person_2_0002.jpg
  ...If your dataset is not like this you can uselfw.pyto put your images into the right format like so (from facenet_sandberg/facenet_sandberg):python lfw.py --image_directory PATH_TO_YOUR_BASE_IMAGE_DIRECTORYAlignmentAlignment is done with a combination of Faceboxes and MTCNN. While Faceboxes is more accurate and works with more images than MTCNN, it does not returnfacial landmarks. Whichever algorithm returns more results is used.Use thealign_dataset.pyscript to align an entire image directory:python align_dataset.py --input_dir PATH_TO_YOUR_BASE_IMAGE_DIRECTORY \
                        --output_dir PATH_TO_OUTPUT_ALIGNED_IMAGES \
                        --facenet_model_checkpoint PATH_TO_PRETRAINED_FACENET_MODEL \
                        --image_height DESIRED_IMAGE_HEIGHT \
                        --image_width DESIRED_IMAGE_WIDTH \
                        --margin DESIRED_PROPORTIONAL_MARGIN \
                        --scale_factor DESIRED_SCALE_FACTOR \
                        --steps_threshold DESIRED_STEPS \
                        --detect_multiple_faces \
                        --use_faceboxes \
                        --use_affine \
                        --num_processes NUM_PROCESSES_TO_USEDefault values for most arguments are providedhereGenerate Pairs.txtA pairs.txt file is used in training and testing. It follows thisformat. In order to generate your own pairs.txt run:python align_dataset.py --image_dir PATH_TO_YOUR_BASE_IMAGE_DIRECTORY \
                        --pairs_file_name OUTPUT_NAME_OF_PAIRS_FILE \
                        --num_folds NUMBER_OF_FOLDS_FOR_CROSS_VALIDATION \
                        --num_matches_mismatches NUMBER_OF_MATCHES_AND_MISMATCHESCopyrightMIT License from original repohttps://github.com/davidsandberg/facenet/blob/master/LICENSE.md