Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (5.6k points)

I'm able to compare two images if they are located at the root of the S3 bucket

const params = {

  SourceImage: {

    S3Object: {

      Bucket: bucket,

      Name: 'source.jpg'

    }

  },

  TargetImage: {

    S3Object: {

      Bucket: bucket,

      Name: 'target.jpg'

    }

  },

  SimilarityThreshold: 90

}

But I'm getting an error if they are in sub-folders:

message: 'Request has invalid parameters',

code: 'InvalidParameterException',

time: 2019-11-25T13:12:44.498Z,

requestId: '7ac7f297-fc36-436b-a1dc-113d419da766',

statusCode: 400,

retryable: false, retryDelay: 71.0571139838835

If I'm trying to compare images in sub-folders, still same thing:

const params = {

  SourceImage: {

    S3Object: {

      Bucket: bucket,

      Name: '/sub1/sub2/source.jpg'

    }

  },

  TargetImage: {

    S3Object: {

      Bucket: bucket,

      Name: '/sub1/sub2/target.jpg'

    }

  },

  SimilarityThreshold: 90

}

Any help would be appreciated!!

1 Answer

0 votes
by (12.4k points)

Here providing you with the working example, hope that helps you.

import boto3

reko=boto3.client('rekognition')

resp = reko.compare_faces(

        SourceImage={

        'S3Object': {

            'Bucket': 'jsimon-public-us',

            'Name': 'pref1/image1.jpg',

        }},

        TargetImage={

        'S3Object': {

            'Bucket': 'jsimon-public-us',

            'Name': 'pref2/image2.jpg',

        }}

)

print(resp)

Want to become AWS Expert? Come & join AWS Certification.

Related questions

+1 vote
1 answer
Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...