SortMethod

class tools.sort.sort_methods.SortMethod(arguments: Namespace, loader_type: T.Literal['face', 'meta', 'all'] = 'meta', is_group: bool = False)

Bases: object

Parent class for sort methods. All sort methods should inherit from this class

Parameters:
  • arguments (Namespace) – The command line arguments passed to the sort process

  • loader_type (T.Literal['face', 'meta', 'all']) – The type of image loader to use. “face” just loads the image with the filename, “meta” just loads the image alignment data with the filename. “all” loads the image and the alignment data with the filename

  • is_group (bool) – Set to True if this class is going to be called exclusively for binning. Default: False

Attributes Summary

bin_names

The name of each created bin, if they exist, otherwise an empty list

binned

List of bins (list) containing the filenames belonging to the bin.

loader_type

The loader that this sorter uses

sorted_filelist

List of sorted filenames for given sorter in a single list.

Methods Summary

binning()

Group into bins by their sorted score.

score_image(filename, image, alignments)

Override for sort method's specific logic.

sort()

Override for method specific logic for sorting the loaded statistics.

Attributes Documentation

bin_names

The name of each created bin, if they exist, otherwise an empty list

binned

List of bins (list) containing the filenames belonging to the bin. The binning process is called when this property is first accessed

loader_type

The loader that this sorter uses

Type:

[“face”, “meta”, “all”]

sorted_filelist

List of sorted filenames for given sorter in a single list. The sort process is called when this property is first accessed

Methods Documentation

binning() list[list[str]]

Group into bins by their sorted score. Override for method specific binning techniques.

Binning takes the results from _result compiled during _sort_filelist() and organizes into bins for output.

Returns:

List of bins of filenames

Return type:

list

score_image(filename: str, image: np.ndarray | None, alignments: PNGAlignments | None) None

Override for sort method’s specific logic. This method should be executed to get a single score from a single image and add the result to _result

Parameters:
  • filename (str) – The filename of the currently processing image

  • image (np.ndarray | None) – A face image loaded from disk or None

  • alignments (PNGAlignments | None) – The alignments dictionary for the aligned face or None

Return type:

None

sort() None

Override for method specific logic for sorting the loaded statistics.

The scored list _result should be sorted in place

Return type:

None

property bin_names: list[str]

The name of each created bin, if they exist, otherwise an empty list

property binned: list[list[str]]

List of bins (list) containing the filenames belonging to the bin. The binning process is called when this property is first accessed

binning() list[list[str]]

Group into bins by their sorted score. Override for method specific binning techniques.

Binning takes the results from _result compiled during _sort_filelist() and organizes into bins for output.

Returns:

List of bins of filenames

Return type:

list

property loader_type: Literal['face', 'meta', 'all']

The loader that this sorter uses

Type:

[“face”, “meta”, “all”]

score_image(filename: str, image: np.ndarray | None, alignments: PNGAlignments | None) None

Override for sort method’s specific logic. This method should be executed to get a single score from a single image and add the result to _result

Parameters:
  • filename (str) – The filename of the currently processing image

  • image (np.ndarray | None) – A face image loaded from disk or None

  • alignments (PNGAlignments | None) – The alignments dictionary for the aligned face or None

Return type:

None

sort() None

Override for method specific logic for sorting the loaded statistics.

The scored list _result should be sorted in place

Return type:

None

property sorted_filelist: list[str]

List of sorted filenames for given sorter in a single list. The sort process is called when this property is first accessed