AWS Rekognition给出了InvalidS3Exeption错误 [英] AWS Rekognition gives an InvalidS3Exeption error

查看:70
本文介绍了AWS Rekognition给出了InvalidS3Exeption错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我运行命令

aws rekognition detect-labels --image "S3Object={Bucket=BucketName,Name=picture.jpg}" --region us-east-1

我收到此错误.

InvalidS3ObjectException: An error occurred (InvalidS3ObjectException) when calling the DetectLabels operation: Unable to get image metadata from S3.  Check object key, region and/or access permissions.

我正在尝试检索我正在从事的项目的标签,但似乎无法超越这一步.我将访问密钥,秘密密钥,us-east-1区域和json配置为aws作为输出格式.

I am trying to retrieve labels for a project I am working on but I can't seem to get past this step. I configured aws with my access key, secret key, us-east-1 region, and json as my output format.

我也尝试了下面的代码,但收到了完全相同的错误(我将BucketName正确替换为我的存储桶的名称.)

I have also tried the code below and I receive the exact same error (I correctly Replaced BucketName with the name of my bucket.)

import boto3

BUCKET = "BucketName"
KEY = "picture.jpg"

def detect_labels(bucket, key, max_labels=10, min_confidence=90, region="eu-west-1"):
    rekognition = boto3.client("rekognition", region)
    response = rekognition.detect_labels(
        Image={
            "S3Object": {
                "Bucket": bucket,
                "Name": key,
            }
        },
        MaxLabels=max_labels,
        MinConfidence=min_confidence,
    )
    return response['Labels']


for label in detect_labels(BUCKET, KEY):
    print "{Name} - {Confidence}%".format(**label)

我可以在我的用户帐户上看到它正在调用Rekognition.显示它是从IAM调用的图像.

I am able to see on my user account that it is calling Rekognition. Image showing it being called from IAM.

问题似乎出在我的S3存储桶中,但是我还没有发现什么.

It seems like the issue is somewhere with my S3 bucket but I haven't found out what.

推荐答案

出于稳定性原因,S3和Rekognition的区域应该相同.

Region of S3 and Rekognition should be the same for stability reasons.

更多信息: https://forums.aws.amazon.com/thread.jspa?threadID = 243999

这篇关于AWS Rekognition给出了InvalidS3Exeption错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆