最近有想要看一下人脸表情分析,这方面已经很成熟了。找到了Deepface,记录一下配置过程。
安装Deepface
安装deepface,它会顺带把opencv也安装好。
pip install deepface
安装到最后报错
ERROR: Cannot uninstall ‘wrapt’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall
解决方法:
pip install wrapt --ignore-installed
运行demo
from deepface import DeepFace
import cv2 as cv
img = cv.imread("happy.jpg")
prediction = DeepFace.analyze(img)
print(prediction)
应该就会下载权重文件,如果下载得慢的话可以手动下载然后放进.deepface文件夹里。下载过程会显示下载的链接。
如果期间报错
OSError: Unable to open file (truncated file: eof = 207375855, sblock->base_addr = 0, stored_eof = 538771776)
说明是下载错误然后没有删掉下载错误的文件,所以文件损坏打不开,删掉对应文件就好了。