FacesLoader
- class lib.image.FacesLoader(path, skip_list=None, count=None)
Bases:
ImagesLoaderLoads 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
The number of images or video frames in the source location.
A full list of files in the source location.
Trueif the input is a video,Falseif it is notThe folder or video that was passed in as the
pathparameter.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)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
ImagesLoaderclose()Closes down and joins the internal threads
load()Generator for loading images from the given
locationAttributes 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_listhas been provided. See alsoprocess_count
- file_list
A full list of files in the source location. This includes any files that will ultimately be skipped if a
skip_listhas been provided. If the input is a video then this is a list of dummy filenames as corresponding to an alignments file
- is_video
Trueif the input is a video,Falseif it is not
- location
The folder or video that was passed in as the
pathparameter.- 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
locationIf
FacesLoaderis 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. (
FacesLoaderonly)
- Return type:
T.Generator[tuple[str, npt.NDArray[np.uint8]] | tuple[str, npt.NDArray[np.uint8], PNGHeader], None, None]