/face_recognition_cnn

Face verification and recognition using FaceNet deep convolutional neural network

Primary LanguagePython

Face recognition cnn

Face verification and recognition using a pre-trained FaceNet deep convolutional neural network:


1. Database

The database are my classmates from Tsinghua University:

If you want to have your own database just need to add your own face images (96x96) to the /images folder. Then modify below lines of code accordingly:

# fr.py
44. database = {}
45. database["yimin"] = img_to_encoding("images/yimin.jpg", FRmodel)
46. database["alex"] = img_to_encoding("images/alex.jpg", FRmodel)
47. database["white"] = img_to_encoding("images/white.jpg", FRmodel)
48. database["jiayi"] = img_to_encoding("images/jiayi.jpg", FRmodel)
49. database["kevinthu"] = img_to_encoding("images/kevinthu.jpg", FRmodel)
50. database["jane"] = img_to_encoding("images/jane.jpg", FRmodel)
51. database["lucky"] = img_to_encoding("images/lucky.jpg", FRmodel)
52. database["bruno"] = img_to_encoding("images/bruno.jpg", FRmodel)
53. database["adeline"] = img_to_encoding("images/adeline.jpg", FRmodel)
54. database["sdt"] = img_to_encoding("images/sdt.jpg", FRmodel)
55. database["alvaro"] = img_to_encoding("images/alvaro.jpg", FRmodel)
56. database["linda"] = img_to_encoding("images/linda.jpg", FRmodel)

2. Face Verification

Face verification verifies the input face ("alvaro_0.jpg") encoding vector corresponds (distance < threashold) to the provided name ("alvaro") database member encoding vector:

# fr.py
76. verify("images/alvaro_0.jpg", "alvaro", database, FRmodel)

3. Face Recognition

Face recognition compares the input face ("alvaro_0.jpg") encoding vector with all database members encoding vector, chosing the one with the minimum distance between vectors:

# fr.py
106. who_is_it("images/alvaro_0.jpg", database, FRmodel)

4. Final output