Last active
April 22, 2019 09:10
-
-
Save qnkhuat/9d9afa7d2756917cfc2450fac360a47b to your computer and use it in GitHub Desktop.
Emotion recognition using microsoft api with local image
This file contains 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
import requests | |
import matplotlib.pyplot as plt | |
from PIL import Image | |
from matplotlib import patches | |
from io import BytesIO | |
face_api_url = _url # https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect | |
headers = {'Content-Type': 'application/octet-stream', 'Ocp-Apim-Subscription-Key': subscription_key} | |
params = { | |
'returnFaceId': 'true', | |
'returnFaceLandmarks': 'false', | |
'returnFaceAttributes': 'emotion' | |
} | |
data = open(image_path, 'rb') | |
response = requests.post(face_api_url , headers=headers, data=data,params=params) | |
faces = response.json() | |
print(faces) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment