Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Kinda working locally
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyjbowers committed Sep 18, 2017
1 parent e976975 commit dffea10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions rekognitionrecognizer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import boto3
import json
import logging
import requests
Expand All @@ -19,11 +20,11 @@ def recognize(self, image):
logging.info("Getting image file")
image.get_image_file().seek(0)

logging.info("Posting to rekognition at %s" % self.recognition_endpoint)
r = requests.post(self.recognition_endpoint, files={'file': image.get_image_file().read()})
client = boto3.client('rekognition')
r = client.recognize_celebrities(Image={"Bytes": image.get_image_file().read()})

logging.info("Face object returned: %s" % r.text)
face_obj = json.loads(r.text)
logging.info("Face object returned: %s" % r)
face_obj = (r)

if ("CelebrityFaces" in face_obj and len(face_obj['CelebrityFaces']) > 0):
celeb_objs = face_obj['CelebrityFaces']
Expand Down
4 changes: 3 additions & 1 deletion twilio_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
)
twilio_client = Client(os.environ.get('TWILIO_ACCOUNT_SID', None), os.environ.get('TWILIO_AUTH_TOKEN', None))

recognizer = RekognitionRecognizer(os.environ.get('FACIAL_RECOGNITION_ENDPOINT', None))
recognizer = RekognitionRecognizer()

failure_message = 'No member recognized, sorry'
confidence_levels = [
Expand Down Expand Up @@ -145,11 +145,13 @@ def recongize():
try:
# Makes POST request with image to app.py on port 8888
logging.info("Sending image to rekognition app...")

#r = requests.post(os.environ.get('FACIAL_RECOGNITION_ENDPOINT'], files={'file': f.getvalue()})
recognizer.recognize(target_image)

# Sends reply text based on content in Amazon Rekognition's response
resp = MessagingResponse()

#face_obj = json.loads(r.text)
#if ("CelebrityFaces" in face_obj and len(face_obj['CelebrityFaces']) > 0):
if len(target_image.recognized_faces) > 0:
Expand Down

0 comments on commit dffea10

Please sign in to comment.