[PYTHON] Amazon Rekognition Filter function when registering faces ・ Limiting the number of faces

Amazon Rekognition Overview of filter function and face limit when registering faces

amareko.jpg

Amazon Rekognition IndexFaces API Maximum number of faces you want to register at the time of action, It is possible to eliminate faces that are not clear but blurry.

Target person

  1. I want to maintain quality with Amazon Rekognition
  2. I want to save money by eliminating low quality images

With the default settings, blurred images and face images that are mixed in with the background are also subject to registration, which reduces accuracy. Traditionally, Index Faces indexes up to 15 faces in the input image. The new version of the face detection model indexes up to 100 faces in the input image.

List of filters that can be used

MaxFaces You can set the maximum value of the face image you want to register As for the registered images, clear and clear images have the highest priority.

QualityFilter Filter to exclude poor quality images If you set the QualityFilter to automatic, Amazon will exclude poor quality images.

Filter system control method

Controllable level to filter "** AUTO " if you want the filter to be automatic on the Amazon side Judgment sweet filter " LOW " Intermediate filter " MEDIUM " Strict filter " HIGH " If you do not want to filter, specify " N ONE **"

Filter usage example

amareko_filter.py



import boto3

collection = "qrestia"
image_file = "TestImage.jpg "
external_image_id = "Qiita test ID"

def index_faces():
    rekognition_client = boto3.client('rekognition')
    with open(image_file, 'rb') as image:
        
        rekognition_response = rekognition_client.index_faces(
            Image={'Bytes': image.read()},
            CollectionId=collection,
            ExternalImageId=external_image_id,
            QualityFilter="AUTO", #Set Quality Filter to "Automatic"
            MaxFaces=3) #Increase the maximum number of face detection to 3
    print(rekognition_response)

if __name__ == '__main__':
    index_faces()

How to check the cause of the bounce

Information about faces found in the image but not indexed can be found in the array of UnindexedFace objects. From this response, you can understand the cause and make appropriate filter adjustments.

Recommended Posts

Amazon Rekognition Filter function when registering faces ・ Limiting the number of faces
10. Counting the number of lines
Get the number of digits
Calculate the number of changes
Filter the output of tracemalloc
Get the number of views of Qiita
Calculation of the number of Klamer correlations
Precautions when using the urllib.parse.quote function
Get the number of Youtube subscribers
[Python] Calculate the number of digits required when filling in 0s [Note]