Hydra AI

FREEMIUM
(Ким) Alessandro Lamberti | Оновлено 19 days ago | Artificial Intelligence/Machine Learning
Популярність

7.8 / 10

Затримки

6,420ms

Рівень обслуговування

97%

Health Check

N/A

Повернутися до всіх обговорень

Indexing into individual values

Rapid account: Quarks 1
Quarks1
2 years ago

I was wondering how I could index into the individual values of response, such as emotions or age. When i try to the normal way (treating it like a dictionary) it gives me not subscriptable error.

Rapid account: Alessandro Lamberti 98
alessandro.lamberti98 Commented 2 years ago

From the app logs, you never had errors. So I’d say it’s either something you’re doing code-wise, or I’m not sure, especially because you’re saying it happens only occasionally

Rapid account: Quarks 1
Quarks1 Commented 2 years ago

For some reason when i try using response.raise_for_status() it will ocassionally error out and return 400 client error: Bad request for url. The way I have this setup is taking a picutre from a webcam and then encoding it into base64 and having that be the payload. Is there something that could be going wrong with this method of doing so?

Rapid account: Alessandro Lamberti 98
alessandro.lamberti98 Commented 2 years ago

It honestly never happened to me, could you provide more information on this? Like the different scenarios you’re trying, or it’s always with the same image?

Rapid account: Quarks 1
Quarks1 Commented 2 years ago

I’m currently having an issue where randomly I’ll get the error “TypeError: the JSOn osbjext must be str, bytes, or bytearray, not dict” when trying to do json.loads. It’s weird because it works sometimes, but then other times causes this error without changing the code at all. Do you know why this happens?

Rapid account: Alessandro Lamberti 98
alessandro.lamberti98 Commented 2 years ago

You’re absolutely right! Thanks a lot for pointing it out! I will soon update my docs, in the meantime, this works for me:

import requests
import json

url = "https://hydra-ai.p.rapidapi.com/dev/faces/analyse/"

payload = {"image": "https://bit.ly/3JXlkkA"}
headers = {
	"content-type": "application/json",
	"X-RapidAPI-Host": "hydra-ai.p.rapidapi.com",
	"X-RapidAPI-Key": "API_KEY"
}

response = requests.request("POST", url, json=payload, headers=headers)
data = json.loads(response.json())

print(data["detected_faces"][0]["info"]["emotions"]) 

Do let me know if you have other questions or any feedback!
Cheers

Приєднуйтесь до обговорення — додайте повідомлення нижче:

Вхід / Реєстрація, щоб публікувати нові повідомлення