Python Face ID API

oneML model for face verification and face identification.

oneML.faceAPI.FaceId : public object

The oneML FaceId API object.

Class to create and use oneML face id model.

Public Functions

__init__(self, *args)

Construct a FaceId object.

    args:

    - LicenseManager instance

    - FaceEmbedder instance (optional, to reuse an existing instance)
Parameters
  • args: Variable length argument list.

predict_batch(self, imgvec_, same_person_dist_threshold=- 1.0)

Predict images to registered ids.

Return

FaceIdResultVector: list of FaceIdResult objects

Parameters
  • imgvec_: images of a person as numpy array with shape (batch, height, width, channel)

  • same_person_dist_threshold: same person dist threshold, -1.0 means default threshould

predict(self, imgvec_, same_person_dist_threshold=- 1.0)

Predict an image to registered ids.

Return

FaceIdResult: result object

Parameters
  • imgvec_: image of a person as numpy array with shape (height, width, channel)

  • same_person_dist_threshold: same person dist threshold, -1.0 means default threshould

is_the_same_person_img(self, imgvec_, imgvec1_, same_person_dist_threshold=- 1.0)

Verify if 2 face images are the same.

Return

bool: true if 2 faces are from the same person, false otherwise

Parameters
  • imgvec_: image of first person as numpy array with shape (height, width, channel)

  • imgvec1_: image of second person as numpy array with shape (height, width, channel)

  • same_person_dist_threshold: same person dist threshold, -1.0 means default threshould

is_the_same_person_emb(self, vec_in_, imgvec_, same_person_dist_threshold=- 1.0)

Verify if a face images is the same as a face embedding.

Return

bool: true if same person, false otherwise

Return

numpy array: embedding vector of the image

Parameters
  • vec_in_: embedding of first person

  • imgvec_: image of second person as numpy array with shape (height, width, channel)

  • same_person_dist_threshold: same person dist threshold, -1.0 means default threshould

register_id_emb(self, id, vec_in_)

Register a new ID with embedding vectors.

If an ID exists, its embedding vectors will be replaced by new one and the classifier will be rebuilt.

Return

int: the embedding size

Parameters
  • id: string id

  • vec_in_: embedding array size EMB_SIZE

register_id_images(self, id, imgvec_, avg_emb)

Register a new ID with images.

If avg_emb is true, we will register with average embedding vector, else we will register embedding from first image.

Return

EmbeddingArray: list of embedding values

Parameters
  • id: string id

  • imgvec_: numpy array with shape (batch, height, width, channel)

  • avg_emb: boolean to average embedding images or not

register_id_image(self, id, imgvec_)

Register a new ID with an image.

Return

EmbeddingArray: list of embedding values

Parameters
  • id: string id

  • imgvec_: numpy array with shape (height, width, channel)

update_embedding_dynamically_img(self, id, imgvec_, vec_in_)

Dynamically update data inside a gallery_matrix classier by a face image and original embedding array.

Return

Parameters
  • id: string id

  • imgvec_: new image as numpy array with shape (height, width, channel)

  • vec_in_: original embedding as numpy array with shape (1, EMB_SIZE)

update_embedding_dynamically_emb(self, id, vec_in_, vec_in1_)

Dynamically update data inside a gallery_matrix classier by a probe embedding and original embedding array.

Return

Parameters
  • id: string id

  • vec_in_: new embedding as numpy array with shape (1, EMB_SIZE)

  • vec_in1_: original embedding as numpy array with shape (1, EMB_SIZE)

update_embedding(self, id, vec_in_)

Directly update an embedding vector inside a gallery_matrix classifier.

Return

Parameters
  • id: string id

  • vec_in_: embedding array as numpy array with shape (1, EMB_SIZE)

remove_id(self, id)

Remove id from gallery.

Return

Parameters
  • id: string id to ve removed

get_ids(self)

Get all ids in the gallery.

Return

StringVector: list of strings stored in the gallery

oneML.faceAPI.FaceIdResult : public object

The result object for oneML FaceId API.

Helper class to access all the results from
an API call.

Public Functions

get_id(self)

Get id.

Return

string: identified ID

get_nearest_node_distance(self)

Get nearest node distance.

Return

float: distance to nearest ID

get_combined_distance(self)

Get combined distance.

Return

float: combined distance to first two candidate IDs

is_identifiable(self)

Check if distance result is above the threshold for detecting unknown ID.

Return

bool: True if the result is valid or False for unknown ID

get_return_status(self)

Get return status.

Return

int: return status

oneML.faceAPI.FaceIdResultVector : public object
List of FaceIdResult objects.
oneML.faceAPI.FaceIdStatus_Empty = _oneMLfacePython.FaceIdStatus_Empty
oneML.faceAPI.FaceIdStatus_Success = _oneMLfacePython.FaceIdStatus_Success
oneML.faceAPI.FaceIdStatus_Fail = _oneMLfacePython.FaceIdStatus_Fail