Кажется, что URL, который вы генерируете, неверен. Можете ли вы попробовать следующий код,
apikey = "e720e03190c41148ec555889daf2f64"
assert apikey
api_url = "https://southeastasia.api.cognitive.microsoft.com/vision/v2.0/"
analyse_api = api_url + "analyze"
image_data = img
headers = {"Ocp-Apim-Subscription-Key": apikey,
'Content-Type': 'application/octet-stream'}
params = {'visualFeatures':'Categories,Description,Color,Objects,Faces'}
response = requests.post(
analyse_api, headers=headers, params=params, data=image_data)
response.raise_for_status()
analysis = response.json()
#image_caption = analysis["description"]["captions"][0]["text"].capitalize()
people = 0
for i in analysis['objects']:
if i['object'] == 'person':
people += 1
describepeople = []
for i in analysis['faces']:
describepeople.append(i['gender'] + ' ' + str(i['age']))
tags = analysis['description']['tags']
return[people, describepeople, tags]