我试图运行我的代码来比较两张脸之间的相似性,但无法得到输出

2024-05-26 11:55:25 发布

您现在位置:Python中文网/ 问答频道 /正文

当我运行代码时,它运行得很好,但问题是我得到的是一个空白输出

“这是针对我想要创建的应用程序,以便我可以识别以下两张脸是同一个人还是不同的人。”


import json

from facepplib import FacePP, exceptions

face_detection=""
faceset_initialize=""
face_search=""
face_landmarks=""
dense_facial_landmarks=""
face_attributes=""
beauty_score_and_emotion_recognition=""

def face_comparing(app):
    """
    Compare two faces and decide whether they are from the same person.

    """
    print('[Face Comparing]')

    #1) Compare two images of websiite:
    img_url1 ='https://ibb.co/bv2zdgP'
    img_url2 ='https://ibb.co/m49ZDQ1'

    #2) Compare two local drivve images:
    #img_url1=
     #img_url2=

    cmp_ = app.compare.get(image_url1=img_url1,image_url2=img_url2)

    print('image1' , '=' , cmp_.image1)
    print('image2' , '=' , cmp_.image2)

    print('thresholds', '=', json.dumps(cmp_.thresholds, indent=4))
    print('confidence', '=', cmp_.confidence)

    if cmp_.confidence>70:
         print('Both faces are same')

    else:
        print('Both Faces are different')


if __name__ == '_main__':

        api_key  ='xQLsTmMyqp1L2MIt7M310h-cQiy0Dwhl'
        api_secret ='TyBSGw8NBEP9Tbhv_JbQM18mIlorY6-D'
        app_ = FacePP(api_key=api_key, api_secret=api_secret)

        funcs = [
            face_detection,
            faceset_initialize,
            face_search,
            face_landmarks,
            dense_facial_landmarks,
            face_attributes,
            beauty_score_and_emotion_recognition

        ]
        face_comparing(app_)

        try:

            app_ = FacePP(api_key=api_key, api_secret=api_secret)

            funcs = [
                face_detection,
            faceset_initialize,
            face_search,
            face_landmarks,
            dense_facial_landmarks,
            face_attributes,
            beauty_score_and_emotion_recognition

            ]
            face_comparing(app_)

        except exceptions.BaseFacePPError as e:
            print('Error:',e)

C:\Users\siddi\AppData\Local\Programs\Python 37-32\Python.exe C:/Users/siddi/.PyCharmCE2019.2/config/scratch/scratch_2.py

进程已完成,退出代码为0


Tags: andkeyapiappimgsecretfaceprint