Last active
July 24, 2018 19:45
-
-
Save DylanDmitri/eec14ba584952cfbf9c098d356715d71 to your computer and use it in GitHub Desktop.
Azure Face Python Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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