基于facenet的人脸识别
facenet_recognition的Python项目详细描述
人脸识别
基于facenet的人脸识别
使用Facenet构建 通过深入学习建立的最先进的人脸识别。模型 在Labeled Faces in the Wild基准上的精度为99.2%。
功能
- 开箱即用的工作面识别
- 从FaceNet中选择任何经过预培训的型号
- 对于培训,请提供正确的文件夹结构
- 比其他可用解决方案更快
先决条件
- 您需要安装python(2.6到3.5)
- 基于x的系统支持(在windows上有效,但未经测试)
安装
pipinstallfacenet_recognition
设置
创建如下设置:
- 创建输入目录例如:input_images
- 创建对齐图像目录例如:对齐图像创建此
目录我们将在这里存储对齐的图像
- 创建预先训练的模型目录例如:pre trained_facenet_model
从下载预先训练的模型
` facenet `并保留它
在pre_model目录中
- 创建我的训练有素的分类器目录,例如:my_classifier在此
目录我们将保存我们的培训模型
设置
创建如下设置:
- 创建输入目录例如:input_images
- 创建对齐图像目录例如:对齐图像创建此 目录我们将在这里存储对齐的图像
- 创建预先训练的模型目录例如:pre trained_facenet_model 从下载预先训练的模型 ` facenet `并保留它 在pre_model目录中
- 创建我的训练有素的分类器目录,例如:my_classifier在此 目录我们将保存我们的培训模型
让我们开始
对于面部识别,我们需要按如下方式对齐图像:
importfacenet_recognitionfacenet_recognition.align_input('input_images','aligned_images')
上面的命令将把我们的输入图像创建为对齐格式并保存 它位于给定的对齐图像文件夹
在图像上训练和测试分类器
在我们对齐图像之后,现在我们可以训练分类器了。
pre_model='./pretrained_facenet_model/20170511-185253.pb'#locaiton of pret-trained model from Facenetmy_class='./my_classifier/my_classifier.pkl'#location where we want to savetest_classifier_type='svm'#type of model either svm or nnweight='./my_classifier/model_small.yaml'#local stored weightsfacenet_recognition.test_train_classifier(aligned_images,pre_model,my_class,weight,test_classifier_type,nrof_train_images_per_class=30,seed=102)
mininum每人需要的图像:1number张用于培训的图像 每人30美元(可配置)
在图像上训练Classifier(仅限训练)
此api用于在对齐的图像上训练分类器
pre_model='./pretrained_facenet_model/20170511-185253.pb'#locaiton of pret-trained model from Facenetmy_class='./my_classifier/my_classifier.pkl'#location where we want to savetest_classifier_type='nn'#type of model either svm or nnweight='./my_classifier/model_small.yaml'#local stored weightsfacenet_recognition.create_classifier(aligned_images,pre_model,my_class,weight,test_classifier_type)
mininum每人需要的图像:1number张用于培训的图像 每人30美元(固定)
在图像上测试Classifier
此API用于测试我们训练有素的Classifier
pre_model='./pretrained_facenet_model/20170511-185253.pb'#locaiton of pret-trained model from Facenetmy_class='./my_classifier/my_classifier.pkl'#location where we want to savetest_classifier_type='nn'#type of model either svm or nnweight='./my_classifier/model_small.yaml'#local stored weightsfacenet_recognition.test_classifier(aligned_images,pre_model,my_class,weight,test_classifier_type)
mininum每人需要的图像:1
许可证
这个项目是根据麻省理工学院的许可证授权的-参见 LICENSE.md有关详细信息的文件
致谢
- 非常感谢David Sandberg为Facent所做的贡献
- 灵感来源于基于dlib的图书馆人脸识别
历史记录
0.1.4(2018-28-03)
- 第一个测试版。