Windows環境搭建 face_recognition,dlib

文章參考:http://www.javashuo.com/article/p-qrrzvcdy-r.htmlpython

文章參考:http://www.javashuo.com/article/p-qfqincbn-ce.htmlgit

文章參考:http://www.javashuo.com/article/p-skmozzyk-ko.htmlgithub

 

該庫能夠經過python或者命令行便可實現人臉識別的功能。使用dlib深度學習人臉識別技術構建,在戶外臉部檢測數據庫基準(Labeled Faces in the Wild)上的準確率爲99.38%。 在github上有相關的連接和API文檔。 數據庫

配置環境

安裝dlib

方法一

首先配置dlib學習

我這裏有一個dlib包,連接:https://pan.baidu.com/s/1drnxz251fvVVc9qoh61TTg 提取碼:9pcl spa

下載好後運行cmd或者 pycharm的terminal 進入dlib 包所在的路徑下,運行.net

pip install 【所下載的包】
import dlib 

 

方法二

https://pypi.org/project/dlib/18.17.100/#downloads 找到須要的dlib版本命令行

 

 

新版本須要自行編譯3d

下載好後pip install 【文件路徑】安裝code

 

安裝face_recognition

直接使用 pip install 便可 我使用了 清華園的鏡像

注意:下載速度過慢會報錯

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple face_recognition
import face_recognition

 

寫一小段代碼進行驗證,我準備了四張圖片

 

 1 import face_recognition
 2 mayun_image = face_recognition.load_image_file("mayun.jpg");
 3 jobs_image = face_recognition.load_image_file("jobs.jpg");
 4 task1_image = face_recognition.load_image_file("task1.jpg");
 5 
 6 mayun_encoding = face_recognition.face_encodings(mayun_image)[0]
 7 jobs_encoding = face_recognition.face_encodings(jobs_image)[0]
 8 task1_encoding = face_recognition.face_encodings(task1_image)[0]
 9 
10 results = face_recognition.compare_faces([mayun_encoding, jobs_encoding], task1_encoding)
11 labels = ['mayun', 'jobs']
12 
13 print('results:'+str(results))
14 
15 for i in range(0, len(results)):
16     if results[i] == True:
17         print('The person is:'+labels[i])

運行結果

相關文章
相關標籤/搜索