- This repo is a reimplementation of Arcface(paper), or Insightface(github)
- This repo is get inspiration from insightface, Insightface_Pytorh
Follow this instruction FaceDetector Installation.
python setup.py install
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
Verify if they are the same person.
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
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 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 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)