FacesLoader

class lib.image.FacesLoader(path, skip_list=None, count=None)

Bases: ImagesLoader

Loads faces from a faces folder along with the face’s Faceswap metadata.

Examples

Loading faces with their Faceswap metadata:

>>> loader = FacesLoader('/path/to/faces/folder')
>>> for filename, face, metadata in loader.load():
>>>     <do processing>

Attributes Summary

count

The number of images or video frames in the source location.

file_list

A full list of files in the source location.

is_video

True if the input is a video, False if it is not

location

The folder or video that was passed in as the path parameter.

process_count

The number of images or video frames to be processed (IE the total count less items that are to be skipped from the skip_list)

processed_file_list

A list of files in the source location with any files that will be skipped removed

Methods Summary

add_skip_list(skip_list)

Add a skip list to this ImagesLoader

close()

Closes down and joins the internal threads

load()

Generator for loading images from the given location

Attributes Documentation

count

The number of images or video frames in the source location. This count includes any files that will ultimately be skipped if a skip_list has been provided. See also process_count

file_list

A full list of files in the source location. This includes any files that will ultimately be skipped if a skip_list has been provided. If the input is a video then this is a list of dummy filenames as corresponding to an alignments file

is_video

True if the input is a video, False if it is not

location

The folder or video that was passed in as the path parameter.

Type:

str

process_count

The number of images or video frames to be processed (IE the total count less items that are to be skipped from the skip_list)

processed_file_list

A list of files in the source location with any files that will be skipped removed

Methods Documentation

add_skip_list(skip_list: list[int]) None

Add a skip list to this ImagesLoader

Parameters:

skip_list (list[int]) – A list of indices corresponding to the frame indices that should be skipped by the load() function.

Return type:

None

close()

Closes down and joins the internal threads

load() T.Generator[tuple[str, npt.NDArray[np.uint8]] | tuple[str, npt.NDArray[np.uint8], PNGHeader], None, None]

Generator for loading images from the given location

If FacesLoader is in use then the Faceswap metadata of the image stored in the image exif file is added as the final item in the output tuple.

Yields:
  • filename – The filename of the loaded image.

  • image – The loaded image.

  • metadata – The Faceswap metadata associated with the loaded image. (FacesLoader only)

Return type:

T.Generator[tuple[str, npt.NDArray[np.uint8]] | tuple[str, npt.NDArray[np.uint8], PNGHeader], None, None]