美文网首页
python第七天 人脸识别

python第七天 人脸识别

作者: 敏姐姐_e9d0 | 来源:发表于2018-11-06 14:32 被阅读0次

    人脸识别(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)
    

    相关文章

      网友评论

          本文标题:python第七天 人脸识别

          本文链接:https://www.haomeiwen.com/subject/yvhuxqtx.html