Created
July 11, 2018 18:23
-
-
Save daniel-woods/eb9bf2e5a475ccd11eb7808899135cee to your computer and use it in GitHub Desktop.
Script for doing some common Rekognition Video queries on common APIs (StartFaceSearch, StartCelebrityRecognition, StartContentModeration)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python2.7 | |
| # Script for doing some common Rekognition Video queries | |
| import boto3 | |
| import json | |
| from time import sleep | |
| bucket = "YOUR_BUCKET" | |
| s3_path = "PATH/TO/FILE.mp4" | |
| region = "AWS_REGION" # ex: eu-west-1 | |
| # Create Video Object and Start the Search operation | |
| rk_client = boto3.client('rekognition', region_name=region) | |
| vid_object = {"S3Object": {"Bucket": bucket, "Name": s3_path}} | |
| ## StartFaceSearch | |
| # rspns = rk_client.start_face_search(CollectionId='custom_celebrities',Video=vid_object) | |
| ## StartCelebrityRecognition | |
| # rspns = rk_client.start_celebrity_recognition(Video=vid_object) | |
| ## StartContentModeration | |
| rspns = rk_client.start_content_moderation(Video=vid_object) | |
| print(json.dumps(rspns, indent=4)) | |
| sleep(5) | |
| while True: | |
| # Search for the collection, check to see if job is complete. | |
| ## GetFaceSearch | |
| # response = rk_client.get_face_search(JobId=rspns['JobId']) | |
| ## GetCelebrityRekognition | |
| # response = rk_client.get_celebrity_recognition(JobId=rspns['JobId']) | |
| ## GetContentModeration | |
| response = rk_client.get_content_moderation(JobId=rspns['JobId']) | |
| if response['JobStatus'] == 'IN_PROGRESS': | |
| sleep(60) | |
| else: | |
| print(json.dumps(response, indent=4)) | |
| break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment