Add Mask importing to the mask tool #1376
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)