[英]Amazon Rekognition API - S3 MetaData Issue
I am trying to detect faces in an image using AWS Image Rekognition API.我正在尝试使用 AWS Image Rekognition API 检测图像中的人脸。 But getting the following Error:
但得到以下错误:
Error1:错误 1:
ClientError: An error occurred (InvalidS3ObjectException) when calling the DetectFaces operation: Unable to get image metadata from S3. Check object key, region and/or access permissions.
Python Code1: Python代码1:
def detect_faces(object_name="path/to/image/001.jpg"):
client = get_aws_client('rekognition')
response = client.detect_faces(
Image={
# 'Bytes': source_bytes,
'S3Object': {
'Bucket': "bucket-name",
'Name': object_name,
'Version': 'string'
}
},
Attributes=[
'ALL',
]
)
return response
The Object "path/to/image/001.jpg" exists in the AWS S3 Bucket "bucket-name".对象“path/to/image/001.jpg”存在于 AWS S3 存储桶“存储桶名称”中。 And the region Name is also correct.
并且区域名称也是正确的。
The Permissions for this object '001.jpg' is: Everyone is granted Open/Download/view Permission.这个对象'001.jpg'的权限是:每个人都被授予打开/下载/查看权限。 MetaData for the Object: Content-Type: image/jpeg
对象的元数据:内容类型:图像/jpeg
Not sure how to debug this.不知道如何调试这个。 Any Suggestion to resolve this please ?
有什么建议可以解决这个问题吗?
Thanks,谢谢,
You appear to be asking the service to fetch the object with a version id of string
.您似乎要求服务获取版本 ID 为
string
的对象。
Version
版本
If the bucket is versioning enabled, you can specify the object version.
如果存储桶启用了版本控制,您可以指定对象版本。
Type: String
类型:字符串
Length Constraints: Minimum length of 1. Maximum length of 1024.
长度限制:最小长度为 1。最大长度为 1024。
Required: No
要求:否
http://docs.aws.amazon.com/rekognition/latest/dg/API_S3Object.html#rekognition-Type-S3Object-Version
http://docs.aws.amazon.com/rekognition/latest/dg/API_S3Object.html#rekognition-Type-S3Object-Version
Remove 'Version': 'string'
from your request parameters, unless you really intend to fetch a specific version of the object from a versioned bucket, in which case, provide the actual version id of the object in question.从您的请求参数中删除
'Version': 'string'
,除非您确实打算从版本化存储桶中获取对象的特定版本,在这种情况下,请提供相关对象的实际版本 ID。
I had the same issue and avoid using '-' or whitespaces in bucket and uploaded file names solved it for me.我遇到了同样的问题,避免在存储桶中使用“-”或空格,上传的文件名为我解决了这个问题。
Maybe removing underscores can also help.也许删除下划线也有帮助。
Old thread, new solution: I got the same error message.旧线程,新解决方案:我收到相同的错误消息。 My mistake was due to a region mismatch;
我的错误是由于区域不匹配; My S3 bucket was residing in us-east-2, but my recognition client defaulted to us-west-1.
我的 S3 存储桶位于 us-east-2,但我的识别客户端默认为 us-west-1。 I changed the line
我换了线
client = get_aws_client('rekognition')
to到
client = get_aws_client('rekognition', region_name='us-east-2')
and it worked.它奏效了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.