mirror of
https://github.com/facefusion/facefusion.git
synced 2026-08-29 12:00:38 +02:00
merge master into v4 - post adjustments
This commit is contained in:
+12
-21
@@ -1,29 +1,20 @@
|
|||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
|
from functools import lru_cache
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from facefusion import state_manager
|
from facefusion import state_manager
|
||||||
from facefusion.common_helper import cast_bool, cast_float, cast_int
|
from facefusion.common_helper import cast_bool, cast_float, cast_int
|
||||||
|
|
||||||
CONFIG_PARSER = None
|
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
def get_config_parser() -> ConfigParser:
|
def get_static_config_parser() -> ConfigParser:
|
||||||
global CONFIG_PARSER
|
config_parser = ConfigParser()
|
||||||
|
config_parser.read(state_manager.get_item('config_path'), encoding = 'utf-8')
|
||||||
if CONFIG_PARSER is None:
|
return config_parser
|
||||||
CONFIG_PARSER = ConfigParser()
|
|
||||||
CONFIG_PARSER.read(state_manager.get_item('config_path'), encoding = 'utf-8')
|
|
||||||
return CONFIG_PARSER
|
|
||||||
|
|
||||||
|
|
||||||
def clear_config_parser() -> None:
|
|
||||||
global CONFIG_PARSER
|
|
||||||
|
|
||||||
CONFIG_PARSER = None
|
|
||||||
|
|
||||||
|
|
||||||
def get_str_value(section : str, option : str, fallback : Optional[str] = None) -> Optional[str]:
|
def get_str_value(section : str, option : str, fallback : Optional[str] = None) -> Optional[str]:
|
||||||
config_parser = get_config_parser()
|
config_parser = get_static_config_parser()
|
||||||
|
|
||||||
if config_parser.has_option(section, option) and config_parser.get(section, option).strip():
|
if config_parser.has_option(section, option) and config_parser.get(section, option).strip():
|
||||||
return config_parser.get(section, option)
|
return config_parser.get(section, option)
|
||||||
@@ -31,7 +22,7 @@ def get_str_value(section : str, option : str, fallback : Optional[str] = None)
|
|||||||
|
|
||||||
|
|
||||||
def get_int_value(section : str, option : str, fallback : Optional[str] = None) -> Optional[int]:
|
def get_int_value(section : str, option : str, fallback : Optional[str] = None) -> Optional[int]:
|
||||||
config_parser = get_config_parser()
|
config_parser = get_static_config_parser()
|
||||||
|
|
||||||
if config_parser.has_option(section, option) and config_parser.get(section, option).strip():
|
if config_parser.has_option(section, option) and config_parser.get(section, option).strip():
|
||||||
return config_parser.getint(section, option)
|
return config_parser.getint(section, option)
|
||||||
@@ -39,7 +30,7 @@ def get_int_value(section : str, option : str, fallback : Optional[str] = None)
|
|||||||
|
|
||||||
|
|
||||||
def get_float_value(section : str, option : str, fallback : Optional[str] = None) -> Optional[float]:
|
def get_float_value(section : str, option : str, fallback : Optional[str] = None) -> Optional[float]:
|
||||||
config_parser = get_config_parser()
|
config_parser = get_static_config_parser()
|
||||||
|
|
||||||
if config_parser.has_option(section, option) and config_parser.get(section, option).strip():
|
if config_parser.has_option(section, option) and config_parser.get(section, option).strip():
|
||||||
return config_parser.getfloat(section, option)
|
return config_parser.getfloat(section, option)
|
||||||
@@ -47,7 +38,7 @@ def get_float_value(section : str, option : str, fallback : Optional[str] = None
|
|||||||
|
|
||||||
|
|
||||||
def get_bool_value(section : str, option : str, fallback : Optional[str] = None) -> Optional[bool]:
|
def get_bool_value(section : str, option : str, fallback : Optional[str] = None) -> Optional[bool]:
|
||||||
config_parser = get_config_parser()
|
config_parser = get_static_config_parser()
|
||||||
|
|
||||||
if config_parser.has_option(section, option) and config_parser.get(section, option).strip():
|
if config_parser.has_option(section, option) and config_parser.get(section, option).strip():
|
||||||
return config_parser.getboolean(section, option)
|
return config_parser.getboolean(section, option)
|
||||||
@@ -55,7 +46,7 @@ def get_bool_value(section : str, option : str, fallback : Optional[str] = None)
|
|||||||
|
|
||||||
|
|
||||||
def get_str_list(section : str, option : str, fallback : Optional[str] = None) -> Optional[List[str]]:
|
def get_str_list(section : str, option : str, fallback : Optional[str] = None) -> Optional[List[str]]:
|
||||||
config_parser = get_config_parser()
|
config_parser = get_static_config_parser()
|
||||||
|
|
||||||
if config_parser.has_option(section, option) and config_parser.get(section, option).strip():
|
if config_parser.has_option(section, option) and config_parser.get(section, option).strip():
|
||||||
return config_parser.get(section, option).split()
|
return config_parser.get(section, option).split()
|
||||||
@@ -65,7 +56,7 @@ def get_str_list(section : str, option : str, fallback : Optional[str] = None) -
|
|||||||
|
|
||||||
|
|
||||||
def get_int_list(section : str, option : str, fallback : Optional[str] = None) -> Optional[List[int]]:
|
def get_int_list(section : str, option : str, fallback : Optional[str] = None) -> Optional[List[int]]:
|
||||||
config_parser = get_config_parser()
|
config_parser = get_static_config_parser()
|
||||||
|
|
||||||
if config_parser.has_option(section, option) and config_parser.get(section, option).strip():
|
if config_parser.has_option(section, option) and config_parser.get(section, option).strip():
|
||||||
return list(map(int, config_parser.get(section, option).split()))
|
return list(map(int, config_parser.get(section, option).split()))
|
||||||
|
|||||||
@@ -19,16 +19,16 @@ LOCALES =\
|
|||||||
}
|
}
|
||||||
ONNXRUNTIME_SET =\
|
ONNXRUNTIME_SET =\
|
||||||
{
|
{
|
||||||
'default': ('onnxruntime', '1.24.4')
|
'default': ('onnxruntime', '1.26.0')
|
||||||
}
|
}
|
||||||
if is_windows() or is_linux():
|
if is_windows() or is_linux():
|
||||||
ONNXRUNTIME_SET['cuda'] = ('onnxruntime-gpu', '1.24.4')
|
ONNXRUNTIME_SET['cuda'] = ('onnxruntime-gpu', '1.26.0')
|
||||||
ONNXRUNTIME_SET['openvino'] = ('onnxruntime-openvino', '1.24.1')
|
ONNXRUNTIME_SET['openvino'] = ('onnxruntime-openvino', '1.24.1')
|
||||||
if is_windows():
|
if is_windows():
|
||||||
ONNXRUNTIME_SET['directml'] = ('onnxruntime-directml', '1.24.4')
|
ONNXRUNTIME_SET['directml'] = ('onnxruntime-directml', '1.24.4')
|
||||||
ONNXRUNTIME_SET['qnn'] = ('onnxruntime-qnn', '1.24.4')
|
ONNXRUNTIME_SET['qnn'] = ('onnxruntime-qnn', '1.24.4')
|
||||||
if is_linux():
|
if is_linux():
|
||||||
ONNXRUNTIME_SET['migraphx'] = ('onnxruntime-migraphx', '1.24.2')
|
ONNXRUNTIME_SET['migraphx'] = ('onnxruntime-migraphx', '1.25.0')
|
||||||
ONNXRUNTIME_SET['rocm'] = ('onnxruntime-rocm', '1.22.2.post1')
|
ONNXRUNTIME_SET['rocm'] = ('onnxruntime-rocm', '1.22.2.post1')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import facefusion.choices
|
|||||||
from facefusion.filesystem import create_directory, get_file_name, is_directory, is_file, move_file, remove_directory, remove_file, resolve_file_pattern
|
from facefusion.filesystem import create_directory, get_file_name, is_directory, is_file, move_file, remove_directory, remove_file, resolve_file_pattern
|
||||||
from facefusion.jobs.job_helper import get_step_output_path
|
from facefusion.jobs.job_helper import get_step_output_path
|
||||||
from facefusion.json import read_json, write_json
|
from facefusion.json import read_json, write_json
|
||||||
|
from facefusion.sanitizer import sanitize_job_id
|
||||||
from facefusion.time_helper import get_current_date_time
|
from facefusion.time_helper import get_current_date_time
|
||||||
from facefusion.types import Args, Job, JobSet, JobStatus, JobStep, JobStepStatus
|
from facefusion.types import Args, Job, JobSet, JobStatus, JobStep, JobStepStatus
|
||||||
|
|
||||||
@@ -261,5 +262,6 @@ def find_job_path(job_id : str) -> Optional[str]:
|
|||||||
|
|
||||||
def get_job_file_name(job_id : str) -> Optional[str]:
|
def get_job_file_name(job_id : str) -> Optional[str]:
|
||||||
if job_id:
|
if job_id:
|
||||||
|
job_id = sanitize_job_id(job_id)
|
||||||
return job_id + '.json'
|
return job_id + '.json'
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ def sanitize_job_id(job_id : str) -> str:
|
|||||||
|
|
||||||
if __job_id__.isalnum():
|
if __job_id__.isalnum():
|
||||||
return job_id
|
return job_id
|
||||||
|
|
||||||
return hashlib.sha1(job_id.encode()).hexdigest()
|
return hashlib.sha1(job_id.encode()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from typing import Deque, Iterator
|
from typing import Deque, Iterator, List
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy
|
import numpy
|
||||||
@@ -20,6 +20,7 @@ from facefusion.vision import extract_vision_mask, read_static_images
|
|||||||
|
|
||||||
def multi_process_capture(camera_capture : cv2.VideoCapture, camera_fps : Fps) -> Iterator[VisionFrame]:
|
def multi_process_capture(camera_capture : cv2.VideoCapture, camera_fps : Fps) -> Iterator[VisionFrame]:
|
||||||
capture_deque : Deque[VisionFrame] = deque()
|
capture_deque : Deque[VisionFrame] = deque()
|
||||||
|
source_vision_frames = read_static_images(state_manager.get_item('source_paths'))
|
||||||
|
|
||||||
with tqdm(desc = translator.get('streaming'), unit = 'frame', disable = state_manager.get_item('log_level') in [ 'warn', 'error' ]) as progress:
|
with tqdm(desc = translator.get('streaming'), unit = 'frame', disable = state_manager.get_item('log_level') in [ 'warn', 'error' ]) as progress:
|
||||||
with ThreadPoolExecutor(max_workers = state_manager.get_item('execution_thread_count')) as executor:
|
with ThreadPoolExecutor(max_workers = state_manager.get_item('execution_thread_count')) as executor:
|
||||||
@@ -32,7 +33,7 @@ def multi_process_capture(camera_capture : cv2.VideoCapture, camera_fps : Fps) -
|
|||||||
|
|
||||||
if numpy.any(capture_frame):
|
if numpy.any(capture_frame):
|
||||||
audio_frame = create_empty_audio_frame()
|
audio_frame = create_empty_audio_frame()
|
||||||
future = executor.submit(process_frame, audio_frame, capture_frame)
|
future = executor.submit(process_frame, source_vision_frames, audio_frame, capture_frame)
|
||||||
futures.append(future)
|
futures.append(future)
|
||||||
|
|
||||||
for future_done in [ future for future in futures if future.done() ]:
|
for future_done in [ future for future in futures if future.done() ]:
|
||||||
@@ -45,8 +46,7 @@ def multi_process_capture(camera_capture : cv2.VideoCapture, camera_fps : Fps) -
|
|||||||
yield capture_deque.popleft()
|
yield capture_deque.popleft()
|
||||||
|
|
||||||
|
|
||||||
def process_frame(stream_audio_frame : AudioFrame, stream_vision_frame : VisionFrame) -> VisionFrame:
|
def process_frame(source_vision_frames : List[VisionFrame], stream_audio_frame : AudioFrame, stream_vision_frame : VisionFrame) -> VisionFrame:
|
||||||
source_vision_frames = read_static_images(state_manager.get_item('source_paths'))
|
|
||||||
source_voice_frame = create_empty_audio_frame()
|
source_voice_frame = create_empty_audio_frame()
|
||||||
temp_vision_frame = stream_vision_frame.copy()
|
temp_vision_frame = stream_vision_frame.copy()
|
||||||
temp_vision_mask = extract_vision_mask(temp_vision_frame)
|
temp_vision_mask = extract_vision_mask(temp_vision_frame)
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
numpy==2.4.2
|
numpy==2.4.2
|
||||||
onnx==1.20.1
|
onnx==1.20.1
|
||||||
onnxruntime==1.24.1
|
onnxruntime==1.26.0
|
||||||
opencv-python==4.13.0.92
|
opencv-python==4.13.0.92
|
||||||
psutil==7.2.2
|
psutil==7.2.2
|
||||||
python-multipart==0.0.28
|
python-multipart==0.0.28
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
from configparser import ConfigParser
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from facefusion import config
|
from facefusion import config, state_manager
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope = 'module', autouse = True)
|
@pytest.fixture(scope = 'module', autouse = True)
|
||||||
def before_all() -> None:
|
def before_all() -> None:
|
||||||
config.CONFIG_PARSER = ConfigParser()
|
state_manager.init_item('config_path', 'facefusion.ini')
|
||||||
config.CONFIG_PARSER.read_dict(
|
config_parser = config.get_static_config_parser()
|
||||||
|
config_parser.read_dict(
|
||||||
{
|
{
|
||||||
'str':
|
'str':
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user