python第七天 人脸识别

人脸识别(http://ai.baidu.com/tech/face

人脸识别1.png

  • 选择立即使用(登录百度账号)


    人脸识别2.png
  • 创建应用:项目名称APPID,类型:游戏娱乐


    人脸识别3.png

    则相应的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)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容