Skip to content

Instantly share code, notes, and snippets.

@beabetterdevv
Created November 27, 2022 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beabetterdevv/899419b7f7251db191ee02cbdf80d6d8 to your computer and use it in GitHub Desktop.
Save beabetterdevv/899419b7f7251db191ee02cbdf80d6d8 to your computer and use it in GitHub Desktop.
import json
import boto3
client = boto3.client('rekognition')
# Permissions Required
# s3:GetObject
# rekognition:DetectFaces
# DetectFaces API Documentation - https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DetectFaces.html
def lambda_handler(event, context):
# TODO implement
bucket_name = "bbdev-images"
file_name = "daniel_dogs.JPG"
response = client.detect_faces(Image={'S3Object':{'Bucket':bucket_name,'Name':file_name}},Attributes=['ALL'])
# Process result
for face in response['FaceDetails']:
print(json.dumps(face['AgeRange']['Low'], indent=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment