人脸识别需要安装一个库:face_recognition
conda install face_recognition
还需要的库有torch。但是这个版本可以不需要gpu,所以下cpu版本的也可以。
然后在本地gitclone这个:
https://github.com/miaoxingjun/indentifysex.git
在python中的调用方法:
# indentifysex
#该模块通过判断照片中的人来判断其性别,男性返回1,女性返回0,可使用cpu
#This module determines the gender of a person in a photograph and returns 1 for males and 0 for females with cpu
#调用方法(Usage):
from identifysex.idsex import identifysex
url = r'pic.jpg' # 图片的路径地址,可以是本地图片,也可以是网络的图片
a = identifysex(url)
print(a)
其中,如果输出结果为0,性别为女,如果为1,则为男。