Face Recognition README
阿新 • • 發佈:2018-12-05
Face Recognition
A light weight face recognition implementation using a pre-trained facenet model. Most of the code is taken from David Sandberg’s facenet repository.
Steps to follow:
- Create a dataset of faces for each person and arrange them in below order
root folder │ └───Person 1 │ │───IMG1 │ │───IMG2 │ │ .... └───Person 2 | │───IMG1 | │───IMG2 | | ....
- Create embeddings of this dataset by running
python script/create_embeddings.py --input_dir = $(/path/to/your/image/dataset)
a pickle fileembeddings.pickle
will be created in your folder script/face_recognition.py
contains most functionalities for face recognition task. Input a face image of a person in the dataset,face_recognition.py
i.e.
_, face, bboxes = align_face(image_path='path/to/image',
image_size = 160,
margin=44,
gpu_memory_fraction=1.0
emb = create_embeddings( face, model_dir='/path/to/facenet/model')
embs = load_embeddings(emb_filepath='path/to/embedding/lists')
result, _ = identify_person(emb, embs)
align_face
detect face in an image and returns cropped image and resize it to 160x160
Args:
- image_path: path to image
- image_size: image size to be aligned
- margin: margin for the crop around the bounding box (height, width) in pixels.
- gpu_memory_fraction: percentage of gpu memory to be allocated
Returns:
- True if face is detected, false otherwise
- aligned face
- bounding box