FrameFaces

class lib.infer.objects.FrameFaces(filename: str, image: npt.NDArray[np.uint8], bboxes: npt.NDArray[np.int32] | None = None, landmarks: npt.NDArray[np.float32] | None = None, identities: dict[str, npt.NDArray[np.float32]] | None = None, masks: dict[str, ExtractBatchMask] | None = None, source: str | None = None, is_aligned: bool = False, frame_metadata: PNGSource | None = None, passthrough: bool = False)

Bases: object

An object for holding information about faces in a single frame

Parameters:
  • filename (str) – The original file name of the frame

  • image (npt.NDArray[np.uint8]) – The original frame or a faceswap aligned face image

  • bboxes (npt.NDArray[np.int32] | None) – The (N, Left, Top, Right, Bottom) bounding boxes of the faces in the frame. Default: None (Not provided)

  • landmarks (npt.NDArray[np.float32] | None) – The (N, M, 2) landmarks for each face in the frame, in frame space. Default: None (Not provided)

  • identities (dict[str, npt.NDArray[np.float32]] | None) – The identity matrices for each face in the frame. Default: None (Not provided)

  • masks (dict[str, ExtractBatchMask] | None) – The mask objects for each face in the frame. Default: None (Not provided)

  • source (str | None) – The full path to the source folder or video file. Default: None (Not provided)

  • is_aligned (bool) – True if the image is an aligned faceswap image otherwise False. Used for face filtering with vggface2. Aligned faceswap images will automatically skip detection, alignment and masking. Default: False

  • frame_metadata (PNGSource | None) – The frame metadata for aligned images. None if the image is not an aligned image

  • passthrough (bool) – True if this item is meant to be passed straight through the extraction pipeline with no batching or caching. for immediate return. Default: False

Attributes Summary

detected_faces

A list of DetectedFace objects within the image

image_size

The (height, width) of the stored image

landmarks

The (N, M, 2) landmarks for each face in the frame, in frame space

Methods Summary

append(batch)

Append the data from the given batch object to this batch object

remove_image()

Delete the image and reset image to None.

Attributes Documentation

detected_faces

A list of DetectedFace objects within the image

image_size

The (height, width) of the stored image

landmarks

The (N, M, 2) landmarks for each face in the frame, in frame space

Methods Documentation

append(batch: FrameFaces) None

Append the data from the given batch object to this batch object

Parameters:

batch (FrameFaces) – The object containing data to be appended to this object

Return type:

None

remove_image() None

Delete the image and reset image to None.

Return type:

None

aligned

Holds the face landmarks found for this batch any any aligned data

append(batch: FrameFaces) None

Append the data from the given batch object to this batch object

Parameters:

batch (FrameFaces) – The object containing data to be appended to this object

Return type:

None

bboxes

The (N, Left, Top, Right, Bottom) bounding boxes of the faces in the frame

property detected_faces: list[DetectedFace]

A list of DetectedFace objects within the image

filename

The original file name of the original frame

frame_metadata: PNGSource | None

The frame metadata that has been added from an aligned image. None if metadata has not been added

identities

The identity matrices for each face in the frame

image

The original frame or a faceswap aligned face image

image_shape

The shape of the original frame

property image_size: tuple[int, int]

The (height, width) of the stored image

is_aligned

True if image is an aligned faceswap image otherwise False

property landmarks: ndarray[tuple[Any, ...], dtype[float32]] | None

The (N, M, 2) landmarks for each face in the frame, in frame space

masks

The mask objects for each face in the frame

passthrough

True if the contents of this item are meant to pass straight through the extraction pipeline for immediate return

remove_image() None

Delete the image and reset image to None.

Return type:

None

source

The full path to the source folder or video file or None if not provided