import requests
import base64
import json
url = "https://hydra-ai.p.rapidapi.com/dev/faces/analyse/" // "https://hydra-ai.p.rapidapi.com/dev/image-analysis/multilabel/
payload = {"image": "https://bit.ly/3JXlkkA"} // payload = {"image": base64.b64encode(open("image.jpg", "rb").read()) }
headers = {
"content-type": "application/json",
"X-RapidAPI-Host": "hydra-ai.p.rapidapi.com",
"X-RapidAPI-Key": "YOUR_RAPIDAPI_KEY"
}
response = requests.request("POST", url, json=payload, headers=headers)
data = response.json()
print(data)
Response
{
"success": true,
"ndetected_faces": 1,
"detected_faces": [
{
"box": {
"top": 67,
"left": 24,
"width": 129,
"height": 129
},
"info": {
"age": "17-23",
"gender": "M",
"emotions": {
"angry": 0.39005,
"disgust": 0.00678,
"fear": 0.01622,
"happy": 0.15354,
"neutral": 0.34934,
"sad": 0.04738,
"surprise": 0.03668
},
"mask": {
"has_mask": false,
"confidence": 0.99741
},
"eyes": {
"closed_eyes": false
},
"mouth": {
"is_smiling": false,
"is_open": false
}
}
}
],
"total_inference_time":3609.113430023193
}