`

[AI]如何使用face_recognition

    博客分类:
  • AI
阅读更多

github: https://github.com/ageitgey/face_recognition

以下是MAC环境下安装:

1. 先安装Pillow:

pip install pillow: https://stackoverflow.com/questions/26505958/why-cant-python-import-image-from-pil

 

2.安装cmake:

  1. Install cmake:  https://www.jianshu.com/p/7fff1f77dd9d

3.安装dlib:

 https://gist.github.com/ageitgey/629d75c1baac34dfa5ca2a1928a7aeaf

 

 

Clone the code from github:

git clone https://github.com/davisking/dlib.git
Build the main dlib library (optional if you just want to use Python):

cd dlib
mkdir build; cd build; cmake ..; cmake --build .
Build and install the Python extensions:

cd ..
python3 setup.py install
At this point, you should be able to run python3 and type import dlib successfully.

 

前面步骤没什么问题,到cmake的时候可能会报错,这里需要先配置环境变量:

 

open -e .bash_profile
export CMAKE_C_COMPILER=/usr/local/bin/gcc
export CMAKE_CXX_COMPILER=/usr/local/bin/g++
source .bash_profile

 

然后通过cmake App UI生成sources文件到build文件夹,再cmake --build以下

即可执行setup.py

 

4.执行pip install face_recognition

 

5.PyCharm project interpreter找不到依赖包:

这个问题很奇怪,IDE使用conda的python环境,可以找到Pillow的依赖,但是找不到face_recognition的依赖

但是在控制台那里已经可以执行face_recognition的命令,证明安装成功了

同时如果在控制台通过命令执行自己写的face.py是可以运行成功的.所以不知道为什么IDE识别不了依赖包

这种问题应该是macbook里面装了多个python环境导致,然后我换了项目的python环境(/usr/bin/python3),发现可以找到face_recognition,但是

- 报pip版本低,然后我cd到目录下执行:pip install --upgrade pip升级成功

- 报ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied:

   解决办法:提升/usr/bin的文件权限,这个操作稍有麻烦

要不就把IDE的python环境改变为/usr/local/bin/python3.6

***奇怪的一点是IDE使用conda的环境,所有pip都升级了,在控制台搜索which face_recognition发现也是安装在conda的目录下,就是怎么也找不到依赖,反而/usr/bin & /usr/local/bin的环境下可以搜到依赖

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics