LandmarksMask
- class lib.align.aligned_mask.LandmarksMask(area: T.Literal['eye', 'mouth', 'face', 'face_extended'], landmark_type: LandmarkType, landmarks: npt.NDArray[np.float32], size: int, dilation: float = 0.0, blur_kernel: int = 0, blur_type: T.Literal['gaussian', 'normalized'] | None = 'gaussian', blur_passes: int = 1)
Bases:
objectCreate a single channel mask from aligned landmark points.
Landmarks masks are created on the fly, so the stored centering and size should be the same as the aligned face that the mask will be applied to. As the masks are created on the fly, blur + dilation is applied to the mask at creation (prior to compression) rather than after decompression when requested.
Note
Threshold is not used for Landmarks mask as the mask is binary
- Parameters:
area (T.Literal['eye', 'mouth', 'face', 'face_extended']) – The type of mask to obtain. face is a full face mask, face_extended is a face mask that extends above the eyebrows. The others are masks for those specific areas
landmark_type (LandmarkType) – The type of landmarks that this mask is being created from
landmarks (npt.NDArray[np.float32]) – The landmarks to generate the mask from
size (int) – The size (in pixels) that the compressed mask should be
dilation (float) – The amount of dilation to apply to the mask. as a percentage of the mask size. Default: 0.0
blur_kernel (int) – The kernel size, in pixels to apply gaussian blurring to the mask. Set to 0 for no blurring. Should be odd, if an even number is passed in (outside of 0) then it is rounded up to the next odd number. Default: 0
blur_type (T.Literal['gaussian', 'normalized'] | None) – The blur type to use.
gaussianornormalizedbox filter. Default:gaussianblur_passes (int) – The number of passed to perform when blurring. Default: 1
Methods Summary
Generate the mask.
Methods Documentation
- generate_mask() npt.NDArray[np.uint8]
Generate the mask.
Creates the mask applying any requested dilation and blurring
- Return type:
The landmarks based mask
- blur_kernel
The kernel size, in pixels to apply gaussian blurring to the mask. Set to 0 for no blurring. Should be odd, if an even number is passed in (outside of 0) then it is rounded up to the next odd number. Default: 0
- blur_passes
1
- Type:
The number of passed to perform when blurring. Default
- blur_type: T.Literal['gaussian', 'normalized'] | None
The blur type to use.
gaussian,normalizedbox filter orNonefor no blur. Default:gaussian
- dilation
The amount of dilation to apply to the mask. as a percentage of the mask size. Default: 0.0
- generate_mask() npt.NDArray[np.uint8]
Generate the mask.
Creates the mask applying any requested dilation and blurring
- Return type:
The landmarks based mask
- mask
The mask at the size of
sizewith any requested blurring, threshold amount and centering applied.