Industry leading face manipulation platform
2.1.2 (#271)
Henry Ruhsb26762916135
diff --git a/facefusion/choices.py b/facefusion/choices.pyindex 135586cc..9808aa51 100755--- a/facefusion/choices.py+++ b/facefusion/choices.py@@ -1,8 +1,7 @@from typing import List-import numpy-from facefusion.typing import FaceSelectorMode, FaceAnalyserOrder, FaceAnalyserAge, FaceAnalyserGender, FaceMaskType, FaceMaskRegion, TempFrameFormat, OutputVideoEncoder+from facefusion.common_helper import create_rangeface_analyser_orders : List[FaceAnalyserOrder] = [ 'left-right', 'right-left', 'top-bottom', 'bottom-top', 'small-large', 'large-small', 'best-worst', 'worst-best' ]face_analyser_ages : List[FaceAnalyserAge] = [ 'child', 'teen', 'adult', 'senior' ]@@ -15,13 +14,13 @@ face_mask_regions : List[FaceMaskRegion] = [ 'skin', 'left-eyebrow', 'right-eyebtemp_frame_formats : List[TempFrameFormat] = [ 'jpg', 'png' ]output_video_encoders : List[OutputVideoEncoder] = [ 'libx264', 'libx265', 'libvpx-vp9', 'h264_nvenc', 'hevc_nvenc' ]-execution_thread_count_range : List[int] = numpy.arange(1, 129, 1).tolist()-execution_queue_count_range : List[int] = numpy.arange(1, 33, 1).tolist()-max_memory_range : List[int] = numpy.arange(0, 129, 1).tolist()-face_detector_score_range : List[float] = numpy.arange(0.0, 1.05, 0.05).tolist()-face_mask_blur_range : List[float] = numpy.arange(0.0, 1.05, 0.05).tolist()-face_mask_padding_range : List[float] = numpy.arange(0, 101, 1).tolist()-reference_face_distance_range : List[float] = numpy.arange(0.0, 1.55, 0.05).tolist()-temp_frame_quality_range : List[int] = numpy.arange(0, 101, 1).tolist()-output_image_quality_range : List[int] = numpy.arange(0, 101, 1).tolist()-output_video_quality_range : List[int] = numpy.arange(0, 101, 1).tolist()+execution_thread_count_range : List[float] = create_range(1, 128, 1)+execution_queue_count_range : List[float] = create_range(1, 32, 1)+max_memory_range : List[float] = create_range(0, 128, 1)+face_detector_score_range : List[float] = create_range(0.0, 1.0, 0.05)+face_mask_blur_range : List[float] = create_range(0.0, 1.0, 0.05)+face_mask_padding_range : List[float] = create_range(0, 100, 1)+reference_face_distance_range : List[float] = create_range(0.0, 1.5, 0.05)+temp_frame_quality_range : List[float] = create_range(0, 100, 1)+output_image_quality_range : List[float] = create_range(0, 100, 1)+output_video_quality_range : List[float] = create_range(0, 100, 1)diff --git a/facefusion/cli_helper.py b/facefusion/cli_helper.pydeleted file mode 100644index 84aa847d..00000000--- a/facefusion/cli_helper.py+++ /dev/null@@ -1,5 +0,0 @@-from typing import List, Any---def create_metavar(ranges : List[Any]) -> str:- return '[' + str(ranges[0]) + '-' + str(ranges[-1]) + ']'diff --git a/facefusion/common_helper.py b/facefusion/common_helper.pynew file mode 100644index 00000000..8ddcad8d--- /dev/null+++ b/facefusion/common_helper.py@@ -0,0 +1,10 @@+from typing import List, Any+import numpy+++def create_metavar(ranges : List[Any]) -> str:+ return '[' + str(ranges[0]) + '-' + str(ranges[-1]) + ']'+++def create_range(start : float, stop : float, step : float) -> List[float]:+ return (numpy.around(numpy.arange(start, stop + step, step), decimals = 2)).tolist()diff --git a/facefusion/core.py b/facefusion/core.pyindex ad9941d2..3009124b 100755--- a/facefusion/core.py+++ b/facefusion/core.py@@ -19,7 +19,7 @@ from facefusion.vision import get_video_frame, detect_fps, read_image, read_statfrom facefusion import face_analyser, face_masker, content_analyser, metadata, logger, wordingfrom facefusion.content_analyser import analyse_image, analyse_videofrom facefusion.processors.frame.core import get_frame_processors_modules, load_frame_processor_module-from facefusion.cli_helper import create_metavar+from facefusion.common_helper import create_metavarfrom facefusion.execution_helper import encode_execution_providers, decode_execution_providersfrom facefusion.normalizer import normalize_output_path, normalize_paddingfrom facefusion.filesystem import is_image, is_video, list_module_names, get_temp_frame_paths, create_temp, move_temp, clear_tempdiff --git a/facefusion/installer.py b/facefusion/installer.pyindex 290ef4ee..8b6f7fe0 100644--- a/facefusion/installer.py+++ b/facefusion/installer.py@@ -23,7 +23,9 @@ ONNXRUNTIMES : Dict[str, Tuple[str, str]] =\}if platform.system().lower() == 'linux' or platform.system().lower() == 'windows':TORCH['cuda'] = 'cu118'+ TORCH['cuda-nightly'] = 'cu121'ONNXRUNTIMES['cuda'] = ('onnxruntime-gpu', '1.16.3')+ ONNXRUNTIMES['cuda-nightly'] = ('ort-nightly-gpu', '1.17.0.dev20231205004')ONNXRUNTIMES['openvino'] = ('onnxruntime-openvino', '1.16.0')if platform.system().lower() == 'linux':TORCH['rocm'] = 'rocm5.6'@@ -66,19 +68,24 @@ def run(program : ArgumentParser) -> None:torch_wheel = TORCH[torch]onnxruntime = answers['onnxruntime']onnxruntime_name, onnxruntime_version = ONNXRUNTIMES[onnxruntime]+subprocess.call([ 'pip', 'uninstall', 'torch', '-y', '-q' ])if torch_wheel == 'default':subprocess.call([ 'pip', 'install', '-r', 'requirements.txt' ])else:subprocess.call([ 'pip', 'install', '-r', 'requirements.txt', '--extra-index-url', 'https://download.pytorch.org/whl/' + torch_wheel ])- if onnxruntime != 'rocm':+ if onnxruntime == 'rocm':+ if python_id in [ 'cp39', 'cp310', 'cp311' ]:+ wheel_name = 'onnxruntime_training-' + onnxruntime_version + '+rocm56-' + python_id + '-' + python_id + '-manylinux_2_17_x86_64.manylinux2014_x86_64.whl'+ wheel_path = os.path.join(tempfile.gettempdir(), wheel_name)+ wheel_url = 'https://download.onnxruntime.ai/' + wheel_name+ subprocess.call([ 'curl', '--silent', '--location', '--continue-at', '-', '--output', wheel_path, wheel_url ])+ subprocess.call([ 'pip', 'uninstall', wheel_path, '-y', '-q' ])+ subprocess.call([ 'pip', 'install', wheel_path ])+ os.remove(wheel_path)+ else:subprocess.call([ 'pip', 'uninstall', 'onnxruntime', onnxruntime_name, '-y', '-q' ])- subprocess.call([ 'pip', 'install', onnxruntime_name + '==' + onnxruntime_version ])- elif python_id in [ 'cp39', 'cp310', 'cp311' ]:- wheel_name = 'onnxruntime_training-' + onnxruntime_version + '+rocm56-' + python_id + '-' + python_id + '-manylinux_2_17_x86_64.manylinux2014_x86_64.whl'- wheel_path = os.path.join(tempfile.gettempdir(), wheel_name)- wheel_url = 'https://download.onnxruntime.ai/' + wheel_name- subprocess.call([ 'curl', '--silent', '--location', '--continue-at', '-', '--output', wheel_path, wheel_url ])- subprocess.call([ 'pip', 'uninstall', wheel_path, '-y', '-q' ])- subprocess.call([ 'pip', 'install', wheel_path ])- os.remove(wheel_path)+ if onnxruntime == 'cuda-nightly':+ subprocess.call([ 'pip', 'install', onnxruntime_name + '==' + onnxruntime_version, '--extra-index-url', 'https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ort-cuda-12-nightly/pypi/simple' ])+ else:+ subprocess.call([ 'pip', 'install', onnxruntime_name + '==' + onnxruntime_version ])diff --git a/facefusion/metadata.py b/facefusion/metadata.pyindex e04365e5..98751890 100644--- a/facefusion/metadata.py+++ b/facefusion/metadata.py@@ -2,7 +2,7 @@ METADATA =\{'name': 'FaceFusion','description': 'Next generation face swapper and enhancer',- 'version': '2.1.1',+ 'version': '2.1.2','license': 'MIT','author': 'Henry Ruhs','url': 'https://facefusion.io'diff --git a/facefusion/processors/frame/modules/face_enhancer.py b/facefusion/processors/frame/modules/face_enhancer.pyindex 7c4b57ae..f9997b3e 100755--- a/facefusion/processors/frame/modules/face_enhancer.py+++ b/facefusion/processors/frame/modules/face_enhancer.py@@ -13,7 +13,7 @@ from facefusion.face_helper import warp_face, paste_backfrom facefusion.content_analyser import clear_content_analyserfrom facefusion.face_store import get_reference_facesfrom facefusion.typing import Face, FaceSet, Frame, Update_Process, ProcessMode, ModelSet, OptionsWithModel-from facefusion.cli_helper import create_metavar+from facefusion.common_helper import create_metavarfrom facefusion.filesystem import is_file, is_image, is_video, resolve_relative_pathfrom facefusion.download import conditional_download, is_download_donefrom facefusion.vision import read_image, read_static_image, write_imagediff --git a/facefusion/processors/frame/modules/frame_enhancer.py b/facefusion/processors/frame/modules/frame_enhancer.pyindex 1b82d703..4e5cca57 100644--- a/facefusion/processors/frame/modules/frame_enhancer.py+++ b/facefusion/processors/frame/modules/frame_enhancer.py@@ -11,7 +11,7 @@ from facefusion import logger, wordingfrom facefusion.face_analyser import clear_face_analyserfrom facefusion.content_analyser import clear_content_analyserfrom facefusion.typing import Face, FaceSet, Frame, Update_Process, ProcessMode, ModelSet, OptionsWithModel-from facefusion.cli_helper import create_metavar+from facefusion.common_helper import create_metavarfrom facefusion.execution_helper import map_devicefrom facefusion.filesystem import is_file, resolve_relative_pathfrom facefusion.download import conditional_download, is_download_donediff --git a/facefusion/uis/components/preview.py b/facefusion/uis/components/preview.pyindex 75affe6d..66588745 100755--- a/facefusion/uis/components/preview.py+++ b/facefusion/uis/components/preview.py@@ -93,7 +93,6 @@ def listen() -> None:component.select(update_preview_image, inputs = PREVIEW_FRAME_SLIDER, outputs = PREVIEW_IMAGE)change_one_component_names : List[ComponentName] =\[- 'frame_processors_checkbox_group','face_debugger_items_checkbox_group','face_enhancer_model_dropdown','face_enhancer_blend_slider',@@ -115,6 +114,7 @@ def listen() -> None:component.change(update_preview_image, inputs = PREVIEW_FRAME_SLIDER, outputs = PREVIEW_IMAGE)change_two_component_names : List[ComponentName] =\[+ 'frame_processors_checkbox_group','face_swapper_model_dropdown','face_detector_model_dropdown','face_detector_size_dropdown',diff --git a/tests/test_common_helper.py b/tests/test_common_helper.pynew file mode 100644index 00000000..40ef7f32--- /dev/null+++ b/tests/test_common_helper.py@@ -0,0 +1,10 @@+from facefusion.common_helper import create_metavar, create_range+++def test_create_metavar() -> None:+ assert create_metavar([ 1, 2, 3, 4, 5 ]) == '[1-5]'+++def test_create_range() -> None:+ assert create_range(0.0, 1.0, 0.5) == [ 0.0, 0.5, 1.0 ]+ assert create_range(0.0, 0.2, 0.05) == [ 0.0, 0.05, 0.10, 0.15, 0.20 ]