iris.nodes.templates_filter package

Submodules

iris.nodes.templates_filter.single_identity_filter module

class iris.nodes.templates_filter.single_identity_filter.IdentityValidationAction(value)[source]

Bases: str, Enum

An enumeration.

LOG_WARNING = 'log_warning'
RAISE_ERROR = 'raise_error'
REMOVE = 'remove'
class iris.nodes.templates_filter.single_identity_filter.TemplateIdentityFilter(identity_distance_threshold: float = 0.35, identity_validation_action: IdentityValidationAction = IdentityValidationAction.REMOVE, min_templates_after_validation: int = 1, callbacks: List[Callback] = [])[source]

Bases: Algorithm

Node for filtering iris templates to ensure all templates are likely from the same identity. Uses pairwise Hamming distances to detect and remove (or flag) outlier templates. Can operate on precomputed distances (from alignment node) or compute them internally.

class Parameters(*, identity_distance_threshold: ConstrainedFloatValue = 0.35, identity_validation_action: IdentityValidationAction = IdentityValidationAction.REMOVE, min_templates_after_validation: ConstrainedIntValue = 1)[source]

Bases: Parameters

identity_distance_threshold: float
identity_validation_action: IdentityValidationAction
min_templates_after_validation: ConstrainedIntValue
run(aligned_templates: AlignedTemplates) List[IrisTemplate][source]

Filter templates to ensure all are from the same identity based on Hamming distances.

Parameters:
  • templates (List[IrisTemplate]) – List of iris templates to validate.

  • pairwise_distances (Dict[tuple, float], optional) – Precomputed pairwise Hamming distances. If not provided, will be computed.

Returns:

Filtered list of templates passing identity validation.

Return type:

List[IrisTemplate]

Raises:

E.IdentityValidationError – If validation fails and action is RAISE_ERROR or not enough templates remain.

iris.nodes.templates_filter.single_identity_filter.find_identity_clusters(distances: Dict[Tuple[int, int], float], nb_templates: int, threshold: float, min_cluster_size: int = 2) List[Set[int]][source]

Identifies clusters (potential identities) among templates based on pairwise distances.

Parameters:
  • distances (Dict[Tuple[int, int], float]) – Dictionary of pairwise distances between templates, keys are (i, j) tuples.

  • nb_templates (int) – Total number of templates (nodes).

  • threshold (float) – Maximum distance to consider two templates as belonging to the same identity (edge in the graph).

  • min_cluster_size (int) – Minimum number of templates required to consider a group a cluster (default: 2).

Returns:

List of clusters, each cluster is a set of template indices. Only clusters with size >= min_cluster_size are returned.

Return type:

List[Set[int]]

iris.nodes.templates_filter.single_identity_filter.greedy_purification(distances: Dict[Tuple[int, int], float], threshold: float, nb_templates: int, min_templates: int = 1) List[int][source]

Iteratively remove the template with the highest mean distance to others until all pairwise distances are within threshold or until min_templates remain.

Parameters:
  • distances (Dict[Tuple[int, int], float]) – dict of (i, j): distance

  • threshold (float) – distance threshold

  • nb_templates (int) – number of templates

  • min_templates (int) – minimum templates to retain. Default is 1.

Returns:

indices of outlier templates to remove

Return type:

List[int]

Module contents