人脸识别(http://ai.baidu.com/tech/face)
-
选择立即使用(登录百度账号)
-
创建应用:项目名称APPID,类型:游戏娱乐
则相应的APPID,API Key,secrel Key 就有了,把相对应的内容粘贴到代码中
from aip import AipFace
import base64
import pprint
APP_ID = ''
API_KEY = ''
SECRET_KEY = ''
aipFace = AipFace(APP_ID, API_KEY, SECRET_KEY)
filePath = ''#图片的位置和图片名称
def get_file_content(filePath):
with open(filePath, 'rb') as fp:
content = base64.b64encode(fp.read())
return content.decode('utf-8')
imageType = "BASE64"
options = {}
options["face_field"] = "age,gender,beauty"
result = aipFace.detect(get_file_content(filePath), imageType, options)
print(result)