Skip to content

Industry leading face manipulation platform

Add HyperSwap (no models yet)

henryruhsc390c6d88281
diff --git a/facefusion/processors/choices.py b/facefusion/processors/choices.py
index 3e1222f8..cafb439e 100755
--- a/facefusion/processors/choices.py
+++ b/facefusion/processors/choices.py
@@ -185,6 +185,7 @@ face_swapper_set : FaceSwapperSet =\
'ghost_2_256': [ '256x256', '512x512', '768x768', '1024x1024' ],
'ghost_3_256': [ '256x256', '512x512', '768x768', '1024x1024' ],
'hififace_unofficial_256': [ '256x256', '512x512', '768x768', '1024x1024' ],
+ 'hyperswap_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' ],
diff --git a/facefusion/processors/modules/face_swapper.py b/facefusion/processors/modules/face_swapper.py
index ed27cef3..2582f24a 100755
--- a/facefusion/processors/modules/face_swapper.py
+++ b/facefusion/processors/modules/face_swapper.py
@@ -193,6 +193,30 @@ def create_static_model_set(download_scope : DownloadScope) -> ModelSet:
'mean': [ 0.5, 0.5, 0.5 ],
'standard_deviation': [ 0.5, 0.5, 0.5 ]
},
+ 'hyperswap_256':
+ {
+ 'hashes':
+ {
+ 'face_swapper':
+ {
+ 'url': resolve_download_url('models-3.3.0', 'hyperswap_256.hash'),
+ 'path': resolve_relative_path('../.assets/models/hyperswap_256.hash')
+ }
+ },
+ 'sources':
+ {
+ 'face_swapper':
+ {
+ 'url': resolve_download_url('models-3.3.0', 'hyperswap_256.onnx'),
+ 'path': resolve_relative_path('../.assets/models/hyperswap_256.onnx')
+ }
+ },
+ 'type': 'hyperswap',
+ 'template': 'arcface_128',
+ 'size': (256, 256),
+ 'mean': [ 0.5, 0.5, 0.5 ],
+ 'standard_deviation': [ 0.5, 0.5, 0.5 ]
+ },
'inswapper_128':
{
'hashes':
@@ -516,6 +540,10 @@ def prepare_source_embedding(source_face : Face) -> Embedding:
source_embedding = source_embedding.reshape(1, -1)
return source_embedding
+ if model_type == 'hyperswap':
+ source_embedding = source_face.normed_embedding.reshape((1, -1))
+ return source_embedding
+
if model_type == 'inswapper':
model_path = get_model_options().get('sources').get('face_swapper').get('path')
model_initializer = get_static_model_initializer(model_path)
@@ -553,7 +581,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 in [ 'ghost', 'hififace', 'uniface' ]:
+ if model_type in [ 'ghost', 'hififace', 'hyperswap', '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
diff --git a/facefusion/processors/types.py b/facefusion/processors/types.py
index 5bfc132b..b9b01710 100644
--- a/facefusion/processors/types.py
+++ b/facefusion/processors/types.py
@@ -10,7 +10,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', 'hififace_unofficial_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', 'hyperswap_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_esrgan_x8', 'real_esrgan_x8_fp16', 'real_hatgan_x4', 'real_web_photo_x4', 'realistic_rescaler_x4', 'remacri_x4', 'siax_x4', 'span_kendata_x4', 'swin2_sr_x4', 'ultra_sharp_x4', 'ultra_sharp_2_x4']
LipSyncerModel = Literal['edtalk_256', 'wav2lip_96', 'wav2lip_gan_96']