Face encoding

Face encoding is the process of extracting facial features from a detected face. It outputs a face template to be used for face comparison or face search.

Encoding models

Model

Size

Description

FaceEncoder9A

127.36 MB

This model provides the best accuracy. It is recommended for 1-to-N applications or in an uncontrolled environment. Generated template size is 264 bytes.

FaceEncoder9B

1.99 MB

This model provides a good balance of accuracy, speed, and size. This model is less robust to variations of head pose than the 9A version and should therefore only be used in a controlled environment. Generated template size is 140 bytes.

FaceEncoder8A

152.46 MB

Obsolete. Provided for backward compatibility. Use model 9A whenever possible. Generated template size is 268 bytes.

FaceEncoder8B

2.12 MB

Obsolete. Provided for backward compatibility. Use model 9B whenever possible. Generated template size is 140 bytes.

Note

Call the FaceLibrary.loadModel Method to load the chosen model on application start.

Hint

On startup, call the FaceEncoder.warmUp Method to prepare inference of the AI model.

Face template

A face template is a small representation of a face, only 140 bytes or 264 bytes depending on the encoding model used. It is used for face comparison or face search.

A face template can be also exported to the format required by id3 Face Match-on-Card solution.

Encoding quality

The component also provides a quality estimator that aims at predicting the power of matching of a created template.

Important

This functionality requires the model FaceEncodingQualityEstimator_2A to be loaded.

Example

The example below demonstrates how to encode a face image and generate a FaceTemplate:

# initializes a FaceEncoder and warm it up.
face_encoder = FaceEncoder(
    thread_count=4
)

# warm up the face encoder
face_encoder.warm_up()

# create the template from the detected face.
face_template = face_encoder.create_template(image, face)

# dispose all resources
del face_encoder

See also