Frames
- class tools.alignments.media.Frames(folder: str, count: int | None = None)
Bases:
MediaLoaderObject to hold the frames that are to be checked against
Attributes Summary
Number of faces or frames
Whether source is a video or not
Methods Summary
Ensure that the frames or faces folder exists and is valid.
load_image(filename)Load an image
Load the frame info into dictionary
load_video_frame(filename)Load a requested frame from video
Iterate through the frames folder pulling the base filename
Process exported Frames
Dummy in frames for video
save_image(output_folder, filename, image[, ...])Save an image
Return the items sorted by filename
stream([skip_list])Load the images in
folderin the order they are received fromlib.image.ImagesLoaderin a background thread.valid_extension(filename)Check whether passed in file has a valid extension
Attributes Documentation
- Parameters:
folder (str)
count (int | None)
- count
Number of faces or frames
- is_video
Whether source is a video or not
Methods Documentation
- check_input_folder() VideoCapture | None
Ensure that the frames or faces folder exists and is valid. If frames folder contains a video file return cv2 reader object
- Return type:
Object for reading a video stream
- load_image(filename: str) np.ndarray
Load an image
- Parameters:
filename (str) – The filename of the image to load
- Return type:
The loaded image
- load_items() dict[str, tuple[str, str]]
Load the frame info into dictionary
- Return type:
Fullname as key, tuple of frame name and extension as value
- load_video_frame(filename: str) np.ndarray
Load a requested frame from video
- Parameters:
filename (str) – The frame name to load
- Return type:
The loaded image
- process_folder() Generator[dict[str, str], None, None]
Iterate through the frames folder pulling the base filename
- Yields:
The full frame name, the filename and the file extension of the frame
- Return type:
Generator[dict[str, str], None, None]
- process_frames() Generator[dict[str, str], None, None]
Process exported Frames
- Yields:
The full frame name, the filename and the file extension of the frame
- Return type:
Generator[dict[str, str], None, None]
- process_video() Generator[dict[str, str], None, None]
Dummy in frames for video
- Yields:
The full frame name, the filename and the file extension of the frame
- Return type:
Generator[dict[str, str], None, None]
- static save_image(output_folder: str, filename: str, image: np.ndarray, metadata: PNGHeader | None = None) None
Save an image
- Parameters:
filename (str) – The filename of the image to save
image (np.ndarray) – The image to save
metadata (PNGHeader | None) – Any faceswap metadata that should be saved
output_folder (str)
- Return type:
None
- sorted_items() list[dict[str, str]]
Return the items sorted by filename
- Return type:
The sorted list of frame information
- stream(skip_list: list[int] | None = None) Generator[tuple[str, np.ndarray], None, None]
Load the images in
folderin the order they are received fromlib.image.ImagesLoaderin a background thread.- Parameters:
skip_list (list[int] | None) – A list of frame indices that should not be loaded. Pass
Noneif all images should be loaded. Default:None- Yields:
filename – The filename of the image that is being returned
image – The image that has been loaded from disk
- Return type:
Generator[tuple[str, np.ndarray], None, None]
- static valid_extension(filename) bool
Check whether passed in file has a valid extension
- Return type:
bool
- load_items() dict[str, tuple[str, str]]
Load the frame info into dictionary
- Return type:
Fullname as key, tuple of frame name and extension as value
- process_folder() Generator[dict[str, str], None, None]
Iterate through the frames folder pulling the base filename
- Yields:
The full frame name, the filename and the file extension of the frame
- Return type:
Generator[dict[str, str], None, None]
- process_frames() Generator[dict[str, str], None, None]
Process exported Frames
- Yields:
The full frame name, the filename and the file extension of the frame
- Return type:
Generator[dict[str, str], None, None]
- process_video() Generator[dict[str, str], None, None]
Dummy in frames for video
- Yields:
The full frame name, the filename and the file extension of the frame
- Return type:
Generator[dict[str, str], None, None]
- sorted_items() list[dict[str, str]]
Return the items sorted by filename
- Return type:
The sorted list of frame information