Aligner

class tools.manual.manual.Aligner(tk_globals: TkGlobals)

Bases: object

The Aligner class sets up an extraction pipeline for each of the current Faceswap Aligners, along with the Landmarks based Maskers. When new landmarks are required, the bounding boxes from the GUI are passed to this class for pushing through the pipeline. The resulting Landmarks and Masks are then returned.

Parameters:

tk_globals (TkGlobals) – The tkinter variables that apply to the whole of the GUI

Attributes Summary

is_initialized

The Aligners are initialized in a background thread so that other tasks can be performed whilst we wait for initialization.

Methods Summary

get_landmarks(frame_index, face_index, aligner)

Feed the detected face into the alignment pipeline and retrieve the landmarks.

link_faces(detected_faces)

As the Aligner has the potential to take the longest to initialize, it is kicked off as early as possible.

set_normalization_method(method)

Change the normalization method for faces fed into the aligner.

Attributes Documentation

is_initialized

The Aligners are initialized in a background thread so that other tasks can be performed whilst we wait for initialization. True is returned if the aligner has completed initialization otherwise False.

Methods Documentation

get_landmarks(frame_index: int, face_index: int, aligner: Literal['FAN', 'HRNet', 'cv2-dnn']) ndarray

Feed the detected face into the alignment pipeline and retrieve the landmarks.

The face to feed into the aligner is generated from the given frame and face indices.

Parameters:
  • frame_index (int) – The frame index to extract the aligned face for

  • face_index (int) – The face index within the current frame to extract the face for

  • aligner (Literal['FAN', 'HRNet', 'cv2-dnn']) – The aligner to use to extract the face

Return type:

The 68 point landmark alignments

As the Aligner has the potential to take the longest to initialize, it is kicked off as early as possible. At this time DetectedFaces is not yet available.

Once the Aligner has initialized, this function is called to add the DetectedFaces class as a property of the Aligner.

Parameters:

detected_faces (DetectedFaces) – The class that holds the DetectedFace objects for the current Manual session

Return type:

None

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

Change the normalization method for faces fed into the aligner. The normalization method is user adjustable from the GUI. When this method is triggered the method is updated for all aligner pipelines.

Parameters:

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

Return type:

None

get_landmarks(frame_index: int, face_index: int, aligner: Literal['FAN', 'HRNet', 'cv2-dnn']) ndarray

Feed the detected face into the alignment pipeline and retrieve the landmarks.

The face to feed into the aligner is generated from the given frame and face indices.

Parameters:
  • frame_index (int) – The frame index to extract the aligned face for

  • face_index (int) – The face index within the current frame to extract the face for

  • aligner (Literal['FAN', 'HRNet', 'cv2-dnn']) – The aligner to use to extract the face

Return type:

The 68 point landmark alignments

property is_initialized: bool

The Aligners are initialized in a background thread so that other tasks can be performed whilst we wait for initialization. True is returned if the aligner has completed initialization otherwise False.

link_faces(detected_faces: DetectedFaces) None

As the Aligner has the potential to take the longest to initialize, it is kicked off as early as possible. At this time DetectedFaces is not yet available.

Once the Aligner has initialized, this function is called to add the DetectedFaces class as a property of the Aligner.

Parameters:

detected_faces (DetectedFaces) – The class that holds the DetectedFace objects for the current Manual session

Return type:

None

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

Change the normalization method for faces fed into the aligner. The normalization method is user adjustable from the GUI. When this method is triggered the method is updated for all aligner pipelines.

Parameters:

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

Return type:

None