Skip to content

Instantly share code, notes, and snippets.

@DylanDmitri
Last active July 24, 2018 19:45
Show Gist options
  • Save DylanDmitri/eec14ba584952cfbf9c098d356715d71 to your computer and use it in GitHub Desktop.
Save DylanDmitri/eec14ba584952cfbf9c098d356715d71 to your computer and use it in GitHub Desktop.
Azure Face Python Demo
def get_face_info(image_bytes):
url = 'https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect'
params = {
'returnFaceId': 'true',
'returnFaceLandmarks': 'false',
'returnFaceAttributes': 'age,gender,headPose,smile,facialHair,glasses,' +
'emotion,hair,makeup,occlusion,accessories,blur,exposure,noise',
}
headers = {
'Ocp-Apim-Subscription-Key': SUBSCRIPTION_KEY,
'Content-type': 'application/octet-stream',
}
return requests.post(url, params=params, headers=headers, data=image_bytes).json()
file_name = '/Users/dg/Downloads/demo_image.jpg'
get_face_info(open(file_name, 'rb').read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment