我正在通過它的 API 使用 MS 認知服務(wù)來分析圖像,并注意到當圖像處于橫向模式(“面部未垂直對齊”)時,它返回一個空結(jié)果。我很困惑,想知道是我做錯了什么,還是 MS 服務(wù)的工作方式。這是一個重現(xiàn)問題的簡單示例。您應(yīng)該擁有 MS Face 訂閱密鑰才能使用該服務(wù)!import requests# If you are using a Jupyter notebook, uncomment the following line.#%matplotlib inlineimport matplotlib.pyplot as pltfrom PIL import Imagefrom matplotlib import patchesfrom io import BytesIO# send request to MS, use YOUR subscription keysubscription_key = "982374kwhXXXxxxx"assert subscription_keyface_api_url ='https://westus.api.cognitive.microsoft.com/face/v1.0/detect'header = {'Ocp-Apim-Subscription-Key': face_api_url }headers = {'Ocp-Apim-Subscription-Key': subscription_key, "Content-Type": "application/octet-stream" }params = { 'returnFaceId': 'true', 'returnFaceLandmarks': 'false', 'returnFaceAttributes': 'age,gender,headPose,smile,facialHair,glasses,' + 'emotion,hair,makeup,occlusion,accessories,blur,exposure,noise'}# get a random image and convert to numpy arrayimage_url = 'https://how-old.net/Images/faces2/main007.jpg'image = Image.open(BytesIO(requests.get(image_url).content))image_np = np.array(image)這是圖像:
添加回答
舉報
0/150
提交
取消