Skip to content

Instantly share code, notes, and snippets.

@wwwins
Created May 24, 2017 06:30
Show Gist options
  • Save wwwins/03016806a5a9f7bdc3062a07c283cfb6 to your computer and use it in GitHub Desktop.
Save wwwins/03016806a5a9f7bdc3062a07c283cfb6 to your computer and use it in GitHub Desktop.
aws rekognition detect faces api
#!/usr/bin/env python
"""
Usage:
python detectface.py -i image.jpg
"""
from argparse import ArgumentParser
import boto3
from pprint import pprint
def get_client(endpoint):
client = boto3.client('rekognition')
return client
def get_args():
parser = ArgumentParser(description='Detect faces')
parser.add_argument('-e', '--endpoint')
parser.add_argument('-i', '--image')
return parser.parse_args()
if __name__ == '__main__':
args = get_args()
client = get_client(args.endpoint)
with open(args.image, 'rb') as image:
response = client.detect_faces(Image={'Bytes': image.read()},Attributes=['ALL'])
pprint(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment