import boto3
if __name__ == "__main__":
bucket='MyBucketName'
sourceFile='pic1.jpg'
targetFile='pic2.jpg'
client=boto3.client('rekognition','us-east-1')
response=client.compare_faces(SimilarityThreshold=70,
SourceImage={'S3Object':{'Bucket':bucket,'Name':sourceFile}},
TargetImage={'S3Object':{'Bucket':bucket,'Name':targetFile}})
for faceMatch in response['FaceMatches']:
position = faceMatch['Face']['BoundingBox']
confidence = str(faceMatch['Face']['Confidence'])
print('The face at ' +
str(position['Left']) + ' ' +
str(position['Top']) +
' matches with ' + confidence + '% confidence')
I am trying to compare two images present in my bucket but no matter which region i select i always get the following error:-
botocore.errorfactory.InvalidS3ObjectException: An error occurred (InvalidS3ObjectException) when calling the CompareFaces operation: Unable to get object metadata from S3. Check object key, region and/or access permissions.
My bucket's region is us-east-1 and I have configured the same in my code. what am I doing wrong?
It happened to me using the AWS rekognition sdk for android , the problem was that the region of the S3 bucket is not the same in my request , so I had to put the correct region in the request (same as S3 bucket ) :
rekognitionClient.setRegion(Region.getRegion(Regions.US_WEST_1));//replace with your S3 region
I had the same problem. What I did to fix it was to rearrange my bucket and the folders. Make sure that your image is directly in your bucket and not in a folder in your bucket. Also double check that the name of the images are correct and that everything is on point.
Check if the S3 and Image Rekognition is in the same region, I know, it's not nice or documented (I guess), but this guys are talking about it here and here
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