If you saw this exception in response to a call, search_faces_by_imageit probably means that there were no detectable faces in the image you provided. You can view a list of possible exceptions in the API_SearchFacesByImage .
To handle this exception, you can write code like this:
import boto3
rek = boto3.client('rekognition')
def lookup_faces(image, collection_id):
try:
faces = rek.search_faces_by_image(
CollectionId=collection_id,
Image=image,
FaceMatchThreshold=95
)
logger.info('faces detected: {}'.format(faces))
return faces
except rek.exceptions.InvalidParameterException as e:
logger.debug('no faces detected')
return None
source
share