1 to 1 Face Recognition

SDK.get_face_feature_vector(*args, **kwargs)

Overloaded function.

  1. get_face_feature_vector(self: tfsdk.SDK, aligned_face_image: tfsdk.TFFacechip) -> Tuple[tfsdk.ERRORCODE, tfsdk.Faceprint]

    Extract the feature vector (Faceprint) for the given aligned face image.

    Parameters:

    tf_facechip - The tfsdk.TFFacechip representing the aligned face chip. Face chip must have size of 112x112 pixels, therefore use the default margin and scale parameters when calling tfsdk.SDK.extract_aligned_face().

    Returns:
  2. get_face_feature_vector(self: tfsdk.SDK, face_box_and_landmarks: tfsdk.TFImage, tf_image: tfsdk.FaceBoxAndLandmarks) -> Tuple[tfsdk.ERRORCODE, tfsdk.Faceprint]

    Extract the face feature vector (Faceprint) from the face box.

    Parameters:
    Returns:
SDK.get_face_feature_vectors(self: tfsdk.SDK, aligned_face_images: List[tfsdk.TFFacechip]) Tuple[tfsdk.ERRORCODE, List[tfsdk.Faceprint]]

Extract the face feature vectors (Faceprints) from the aligned face images. This batch processing method increases throughput when using GPU inference.

Parameters:

tf_facechips - A list of tfsdk.TFFacechips.

Returns:
SDK.get_largest_face_feature_vector(self: tfsdk.SDK, tf_image: tfsdk.TFImage) Tuple[tfsdk.ERRORCODE, tfsdk.Faceprint, bool]

Detect the largest face in the image by area and return the corresponding feature vector (Faceprint).

Parameters:

tf_image - The input tfsdk.TFImage, returned by tfsdk.SDK.preprocess_image().

Returns:
static SDK.faceprint_to_json(faceprint: tfsdk.Faceprint) str

Convert a tfsdk.Faceprint into a json string.

Parameters:

faceprint - The tfsdk.Faceprint to convert to a string.

Returns:

str - The string representation of the tfsdk.Faceprint.

static SDK.json_to_faceprint(json_string: str) Tuple[tfsdk.ERRORCODE, tfsdk.Faceprint]

Create a tfsdk.Faceprint from a json string.

Parameters:

json_string - The json string representation of a tfsdk.Faceprint, generated from the tfsdk.SDK.json_to_faceprint() function.

Returns:

tfsdk.Faceprint - The tfsdk.Faceprint generated from the json string.

SDK.get_similarity(self: tfsdk.SDK, feature_vector_1: tfsdk.Faceprint, feature_vector_2: tfsdk.Faceprint) Tuple[tfsdk.ERRORCODE, float, float]

Compute the similarity between two feature vectors, or how similar two faces are. Note, while the match probability may be more intuitive to understand, match thresholding should be performed on the similarity score. To understand the difference between these two metrics, refer to our FAQ page. Refer to the ROC curves when selecting a threshold.

Parameters:

feature_vector_1 - The first Faceprint to be compared. feature_vector_2 - The second Faceprint to be compared.

Returns:
  • tfsdk.ERRORCODE - The error code.

  • float - The match probability.

  • float - The similarity score. The match probability is the probability that the two faces feature vectors are a match, while the similarity is the computed similarity score.

class tfsdk.Faceprint
compare(self: tfsdk.Faceprint, fp: tfsdk.Faceprint) Tuple[tfsdk.ERRORCODE, float, float]

Compare the similarity between two tfsdk.Faceprint. The same as tfsdk.SDK.get_similarity().

Parameters:

fp - The tfsdk.Faceprint to compare against.

Returns:
  • tfsdk.ERRORCODE - The error code.

  • float - The match probability.

  • float - The similarity score.

property feature_vector

Vector of floats which describe the face.

get_quantized_vector(self: tfsdk.Faceprint) numpy.ndarray[numpy.int16]

Return the feature vector as a list of 16-bit integers. This is useful for when the tfsdk.ModelOptions.fr_vector_compression option is enabled and you require an integer representation of the quantized feature vector.

Returns:

numpy.ndarray[numpy.int16] - A 16-bit numpy array representation of the tfsdk.Faceprint.feature_vector.

property model_name

Name of model used to generate feature vector.

property model_options

Additional options used for generating the feature vector.

property sdk_version

SDK version used to generate feature vector.

set_quantized_vector(self: tfsdk.Faceprint, quantized_feature_vector: numpy.ndarray[numpy.int16]) None

Populate the tfsdk.Faceprint.feature_vector from a quantized 16-bit numpy array generated by tfsdk.Faceprint.get_quanitzed_vector()

Parameters:

quantized_feature_vector - The 16-bit numpy array feature vector.

class tfsdk.ModelOptions
property fr_vector_compression

Indicates if the tfsdk.ConfigurationOptions.fr_vector_compression option was enabled when generating the feature vector.