Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon Rekognition API - S3 MetaData Issue

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,

like image 435
Naveen Avatar asked Jan 07 '17 15:01

Naveen


People also ask

Can Amazon Rekognition identify people in a photo?

Rekognition Image is an image recognition service that detects objects, scenes, and faces; extracts text; recognizes celebrities; and identifies inappropriate content in images.

Which of the following is an advantage of using Amazon Rekognition with image files?

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.

What does Amazon Rekognition do with the results after it completes a video analysis?

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.

Is not authorized to perform Rekognition?

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.


2 Answers

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.

like image 69
Michael - sqlbot Avatar answered Sep 27 '22 15:09

Michael - sqlbot


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.

like image 27
Tiago Lubiana Avatar answered Sep 27 '22 17:09

Tiago Lubiana