我在stackoverflow和python编程方面是新手,我正在尝试使用skybiometry.com的服务从我的硬盘中获取图像的情感分析。它们的示例链接类似于:"http://api.skybiometry.com/fc/faces/detect.json?api_key=aa754b54b37&api_secret=4b3a4c6d4c&urls=http://theweeklyworld.com/wp-content/uploads/2014/08/child-happy-face1.jpg&attributes=all“,我想在我的python脚本中对我的图像执行此操作。在他们的网站https://skybiometry.com/documentation/ On point 4.13上,他们说,如果我想要分析硬盘中的图像,请求必须以MIME形式存在。我不知道如何处理这件事。在我的另一个项目中,我做了这样的请求
import requests
auth_headers = {
'api_key': api_key,
'api_secret': api_secret,
}
url = 'http://api.skybiometry.com/fc/faces/detect'
files = { 'source': open(path + ".jpg", 'rb')
}
data = { 'timeout': 60
}
response = requests.post(url, files=files, data=data, headers=auth_headers)
print (response.json())
有没有人能帮我调整一下这个请求,让它正常工作?非常感谢!
发布于 2017-08-13 14:59:11
您需要更改您自己的skybiometry凭据的api_key
和api_secret
才能使用该python脚本。
无论如何,我更喜欢先为python安装api客户端skybiometry,然后再使用您的python脚本。要安装它,您需要执行以下步骤:
git clone git@github.com:SkyBiometry/python-face-client.git
cd python-face-client
python setup.py build
python setup.py install
然后,您可以通过import
和您的skybiometry凭证一起使用api-client,例如:
from face_client import FaceClient
client = FaceClient('API_KEY', 'API_SECRET')
更改您自己的skybiometry凭证的API_KEY
和API_SECRET
。
有关更多示例以及如何使用api-client,可以查看以下内容:https://github.com/SkyBiometry/python-face-client
欢迎光临。
https://stackoverflow.com/questions/41020479
复制相似问题