This PR adds the ability to import masks into faceswap alignment files/PNG Headers for extracted faces.
Masks can be imported/exported as either the stored 'face-aligned' mask, or as a full-frame mask for the entire frame/image
Export masks
Masks can be exported from faceswap for editing in external tools. They will be output as either aligned face masks, or as full frame masks, depending on what type of input (frames or faces) that you feed the mask tool, and which works best for your workflow.
Set input to either the frames you wish to export masks from or to the extracted faces folder
Set the input-type to correspond with whether you are passing frames in, or a folder of faces
The exported masks will correspond directly to the selected input-type
Select the mask type (masker) that you wish to export
Set processing to output
Set the output-folder to the destination to export the masks to
Exported masks will be placed in the output folder as single channel (grayscale) images, and will be named correctly for importing (after editing)
Import masks
Masks can be imported, after editing/creation in external tools. Masks can be created in most image formats, but will ultimately be stored internally as single-channel 8-bit grayscale images.
Note: batch-mode is not supported for mask import
Set input to either the frames you wish to import masks for or to the extracted faces folder
Optionally specify an alignments file location
recommended if the input-type is faces, to ensure that your imported masks also get updated to your alignments file
Set the input-type to correspond with whether you are passing frames in, or a folder of faces
The masks that you are importing must be of the same type as the source input. IE: If you have selected the input type as frames the masks that you are importing must also be annotated for the full frame
Select the masker as custom
This is a security step to make sure that you do not accidentally overwrite any other mask types that you may have annotated
Imported masks will always be stored as the custom mask type
Set processing to import
Set mask-path to the folder that contains the masks you wish to import
If your input/source is a folder of images (be it frames or faces) then the filename of the masks must be exactly the same as the filenames within your source folder (excluding the file extension)
If your input is a video file, then the masks can be named anything you please, but the filename must end with the frame number (excluding the file extension)
Frame numbering must start at 1 (that is, the first frame in any video file must be 1 and not 0)
The frame number can be separated from the rest of the filename by any non-numeric character (or the filename can just be the frame number, with no other text)
The frame number can be padded with any number of zeros
Set the centering that you wish to store the masks at. Unless you are masking for full-head swaps, then face will always be the correct choice here
Set the storage-size that you wish faceswap to store the masks at. Generally, masks do not need to be stored at a very high resolution. By default this is 128px, which works fine for most use cases. You can store custom masks at a higher resolution, but this will lead to larger filesizes, and may lead to longer processing times (when training or converting)
This PR adds the ability to import masks into faceswap alignment files/PNG Headers for extracted faces.
Masks can be imported/exported as either the stored 'face-aligned' mask, or as a full-frame mask for the entire frame/image
Export masks
Masks can be exported from faceswap for editing in external tools. They will be output as either aligned face masks, or as full frame masks, depending on what type of input (frames or faces) that you feed the mask tool, and which works best for your workflow.
input
to either the frames you wish to export masks from or to the extracted faces folderinput-type
to correspond with whether you are passing frames in, or a folder of facesinput-type
masker
) that you wish to exportprocessing
tooutput
output-folder
to the destination to export the masks toExported masks will be placed in the output folder as single channel (grayscale) images, and will be named correctly for importing (after editing)
Import masks
Masks can be imported, after editing/creation in external tools. Masks can be created in most image formats, but will ultimately be stored internally as single-channel 8-bit grayscale images.
Note:
batch-mode
is not supported for mask importinput
to either the frames you wish to import masks for or to the extracted faces folderinput-type
is faces, to ensure that your imported masks also get updated to your alignments fileinput-type
to correspond with whether you are passing frames in, or a folder of facesframes
the masks that you are importing must also be annotated for the full framemasker
ascustom
custom
mask typeprocessing
toimport
mask-path
to the folder that contains the masks you wish to import1
and not0
)centering
that you wish to store the masks at. Unless you are masking for full-head swaps, thenface
will always be the correct choice herestorage-size
that you wish faceswap to store the masks at. Generally, masks do not need to be stored at a very high resolution. By default this is 128px, which works fine for most use cases. You can store custom masks at a higher resolution, but this will lead to larger filesizes, and may lead to longer processing times (when training or converting)