根据百度的AI平台,写了个demo。放了两张图跑了一下,百度AI的评分太苛刻了,好多明星连60都没。。。(逃
from aip import AipFace
import base64
# 定义常量
#
APP_ID = '***'
API_KEY = '***'
SECRET_KEY = '***'
# 初始化AipFace对象
aipFace = AipFace(APP_ID, API_KEY, SECRET_KEY)
# 设置图片路径
filePath = "1.jpg"
#将图片进行base64编码,再url编码
def get_file_content(filePath):
with open(filePath, 'rb') as fp:
image = fp.read()
image_data = base64.b64encode(image)
return image_data.decode("utf-8")
# 定义参数变量
options ={}
options['face_field'] = 'age,beauty'
imageType = "BASE64"
# 调用人脸属性检测接口
result = aipFace.detect(get_file_content(filePath),imageType,options)
print(result)
print(type(result))