[英]Amazon Rekognition detect_labels does not return Instances or Parents
根据https://docs.aws.amazon.com/rekognition/latest/dg/labels-detect-labels-image.html#detectlabels-response和https://docs.aws.amazon.com/rekognition/latest/dg /API_DetectLabels.html ,Amazon Rekognition 应返回带有每个标签的实例(边界框详细信息)和父项。 但是,在成功运行具有与上述链接类似的实现的 detect_labels 后,我的响应中唯一的键是“名称”和“置信度”; 'Instances' 和 'Parents' 甚至都不是键,更不用说具有空值的键了。
有人有想法吗?
我的代码如下:
def _bounding_box(imageFile):
client = boto3.client('rekognition')
with open(imageFile, 'rb') as image:
response = client.detect_labels(Image={'Bytes': image.read()})
print('Detected labels in ' + imageFile)
for label in response['Labels']:
print(label)
print("Label: " + label['Name'])
print("Confidence: " + str(label['Confidence']))
print("Instances:")
for instance in label['Instances']:
print(" Bounding box")
print(" Top: " + str(instance['BoundingBox']['Top']))
print(" Left: " + str(instance['BoundingBox']['Left']))
print(" Width: " + str(instance['BoundingBox']['Width']))
print(" Height: " + str(instance['BoundingBox']['Height']))
print(" Confidence: " + str(instance['Confidence']))
print()
print('Parents: ')
for parent in label['Parents']:
print(" " + parent['Name'])
print("----------")
print()
我能够准确地再现您的结果。
然后,我更新了我的boto3
版本,并返回了Instances
信息。
Instances
:版本1.9.16 Instances
:版本1.9.104 您可以通过以下方式发现版本:
>>> import boto3
>>> boto3.__version__
因此,更新您的boto3
。 ( pip install boto3 --upgrade
)
通常,使用虚拟环境来保持环境整洁是件好事。
仅供参考,升级Boto对我没有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.