mediapipe_model_maker.face_stylizer.FaceStylizer

FaceStylizer for building face stylization model.

model_spec Specification for the model.
model_options Model options for creating face stylizer.
hparams The hyperparameters for training face stylizer.

w_avg An average face latent code to regularize face generation in face stylization.

Methods

create

View source

Creates and trains a face stylizer with input datasets.

Args
train_data The input style image dataset for training the face stylizer.
options The options to configure face stylizer.

Returns
A FaceStylizer instant with the trained model.

export_model

View source

Converts the model to TFLite and exports as a model bundle file.

Saves a model bundle file and metadata json file to hparams.export_dir. The resulting model bundle file will contain necessary models for face detection, face landmarks detection, and customized face stylization. Only the model bundle file is needed for the downstream face stylization task. The metadata.json file is saved only to interpret the contents of the model bundle file. The face detection model and face landmarks detection model are from https://storage.googleapis.com/mediapipe-assets/face_landmarker_v2.task and the customized face stylization model is trained in this library.

Args
model_name Face stylizer model bundle file name. The full export path is {self._hparams.export_dir}/{model_name}.

stylize

View source

Stylizes the images represented by the input dataset.

Args
data Dataset of input images, can contain multiple images.

Returns
A dataset contains the stylized images