Amazon rekrecognition错误,试图访问S3文件



这是我在尝试从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.

斗→桶的名称名字→文件名称(例如: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 textn----------')
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

我把你的代码,修改它引用我的桶和对象,并导入boto3。

给出了与完全相同的错误你收到了。然后我意识到我的桶在悉尼地区,所以我删除了region_name参数,所以它将使用我的默认区域(悉尼)。

然后我再次运行它,它工作得很好.

作为一个实验,我改变了Name指向一个不存在的对象。它又给出了错误信息。

因此,您的问题很可能是us-east-1中的bucket不是,或者提供了不正确的bucket名称或密钥。

最新更新