Skip to content

BrightXiaoHan/FaceRecognizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Face Recognition Project

Introduction

SetUp

Install MTCNN FaceDetector

Follow this instruction FaceDetector Installation.

Install

python setup.py install

Basic Usage

Download the pre-trained model.

Download from pre-trained model and merge the part files

cat model_ir_se50.pth* > model_ir_se50.pth
mv model_ir_se50.pth /path/to/FaceRecognizer/output/res50

FaceVerify

Verify if they are the same person.

rebareba2

from insight_face import FaceSearcher

# Load pre-trained res50 model
searcher.load_state('./output/res50/model_ir_se50.pth', 50)

# Load face images
face1 = cv2.imread('./tests/assets/reba/2.jpg')
face2 = cv2.imread('./tests/assets/reba/3.jpg')

result = searcher.verify(face1, face2)

assert result is True

Search

Find who they are. reba

face_bank_dir = 'tests/assets/'
multi_face_img = cv2.imread("tests/assets/multi_face.jpg")

searcher.add_face_bank(face_bank_dir, force_reload=True, bank_name='test')
faces, names, best_sim, _, _ = searcher.search(multi_face_img, 'test')

print(names)

result

>> reba

Match

Match the person between two pictures.

source, target, sim = searcher.match(face1, multi_face_img)
cv2.imshow("source", source[0])
cv2.imshow("matched", target[0])

Get embedding vectors

Get the raw embedding vectors of faces in given image.

# expect a tensor shape with (3, 512)
emb, boxes, landmarks = searcher.embedding_faces_in_the_wild(multi_face_img)

Releases

No releases published

Packages

No packages published

Languages