from aip import AipFace
import base64
""" 你的 APPID AK SK """
APP_ID = '你的 App ID'
API_KEY = '你的 Api Key'
SECRET_KEY = '你的 Secret Key'
client = AipFace(APP_ID, API_KEY, SECRET_KEY)
f = open(r'%s' % './images/hu1.jpg', 'rb')
pic = base64.b64encode(f.read())
image = str(pic, 'utf-8')
imageType = "BASE64"
""" 如果有可选参数 """
options = {}
options["face_field"] = "age,beauty,gender"
options["max_face_num"] = 10
options["face_type"] = "LIVE"
""" 带参数调用人脸检测 """
a = client.detect(image, imageType, options)
for item in a['result']['face_list']:
print("年龄:",item['age'],"容貌评分:",item['beauty'],"性别:",item['gender'])
检测这张图片
结果