人工智能入门
来自CloudWiki
开通服务
参考:
Python调用华为API: https://blog.csdn.net/m0_37758063/article/details/124126654
获取密钥
参考:
Python调用华为API: https://blog.csdn.net/m0_37758063/article/details/124126654
获取代码示例
参考: https://support.huaweicloud.com/api-face/face_02_0084.html
# -*- coding:utf-8 -*- import requests import base64 endpoint = '开通服务所在region的人脸识别服务域名' project_id = '开通服务所在region的用户项目ID' token = '用户获取得到的实际token值' headers = {'Content-Type': 'application/json', 'X-Auth-Token': token} url = "https://{endpoint}/v2/{project_id}/face-detect".format(endpoint=endpoint, project_id=project_id) imagepath = r'./data/face-demo.png' with open(imagepath, "rb") as bin_data: image_data = bin_data.read() image_base64 = base64.b64encode(image_data).decode("utf-8") body = {"image_base64": image_base64, "attributes": "2,12,13"} response = requests.post(url, headers=headers, json=body, verify=False) print(response.text)
获取人脸识别服务域名
获取人脸识别服务域名,endpoint
参考:
https://apiexplorer.developer.huaweicloud.com/apiexplorer/doc?product=FRS&api=DetectFaceByFile
https://face.cn-east-3.myhuaweicloud.com
获取项目ID
参考:
https://support.huaweicloud.com/api-face/face_02_0104.html
0c36ccaf4700f4372f04c0113fab029b