[英]Amazon Rekognition error when trying to access S3 file
This is the error that I see when trying to run text detection on an image from my s3 bucket: botocore.errorfactory.InvalidS3ObjectException: An error occurred (InvalidS3ObjectException) when calling the DetectText operation: Unable to get object metadata from S3. Check object key, region and/or access permissions.
这是我在尝试对 s3 存储桶中的图像运行文本检测时看到的错误: botocore.errorfactory.InvalidS3ObjectException: An error occurred (InvalidS3ObjectException) when calling the DetectText operation: Unable to get object metadata from S3. Check object key, region and/or access permissions.
botocore.errorfactory.InvalidS3ObjectException: An error occurred (InvalidS3ObjectException) when calling the DetectText operation: Unable to get object metadata from S3. Check object key, region and/or access permissions.
bucket -> name of the bucket name -> name of the file (ex: 123.jpg)存储桶 -> 存储桶名称 -> 文件名(例如:123.jpg)
MY CODE (python):我的代码(蟒蛇):
client=boto3.client('rekognition', region_name='us-east-1')
print('works till here')
response=client.detect_text(Image={'S3Object':{'Bucket': bucket,'Name': name}})
print('works till here 2')
textDetections=response['TextDetections']
print ('Detected text\n----------')
for text in textDetections:
print ('Detected text:' + text['DetectedText'])
print ('Confidence: ' + "{:.2f}".format(text['Confidence']) + "%")
print ('Id: {}'.format(text['Id']))
if 'ParentId' in text:
print ('Parent Id: {}'.format(text['ParentId']))
print ('Type:' + text['Type'])
print()
return len(textDetections)
S3 bucket is on global and rekogntion is on us-east-1
I took your code, modified it to reference to my bucket and object, and imported boto3.我接受了您的代码,将其修改为引用我的存储桶和对象,并导入了 boto3。
It gave exactly the same error that you received.它给出了与您收到的完全相同的错误。 I then realised that my bucket is in the Sydney region, so I removed the region_name
parameter, so it would use my default region (Sydney).然后我意识到我的存储桶在悉尼地区,所以我删除了region_name
参数,所以它会使用我的默认地区(悉尼)。
I then ran it again and it worked just fine .然后我再次运行它,它工作得很好。
As an experiment, I then changed the Name
to point to a non-existent object.作为一个实验,我随后将Name
更改为指向一个不存在的对象。 It gave the error message again.它再次给出了错误消息。
Therefore, your problem is likely to be either that the bucket is not in us-east-1
, or an incorrect bucket name or key has been provided.因此,您的问题很可能是存储桶不在us-east-1
,或者提供了不正确的存储桶名称或密钥。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.