Identity

class lib.infer.identity.Identity(plugin: str, threshold: float = 0.4, compile_model: bool = False, config_file: str | None = None)

Bases: ExtractHandlerFace

Responsible for handling Identity/Recognition plugins within the extract pipeline

Parameters:
  • plugin (str) – The plugin that this runner is to use

  • filter_threshold – The threshold to use when filtering faces by identity. Default: 0.4

  • compile_model (bool) – True to compile any PyTorch models

  • config_file (str | None) – Full path to a custom config file to load. None for default config

  • threshold (float)

Attributes Summary

batch_size

The batch size of the plugin

processors

The processors which should have thread's launched for this handler

runner

The runner that runs this handler

Methods Summary

__call__([input_plugin, profile])

Build and start the plugin handler's runner

add_filter_identities(identities, is_filter)

Add the given identities to the identity filter

init_model()

Load the model, compile it, if requested, and send a warmup batch through.

output_info()

Output the counts from the identity filter

post_process(batch)

Perform recognition post processing.

pre_process(batch)

Obtain the aligned face images at the requested size, centering and image format.

process(batch)

Perform inference to get results from the plugin for the given batch.

Attributes Documentation

batch_size

The batch size of the plugin

processors = ('pre_process', 'process', 'post_process')

The processors which should have thread’s launched for this handler

runner

The runner that runs this handler

Methods Documentation

__call__(input_plugin: ExtractHandler | ExtractRunner | None = None, profile: bool = False) ExtractRunner

Build and start the plugin handler’s runner

Parameters:
  • input_plugin (ExtractHandler | ExtractRunner | None) – The input plugin handler or it’s runner that feeds this handler. None if data is to be fed through the handler runner’s put method (ie, the first handler in an extraction chain). Default: None

  • profile (bool) – True if the runner is to be profiled, indicating that threads will not be started. Default: False

Return type:

The extract plugin handler’s runner for this handler

add_filter_identities(identities: npt.NDArray[np.float32], is_filter: bool) None

Add the given identities to the identity filter

Parameters:
  • identities (npt.NDArray[np.float32]) – The identity embeddings to add to the filter

  • is_filter (bool) – True for filter, False for nFilter

Return type:

None

init_model() None

Load the model, compile it, if requested, and send a warmup batch through. Called either from the main thread, if compiling, or from the inference thread if not.

Return type:

None

output_info() None

Output the counts from the identity filter

Return type:

None

post_process(batch: ExtractBatch) None

Perform recognition post processing.

Obtains the final output from the identity plugin and performs any plugin specific post- processing

Parameters:

batch (ExtractBatch) – The incoming ExtractBatch to use for post-processing

Return type:

None

pre_process(batch: ExtractBatch) None

Obtain the aligned face images at the requested size, centering and image format. Perform any plugin specific pre-processing

Parameters:

batch (ExtractBatch) – The incoming ExtractBatch to use for pre-processing

Return type:

None

process(batch: ExtractBatch) None

Perform inference to get results from the plugin for the given batch. Override for plugin type specific processing

Parameters:

batch (ExtractBatch) – The incoming ExtractBatch to use for processing

Return type:

None

add_filter_identities(identities: npt.NDArray[np.float32], is_filter: bool) None

Add the given identities to the identity filter

Parameters:
  • identities (npt.NDArray[np.float32]) – The identity embeddings to add to the filter

  • is_filter (bool) – True for filter, False for nFilter

Return type:

None

output_info() None

Output the counts from the identity filter

Return type:

None

post_process(batch: ExtractBatch) None

Perform recognition post processing.

Obtains the final output from the identity plugin and performs any plugin specific post- processing

Parameters:

batch (ExtractBatch) – The incoming ExtractBatch to use for post-processing

Return type:

None

pre_process(batch: ExtractBatch) None

Obtain the aligned face images at the requested size, centering and image format. Perform any plugin specific pre-processing

Parameters:

batch (ExtractBatch) – The incoming ExtractBatch to use for pre-processing

Return type:

None