Question:
I am trying to detect faces in an image using AWS Image Rekognition API. But getting the following Error:
Error1:
1 2 |
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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”. And the region Name is also correct.
The Permissions for this object ‘001.jpg’ is: Everyone is granted Open/Download/view Permission.
MetaData for the Object: Content-Type: image/jpeg
Not sure how to debug this. Any Suggestion to resolve this please ?
Thanks,
Answer:
You appear to be asking the service to fetch the object with a version id of 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.
Required: No
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.