《阿里云AI产品必知必会系列电子书》——阿里云视觉智能开放平台——人脸识别QuickStart使用教程(上) https://developer.aliyun.com/article/1232507?groupCode=supportservice
三、通过Python-SDK调用人脸人体-明星识别
1、pip install
pip install aliyun-python-sdk-facebody==1.2.33
2、创建DetectCelebrity
from aliyunsdkcore.client import AcsClient from aliyunsdkcore.auth.credentials import AccessKeyCredential from aliyunsdkfacebody.request.v20191230.DetectCelebrityRequest import DetectCelebrityRequest credentials = AccessKeyCredential('accesskey','accesskeysecret') client = AcsClient(region_id='cn-shanghai', credential=credentials) request = DetectCelebrityRequest() request.set_accept_format('json') request.set_ImageURL("url") response = client.do_action_with_exception(request) print(str(response, encoding='utf-8'))
3、测试结果
{ "RequestId": "39**A90-8760-533C-BA48-B1***40", "Data": { "FaceRecognizeResults": [ { "FaceBoxes": [ 0.3861111111111111, 0.16295264623955433, 0.3314814814814815, 0.6016713091922006 ], "Name": "比尔·盖茨" } ], "Height": 718, "Width": 1080 } }
from aliyunsdkcore.auth.credentials import AccessKeyCredential from aliyunsdkfacebody.request.v20191230.CompareFaceRequest import CompareFaceRequest credentials = AccessKeyCredential('accesskey', 'accesskeysecret') client = AcsClient(region_id='cn-shanghai', credential=credentials) request = CompareFaceRequest() request.set_accept_format('json') request.set_QualityScoreThreshold(0) request.set_ImageURLA("urlA") request.set_ImageURLB("urlB") response = client.do_action_with_exception(request) print(str(response, encoding='utf-8'))
3、测试结果
{ "RequestId": "6***1-4E5C-5F58-8340-12****771", "Data": { "QualityScoreA": 90.33343505859375, "QualityScoreB": 90.33343505859375, "Thresholds": [ 61, 69, 75 ], "Confifidence": 99.99996185302734, "RectAList": [ 418, 112, 359, 434 ], "RectBList": [ 418, 112, 359, 434 ] } }