* Fix round issues on CLI arguments with range

* Refresh face references on frame processor change

* Add cuda 12 support to installer

* Add cuda 12 support to installer

* Add cuda 12 support to installer

* Add cuda 12 support to installer

* Simplify check

* Simplify check
This commit is contained in:
Henry Ruhs 2023-12-24 15:55:21 +01:00 committed by GitHub
parent e18e84e4f8
commit b267629161
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 53 additions and 32 deletions

View File

@ -1,8 +1,7 @@
from typing import List from typing import List
import numpy
from facefusion.typing import FaceSelectorMode, FaceAnalyserOrder, FaceAnalyserAge, FaceAnalyserGender, FaceMaskType, FaceMaskRegion, TempFrameFormat, OutputVideoEncoder from facefusion.typing import FaceSelectorMode, FaceAnalyserOrder, FaceAnalyserAge, FaceAnalyserGender, FaceMaskType, FaceMaskRegion, TempFrameFormat, OutputVideoEncoder
from facefusion.common_helper import create_range
face_analyser_orders : List[FaceAnalyserOrder] = [ 'left-right', 'right-left', 'top-bottom', 'bottom-top', 'small-large', 'large-small', 'best-worst', 'worst-best' ] face_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' ] face_analyser_ages : List[FaceAnalyserAge] = [ 'child', 'teen', 'adult', 'senior' ]
@ -15,13 +14,13 @@ face_mask_regions : List[FaceMaskRegion] = [ 'skin', 'left-eyebrow', 'right-eyeb
temp_frame_formats : List[TempFrameFormat] = [ 'jpg', 'png' ] temp_frame_formats : List[TempFrameFormat] = [ 'jpg', 'png' ]
output_video_encoders : List[OutputVideoEncoder] = [ 'libx264', 'libx265', 'libvpx-vp9', 'h264_nvenc', 'hevc_nvenc' ] 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_thread_count_range : List[float] = create_range(1, 128, 1)
execution_queue_count_range : List[int] = numpy.arange(1, 33, 1).tolist() execution_queue_count_range : List[float] = create_range(1, 32, 1)
max_memory_range : List[int] = numpy.arange(0, 129, 1).tolist() max_memory_range : List[float] = create_range(0, 128, 1)
face_detector_score_range : List[float] = numpy.arange(0.0, 1.05, 0.05).tolist() face_detector_score_range : List[float] = create_range(0.0, 1.0, 0.05)
face_mask_blur_range : List[float] = numpy.arange(0.0, 1.05, 0.05).tolist() face_mask_blur_range : List[float] = create_range(0.0, 1.0, 0.05)
face_mask_padding_range : List[float] = numpy.arange(0, 101, 1).tolist() face_mask_padding_range : List[float] = create_range(0, 100, 1)
reference_face_distance_range : List[float] = numpy.arange(0.0, 1.55, 0.05).tolist() reference_face_distance_range : List[float] = create_range(0.0, 1.5, 0.05)
temp_frame_quality_range : List[int] = numpy.arange(0, 101, 1).tolist() temp_frame_quality_range : List[float] = create_range(0, 100, 1)
output_image_quality_range : List[int] = numpy.arange(0, 101, 1).tolist() output_image_quality_range : List[float] = create_range(0, 100, 1)
output_video_quality_range : List[int] = numpy.arange(0, 101, 1).tolist() output_video_quality_range : List[float] = create_range(0, 100, 1)

View File

@ -1,5 +0,0 @@
from typing import List, Any
def create_metavar(ranges : List[Any]) -> str:
return '[' + str(ranges[0]) + '-' + str(ranges[-1]) + ']'

View File

@ -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()

View File

@ -19,7 +19,7 @@ from facefusion.vision import get_video_frame, detect_fps, read_image, read_stat
from facefusion import face_analyser, face_masker, content_analyser, metadata, logger, wording from facefusion import face_analyser, face_masker, content_analyser, metadata, logger, wording
from facefusion.content_analyser import analyse_image, analyse_video from facefusion.content_analyser import analyse_image, analyse_video
from facefusion.processors.frame.core import get_frame_processors_modules, load_frame_processor_module from 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_metavar
from facefusion.execution_helper import encode_execution_providers, decode_execution_providers from facefusion.execution_helper import encode_execution_providers, decode_execution_providers
from facefusion.normalizer import normalize_output_path, normalize_padding from facefusion.normalizer import normalize_output_path, normalize_padding
from facefusion.filesystem import is_image, is_video, list_module_names, get_temp_frame_paths, create_temp, move_temp, clear_temp from facefusion.filesystem import is_image, is_video, list_module_names, get_temp_frame_paths, create_temp, move_temp, clear_temp

View File

@ -23,7 +23,9 @@ ONNXRUNTIMES : Dict[str, Tuple[str, str]] =\
} }
if platform.system().lower() == 'linux' or platform.system().lower() == 'windows': if platform.system().lower() == 'linux' or platform.system().lower() == 'windows':
TORCH['cuda'] = 'cu118' TORCH['cuda'] = 'cu118'
TORCH['cuda-nightly'] = 'cu121'
ONNXRUNTIMES['cuda'] = ('onnxruntime-gpu', '1.16.3') ONNXRUNTIMES['cuda'] = ('onnxruntime-gpu', '1.16.3')
ONNXRUNTIMES['cuda-nightly'] = ('ort-nightly-gpu', '1.17.0.dev20231205004')
ONNXRUNTIMES['openvino'] = ('onnxruntime-openvino', '1.16.0') ONNXRUNTIMES['openvino'] = ('onnxruntime-openvino', '1.16.0')
if platform.system().lower() == 'linux': if platform.system().lower() == 'linux':
TORCH['rocm'] = 'rocm5.6' TORCH['rocm'] = 'rocm5.6'
@ -66,19 +68,24 @@ def run(program : ArgumentParser) -> None:
torch_wheel = TORCH[torch] torch_wheel = TORCH[torch]
onnxruntime = answers['onnxruntime'] onnxruntime = answers['onnxruntime']
onnxruntime_name, onnxruntime_version = ONNXRUNTIMES[onnxruntime] onnxruntime_name, onnxruntime_version = ONNXRUNTIMES[onnxruntime]
subprocess.call([ 'pip', 'uninstall', 'torch', '-y', '-q' ]) subprocess.call([ 'pip', 'uninstall', 'torch', '-y', '-q' ])
if torch_wheel == 'default': if torch_wheel == 'default':
subprocess.call([ 'pip', 'install', '-r', 'requirements.txt' ]) subprocess.call([ 'pip', 'install', '-r', 'requirements.txt' ])
else: else:
subprocess.call([ 'pip', 'install', '-r', 'requirements.txt', '--extra-index-url', 'https://download.pytorch.org/whl/' + torch_wheel ]) 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', 'uninstall', 'onnxruntime', onnxruntime_name, '-y', '-q' ])
subprocess.call([ 'pip', 'install', onnxruntime_name + '==' + onnxruntime_version ]) if onnxruntime == 'cuda-nightly':
elif python_id in [ 'cp39', 'cp310', 'cp311' ]: subprocess.call([ 'pip', 'install', onnxruntime_name + '==' + onnxruntime_version, '--extra-index-url', 'https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ort-cuda-12-nightly/pypi/simple' ])
wheel_name = 'onnxruntime_training-' + onnxruntime_version + '+rocm56-' + python_id + '-' + python_id + '-manylinux_2_17_x86_64.manylinux2014_x86_64.whl' else:
wheel_path = os.path.join(tempfile.gettempdir(), wheel_name) subprocess.call([ 'pip', 'install', onnxruntime_name + '==' + onnxruntime_version ])
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)

View File

@ -2,7 +2,7 @@ METADATA =\
{ {
'name': 'FaceFusion', 'name': 'FaceFusion',
'description': 'Next generation face swapper and enhancer', 'description': 'Next generation face swapper and enhancer',
'version': '2.1.1', 'version': '2.1.2',
'license': 'MIT', 'license': 'MIT',
'author': 'Henry Ruhs', 'author': 'Henry Ruhs',
'url': 'https://facefusion.io' 'url': 'https://facefusion.io'

View File

@ -13,7 +13,7 @@ from facefusion.face_helper import warp_face, paste_back
from facefusion.content_analyser import clear_content_analyser from facefusion.content_analyser import clear_content_analyser
from facefusion.face_store import get_reference_faces from facefusion.face_store import get_reference_faces
from facefusion.typing import Face, FaceSet, Frame, Update_Process, ProcessMode, ModelSet, OptionsWithModel from facefusion.typing import Face, FaceSet, Frame, Update_Process, ProcessMode, ModelSet, OptionsWithModel
from facefusion.cli_helper import create_metavar from facefusion.common_helper import create_metavar
from facefusion.filesystem import is_file, is_image, is_video, resolve_relative_path from facefusion.filesystem import is_file, is_image, is_video, resolve_relative_path
from facefusion.download import conditional_download, is_download_done from facefusion.download import conditional_download, is_download_done
from facefusion.vision import read_image, read_static_image, write_image from facefusion.vision import read_image, read_static_image, write_image

View File

@ -11,7 +11,7 @@ from facefusion import logger, wording
from facefusion.face_analyser import clear_face_analyser from facefusion.face_analyser import clear_face_analyser
from facefusion.content_analyser import clear_content_analyser from facefusion.content_analyser import clear_content_analyser
from facefusion.typing import Face, FaceSet, Frame, Update_Process, ProcessMode, ModelSet, OptionsWithModel from facefusion.typing import Face, FaceSet, Frame, Update_Process, ProcessMode, ModelSet, OptionsWithModel
from facefusion.cli_helper import create_metavar from facefusion.common_helper import create_metavar
from facefusion.execution_helper import map_device from facefusion.execution_helper import map_device
from facefusion.filesystem import is_file, resolve_relative_path from facefusion.filesystem import is_file, resolve_relative_path
from facefusion.download import conditional_download, is_download_done from facefusion.download import conditional_download, is_download_done

View File

@ -93,7 +93,6 @@ def listen() -> None:
component.select(update_preview_image, inputs = PREVIEW_FRAME_SLIDER, outputs = PREVIEW_IMAGE) component.select(update_preview_image, inputs = PREVIEW_FRAME_SLIDER, outputs = PREVIEW_IMAGE)
change_one_component_names : List[ComponentName] =\ change_one_component_names : List[ComponentName] =\
[ [
'frame_processors_checkbox_group',
'face_debugger_items_checkbox_group', 'face_debugger_items_checkbox_group',
'face_enhancer_model_dropdown', 'face_enhancer_model_dropdown',
'face_enhancer_blend_slider', 'face_enhancer_blend_slider',
@ -115,6 +114,7 @@ def listen() -> None:
component.change(update_preview_image, inputs = PREVIEW_FRAME_SLIDER, outputs = PREVIEW_IMAGE) component.change(update_preview_image, inputs = PREVIEW_FRAME_SLIDER, outputs = PREVIEW_IMAGE)
change_two_component_names : List[ComponentName] =\ change_two_component_names : List[ComponentName] =\
[ [
'frame_processors_checkbox_group',
'face_swapper_model_dropdown', 'face_swapper_model_dropdown',
'face_detector_model_dropdown', 'face_detector_model_dropdown',
'face_detector_size_dropdown', 'face_detector_size_dropdown',

View File

@ -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 ]