Align

class lib.infer.align.Align(plugin: str, re_feeds: int = 0, re_align: bool = False, normalization: Literal['none', 'clahe', 'hist', 'mean'] | None = None, filters: bool = False, compile_model: bool = False, config_file: str | None = None)

Bases: ExtractHandler

Responsible for handling align plugins within the extract pipeline

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

  • re_feeds (int) – Number of times to jitter detection bounding box and average the result. Default: 0

  • re_align (bool) – True to re-align faces based on their first-pass results. Default: False

  • normalization (T.Literal['none', 'clahe', 'hist', 'mean'] | None) – The normalization to perform on aligner input images. Default: None (no normalization)

  • filters (bool) – True to enable aligner filters to filter out faces. Default: False

  • 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

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

init_model()

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

output_info()

Output the counts from the aligner filter

post_process(batch)

Post-process the landmark predictions from the model: average any re-feeds, scale back to original frame dimensions, apply any filters

pre_process(batch)

Obtain the adjusted square ROIs from the plugin based off the provided detection bounding boxes.

process(batch)

Perform inference to get results from the aligner

set_normalize_method(method)

Update the normalization method with the given method

Attributes Documentation

batch_size

The batch size of the plugin

processors: tuple[Literal['pre_process', 'process', 'post_process'], ...] = ('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

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 aligner filter

Return type:

None

post_process(batch: ExtractBatch) None

Post-process the landmark predictions from the model: average any re-feeds, scale back to original frame dimensions, apply any filters

Parameters:

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

Return type:

None

pre_process(batch: ExtractBatch) None

Obtain the adjusted square ROIs from the plugin based off the provided detection bounding boxes. Crop and size the input face images ready for inference from these ROIs

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 aligner

Parameters:

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

Return type:

None

set_normalize_method(method: Literal['none', 'clahe', 'hist', 'mean'] | None) None

Update the normalization method with the given method

Parameters:

method (Literal['none', 'clahe', 'hist', 'mean'] | None) – The normalization method to use

Return type:

None

output_info() None

Output the counts from the aligner filter

Return type:

None

post_process(batch: ExtractBatch) None

Post-process the landmark predictions from the model: average any re-feeds, scale back to original frame dimensions, apply any filters

Parameters:

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

Return type:

None

pre_process(batch: ExtractBatch) None

Obtain the adjusted square ROIs from the plugin based off the provided detection bounding boxes. Crop and size the input face images ready for inference from these ROIs

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 aligner

Parameters:

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

Return type:

None

set_normalize_method(method: Literal['none', 'clahe', 'hist', 'mean'] | None) None

Update the normalization method with the given method

Parameters:

method (Literal['none', 'clahe', 'hist', 'mean'] | None) – The normalization method to use

Return type:

None