Shellbrady/LivePortrait112w
0
1# coding: utf-82 3"""4config dataclass used for inference5"""6 7import os.path as osp8import cv29from numpy import ndarray10from dataclasses import dataclass11from typing import Literal, Tuple12from .base_config import PrintableConfig, make_abs_path13 14 15@dataclass(repr=False) # use repr from PrintableConfig16class InferenceConfig(PrintableConfig):17 models_config: str = make_abs_path('./models.yaml') # portrait animation config18 checkpoint_F: str = make_abs_path('../../pretrained_weights/liveportrait/base_models/appearance_feature_extractor.pth') # path to checkpoint19 checkpoint_M: str = make_abs_path('../../pretrained_weights/liveportrait/base_models/motion_extractor.pth') # path to checkpoint20 checkpoint_G: str = make_abs_path('../../pretrained_weights/liveportrait/base_models/spade_generator.pth') # path to checkpoint21 checkpoint_W: str = make_abs_path('../../pretrained_weights/liveportrait/base_models/warping_module.pth') # path to checkpoint22 23 checkpoint_S: str = make_abs_path('../../pretrained_weights/liveportrait/retargeting_models/stitching_retargeting_module.pth') # path to checkpoint24 flag_use_half_precision: bool = True # whether to use half precision25 26 flag_lip_zero: bool = True # whether let the lip to close state before animation, only take effect when flag_eye_retargeting and flag_lip_retargeting is False27 lip_zero_threshold: float = 0.0328 29 flag_eye_retargeting: bool = False30 flag_lip_retargeting: bool = False31 flag_stitching: bool = True # we recommend setting it to True!32 33 flag_relative: bool = True # whether to use relative motion34 anchor_frame: int = 0 # set this value if find_best_frame is True35 36 input_shape: Tuple[int, int] = (256, 256) # input shape37 output_format: Literal['mp4', 'gif'] = 'mp4' # output video format38 output_fps: int = 30 # fps for output video39 crf: int = 15 # crf for output video40 41 flag_write_result: bool = True # whether to write output video42 flag_pasteback: bool = True # whether to paste-back/stitch the animated face cropping from the face-cropping space to the original image space43 mask_crop: ndarray = cv2.imread(make_abs_path('../utils/resources/mask_template.png'), cv2.IMREAD_COLOR)44 flag_write_gif: bool = False45 size_gif: int = 25646 ref_max_shape: int = 128047 ref_shape_n: int = 248 49 device_id: int = 050 flag_do_crop: bool = False # whether to crop the source portrait to the face-cropping space51 flag_do_rot: bool = True # whether to conduct the rotation when flag_do_crop is True52 