Introduce hififace swapper
This commit is contained in:
parent
ce3dac7718
commit
0e4f69ce56
@ -40,6 +40,14 @@ WARP_TEMPLATES : WarpTemplateSet =\
|
||||
[ 0.50123859, 0.61331904 ],
|
||||
[ 0.39308822, 0.72541100 ],
|
||||
[ 0.61150205, 0.72490465 ]
|
||||
]),
|
||||
'mtcnn_512': numpy.array(
|
||||
[
|
||||
[ 0.36562865, 0.46733799 ],
|
||||
[ 0.63305391, 0.46585885 ],
|
||||
[ 0.50019127, 0.61942959 ],
|
||||
[ 0.39032951, 0.77598822 ],
|
||||
[ 0.61178945, 0.77476328 ]
|
||||
])
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ face_swapper_set : FaceSwapperSet =\
|
||||
'ghost_1_256': [ '256x256', '512x512', '768x768', '1024x1024' ],
|
||||
'ghost_2_256': [ '256x256', '512x512', '768x768', '1024x1024' ],
|
||||
'ghost_3_256': [ '256x256', '512x512', '768x768', '1024x1024' ],
|
||||
'hififace_unofficial_256': [ '256x256', '512x512', '768x768', '1024x1024' ],
|
||||
'inswapper_128': [ '128x128', '256x256', '384x384', '512x512', '768x768', '1024x1024' ],
|
||||
'inswapper_128_fp16': [ '128x128', '256x256', '384x384', '512x512', '768x768', '1024x1024' ],
|
||||
'simswap_256': [ '256x256', '512x512', '768x768', '1024x1024' ],
|
||||
|
@ -153,6 +153,40 @@ MODEL_SET : ModelSet =\
|
||||
'mean': [ 0.5, 0.5, 0.5 ],
|
||||
'standard_deviation': [ 0.5, 0.5, 0.5 ]
|
||||
},
|
||||
'hififace_unofficial_256':
|
||||
{
|
||||
'hashes':
|
||||
{
|
||||
'face_swapper':
|
||||
{
|
||||
'url': 'https://github.com/facefusion/facefusion-assets/releases/download/models-3.1.0/hififace_unofficial_256.hash',
|
||||
'path': resolve_relative_path('../.assets/models/hififace_unofficial_256.hash')
|
||||
},
|
||||
'embedding_converter':
|
||||
{
|
||||
'url': 'https://github.com/facefusion/facefusion-assets/releases/download/models-3.1.0/arcface_converter_hififace.hash',
|
||||
'path': resolve_relative_path('../.assets/models/arcface_converter_hififace.hash')
|
||||
}
|
||||
},
|
||||
'sources':
|
||||
{
|
||||
'face_swapper':
|
||||
{
|
||||
'url': 'https://github.com/facefusion/facefusion-assets/releases/download/models-3.1.0/hififace_unofficial_256.onnx',
|
||||
'path': resolve_relative_path('../.assets/models/hififace_unofficial_256.onnx')
|
||||
},
|
||||
'embedding_converter':
|
||||
{
|
||||
'url': 'https://github.com/facefusion/facefusion-assets/releases/download/models-3.1.0/arcface_converter_hififace.onnx',
|
||||
'path': resolve_relative_path('../.assets/models/arcface_converter_hififace.onnx')
|
||||
}
|
||||
},
|
||||
'type': 'hififace',
|
||||
'template': 'mtcnn_512',
|
||||
'size': (256, 256),
|
||||
'mean': [ 0.5, 0.5, 0.5 ],
|
||||
'standard_deviation': [ 0.5, 0.5, 0.5 ]
|
||||
},
|
||||
'inswapper_128':
|
||||
{
|
||||
'hashes':
|
||||
@ -412,7 +446,7 @@ def forward_swap_face(source_face : Face, crop_vision_frame : VisionFrame) -> Vi
|
||||
|
||||
for face_swapper_input in face_swapper.get_inputs():
|
||||
if face_swapper_input.name == 'source':
|
||||
if model_type == 'blendswap' or model_type == 'uniface':
|
||||
if model_type in [ 'blendswap', 'uniface' ]:
|
||||
face_swapper_inputs[face_swapper_input.name] = prepare_source_frame(source_face)
|
||||
else:
|
||||
face_swapper_inputs[face_swapper_input.name] = prepare_source_embedding(source_face)
|
||||
@ -493,7 +527,7 @@ def normalize_crop_frame(crop_vision_frame : VisionFrame) -> VisionFrame:
|
||||
model_standard_deviation = get_model_options().get('standard_deviation')
|
||||
|
||||
crop_vision_frame = crop_vision_frame.transpose(1, 2, 0)
|
||||
if model_type == 'ghost' or model_type == 'uniface':
|
||||
if model_type in [ 'ghost', 'hififace', 'uniface' ]:
|
||||
crop_vision_frame = crop_vision_frame * model_standard_deviation + model_mean
|
||||
crop_vision_frame = crop_vision_frame.clip(0, 1)
|
||||
crop_vision_frame = crop_vision_frame[:, :, ::-1] * 255
|
||||
|
@ -9,7 +9,7 @@ ExpressionRestorerModel = Literal['live_portrait']
|
||||
FaceDebuggerItem = Literal['bounding-box', 'face-landmark-5', 'face-landmark-5/68', 'face-landmark-68', 'face-landmark-68/5', 'face-mask', 'face-detector-score', 'face-landmarker-score', 'age', 'gender', 'race']
|
||||
FaceEditorModel = Literal['live_portrait']
|
||||
FaceEnhancerModel = Literal['codeformer', 'gfpgan_1.2', 'gfpgan_1.3', 'gfpgan_1.4', 'gpen_bfr_256', 'gpen_bfr_512', 'gpen_bfr_1024', 'gpen_bfr_2048', 'restoreformer_plus_plus']
|
||||
FaceSwapperModel = Literal['blendswap_256', 'ghost_1_256', 'ghost_2_256', 'ghost_3_256', 'inswapper_128', 'inswapper_128_fp16', 'simswap_256', 'simswap_unofficial_512', 'uniface_256']
|
||||
FaceSwapperModel = Literal['blendswap_256', 'ghost_1_256', 'ghost_2_256', 'ghost_3_256', 'hififace_unofficial_256', 'inswapper_128', 'inswapper_128_fp16', 'simswap_256', 'simswap_unofficial_512', 'uniface_256']
|
||||
FrameColorizerModel = Literal['ddcolor', 'ddcolor_artistic', 'deoldify', 'deoldify_artistic', 'deoldify_stable']
|
||||
FrameEnhancerModel = Literal['clear_reality_x4', 'lsdir_x4', 'nomos8k_sc_x4', 'real_esrgan_x2', 'real_esrgan_x2_fp16', 'real_esrgan_x4', 'real_esrgan_x4_fp16', 'real_hatgan_x4', 'real_esrgan_x8', 'real_esrgan_x8_fp16', 'span_kendata_x4', 'ultra_sharp_x4']
|
||||
LipSyncerModel = Literal['wav2lip_96', 'wav2lip_gan_96']
|
||||
|
@ -84,7 +84,7 @@ ProcessStep = Callable[[str, int, Args], bool]
|
||||
|
||||
Content = Dict[str, Any]
|
||||
|
||||
WarpTemplate = Literal['arcface_112_v1', 'arcface_112_v2', 'arcface_128_v2', 'ffhq_512']
|
||||
WarpTemplate = Literal['arcface_112_v1', 'arcface_112_v2', 'arcface_128_v2', 'ffhq_512', 'mtcnn_512']
|
||||
WarpTemplateSet = Dict[WarpTemplate, NDArray[Any]]
|
||||
ProcessMode = Literal['output', 'preview', 'stream']
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user