基于 Python + 百度AI 开发的多种人脸属性识别程序
可检测:年龄、 颜值、表情、脸型、性别、眼镜、情绪等各种人脸属性
程序代码如下:
# -*- coding:utf-8 -*-
from aip import AipFace
import base64
def shibe(file):
""" 你的 APPID AK SK """
APP_ID = ''
API_KEY = ''
SECRET_KEY = ''
client = AipFace(APP_ID, API_KEY, SECRET_KEY)
with open(file, "rb") as f:
data = f.read()
encodestr = base64.b64encode(data) # 得到 byte 编码的数据
images = str(encodestr, 'utf-8') # 重新编码数据
image = images
imageType = "BASE64"
""" 调用人脸检测 """
# m = client.detect(image, imageType)
""" 如果有可选参数 """
options = {}
options["face_field"] = "age,beauty,expression,face_shape,gender,glasses,emotion"
"