I am trying to detect faces in an image using AWS Image Rekognition API. But getting the following Error:
Error1:
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:
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,
Rekognition Image is an image recognition service that detects objects, scenes, and faces; extracts text; recognizes celebrities; and identifies inappropriate content in images.
You just provide an image or video to the Amazon Rekognition API, and the service can identify objects, people, text, scenes, and activities. It can detect any inappropriate content as well. Amazon Rekognition also provides highly accurate facial analysis, face comparison, and face search capabilities.
Amazon Rekognition retains the results of a video analysis operation for 7 days. You will not be able to retrieve the analysis results after this time.
I am not authorized to perform an action in Amazon Rekognition. If the AWS Management Console tells you that you're not authorized to perform an action, then you must contact your administrator for assistance. Your administrator is the person that provided you with your user name and password.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With