简体   繁体   English

Amazon Rekognition detect_labels 不返回实例或父项

[英]Amazon Rekognition detect_labels does not return Instances or Parents

Per https://docs.aws.amazon.com/rekognition/latest/dg/labels-detect-labels-image.html#detectlabels-response and https://docs.aws.amazon.com/rekognition/latest/dg/API_DetectLabels.html , Amazon Rekognition should return Instances (bounding box details) and Parents with each label.根据https://docs.aws.amazon.com/rekognition/latest/dg/labels-detect-labels-image.html#detectlabels-responsehttps://docs.aws.amazon.com/rekognition/latest/dg /API_DetectLabels.html ,Amazon Rekognition 应返回带有每个标签的实例(边界框详细信息)和父项。 However, upon successfully running detect_labels with an implementation similar to that of the above links, the only keys in my response are 'Name' and 'Confidence';但是,在成功运行具有与上述链接类似的实现的 detect_labels 后,我的响应中唯一的键是“名称”和“置信度”; 'Instances' and 'Parents' are not even keys, let alone keys with empty values. 'Instances' 和 'Parents' 甚至都不是键,更不用说具有空值的键了。

Does anyone have any thoughts?有人有想法吗?

My code is below:我的代码如下:

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()

I was able to exactly reproduce your results. 我能够准确地再现您的结果。

I then updated my version of boto3 and the Instances information was returned. 然后,我更新了我的boto3版本,并返回了Instances信息。

  • Instances not returned: Version 1.9.16 未返回Instances :版本1.9.16
  • Instances returned: Version 1.9.104 返回的Instances :版本1.9.104

You can discover the version with: 您可以通过以下方式发现版本:

>>> import boto3
>>> boto3.__version__

Therefore, update your boto3 . 因此,更新您的boto3 ( pip install boto3 --upgrade ) pip install boto3 --upgrade

It is normally good to use virtual environments to keep things cleaner. 通常,使用虚拟环境来保持环境整洁是件好事。

仅供参考,升级Boto对我没有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM