Skip to content

Update lambda_function.py #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions S3/Detecting-Faces-with-Rekognition/lambda_function.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import os

#this code is likely part of an AWS Lambda function that listens for S3 events (such as object uploads) and uses the Rekognition service to recognize celebrities in the uploaded images.
#It then stores the extracted face data (key and names) in a DynamoDB table.

import os
import boto3

#enviornment variable that is set outside of this code
TABLE_NAME = os.environ['TABLE_NAME']

dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table(TABLE_NAME)
s3 = boto3.resource('s3')
rekognition = boto3.client('rekognition')


#extracts information about an s3 object that triggered the lambda functino by passing in the even parameter. This is an entrypoint for the Lambda function when the Lambda function is triggered.
def lambda_handler(event, context):

# Get the object from the event
Expand All @@ -29,7 +33,7 @@ def lambda_handler(event, context):
names.append(name)

print(names)

#put_item is a method from the table object
print('Saving face data to DynamoDB table:', TABLE_NAME)
response = table.put_item(
Item={
Expand Down