mirror of
https://github.com/facefusion/facefusion.git
synced 2026-07-28 21:08:54 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8801668562 | ||
|
|
a7f3de3dbc |
@@ -43,9 +43,9 @@ def detect_local_camera_ids(id_start : int, id_end : int) -> List[int]:
|
||||
local_camera_ids = []
|
||||
|
||||
for camera_id in range(id_start, id_end):
|
||||
cv2.setLogLevel(0)
|
||||
cv2.utils.logging.setLogLevel(0)
|
||||
camera_capture = get_local_camera_capture(camera_id)
|
||||
cv2.setLogLevel(3)
|
||||
cv2.utils.logging.setLogLevel(3)
|
||||
|
||||
if camera_capture and camera_capture.isOpened():
|
||||
local_camera_ids.append(camera_id)
|
||||
|
||||
@@ -114,6 +114,7 @@ def extract_frames(target_path : str, temp_video_resolution : Resolution, temp_v
|
||||
ffmpeg_builder.set_input(target_path),
|
||||
ffmpeg_builder.set_media_resolution(pack_resolution(temp_video_resolution)),
|
||||
ffmpeg_builder.set_frame_quality(0),
|
||||
ffmpeg_builder.enforce_pixel_format('rgb24'),
|
||||
ffmpeg_builder.select_frame_range(trim_frame_start, trim_frame_end, temp_video_fps),
|
||||
ffmpeg_builder.prevent_frame_drop(),
|
||||
ffmpeg_builder.set_output(temp_frames_pattern)
|
||||
|
||||
@@ -79,6 +79,10 @@ def unsafe_concat() -> List[Command]:
|
||||
return [ '-f', 'concat', '-safe', '0' ]
|
||||
|
||||
|
||||
def enforce_pixel_format(pixel_format : str) -> List[Command]:
|
||||
return [ '-pix_fmt', pixel_format ]
|
||||
|
||||
|
||||
def set_pixel_format(video_encoder : VideoEncoder) -> List[Command]:
|
||||
if video_encoder == 'rawvideo':
|
||||
return [ '-pix_fmt', 'rgb24' ]
|
||||
|
||||
+27
-31
@@ -10,7 +10,7 @@ from types import FrameType
|
||||
from facefusion import metadata
|
||||
from facefusion.common_helper import is_linux, is_windows
|
||||
|
||||
LOCALS =\
|
||||
LOCALES =\
|
||||
{
|
||||
'install_dependency': 'install the {dependency} package',
|
||||
'force_reinstall': 'force reinstall of packages',
|
||||
@@ -19,24 +19,24 @@ LOCALS =\
|
||||
}
|
||||
ONNXRUNTIME_SET =\
|
||||
{
|
||||
'default': ('onnxruntime', '1.23.2')
|
||||
'default': ('onnxruntime', '1.24.1')
|
||||
}
|
||||
if is_windows() or is_linux():
|
||||
ONNXRUNTIME_SET['cuda'] = ('onnxruntime-gpu', '1.23.2')
|
||||
ONNXRUNTIME_SET['cuda'] = ('onnxruntime-gpu', '1.24.1')
|
||||
ONNXRUNTIME_SET['openvino'] = ('onnxruntime-openvino', '1.23.0')
|
||||
if is_windows():
|
||||
ONNXRUNTIME_SET['directml'] = ('onnxruntime-directml', '1.23.0')
|
||||
ONNXRUNTIME_SET['directml'] = ('onnxruntime-directml', '1.24.1')
|
||||
if is_linux():
|
||||
ONNXRUNTIME_SET['migraphx'] = ('onnxruntime-migraphx', '1.23.0')
|
||||
ONNXRUNTIME_SET['rocm'] = ('onnxruntime_rocm', '1.22.1', '7.0.2') #type:ignore[assignment]
|
||||
ONNXRUNTIME_SET['migraphx'] = ('onnxruntime-migraphx', '1.23.2')
|
||||
ONNXRUNTIME_SET['rocm'] = ('onnxruntime-rocm', '1.22.2.post1')
|
||||
|
||||
|
||||
def cli() -> None:
|
||||
signal.signal(signal.SIGINT, signal_exit)
|
||||
program = ArgumentParser(formatter_class = partial(HelpFormatter, max_help_position = 50))
|
||||
program.add_argument('--onnxruntime', help = LOCALS.get('install_dependency').format(dependency = 'onnxruntime'), choices = ONNXRUNTIME_SET.keys(), required = True)
|
||||
program.add_argument('--force-reinstall', help = LOCALS.get('force_reinstall'), action = 'store_true')
|
||||
program.add_argument('--skip-conda', help = LOCALS.get('skip_conda'), action = 'store_true')
|
||||
program.add_argument('--onnxruntime', help = LOCALES.get('install_dependency').format(dependency = 'onnxruntime'), choices = ONNXRUNTIME_SET.keys(), required = True)
|
||||
program.add_argument('--force-reinstall', help = LOCALES.get('force_reinstall'), action = 'store_true')
|
||||
program.add_argument('--skip-conda', help = LOCALES.get('skip_conda'), action = 'store_true')
|
||||
program.add_argument('-v', '--version', version = metadata.get('name') + ' ' + metadata.get('version'), action = 'version')
|
||||
run(program)
|
||||
|
||||
@@ -48,15 +48,16 @@ def signal_exit(signum : int, frame : FrameType) -> None:
|
||||
def run(program : ArgumentParser) -> None:
|
||||
args = program.parse_args()
|
||||
has_conda = 'CONDA_PREFIX' in os.environ
|
||||
|
||||
if not args.skip_conda and not has_conda:
|
||||
sys.stdout.write(LOCALES.get('conda_not_activated') + os.linesep)
|
||||
sys.exit(1)
|
||||
|
||||
commands = [ shutil.which('pip'), 'install' ]
|
||||
|
||||
if args.force_reinstall:
|
||||
commands.append('--force-reinstall')
|
||||
|
||||
if not args.skip_conda and not has_conda:
|
||||
sys.stdout.write(LOCALS.get('conda_not_activated') + os.linesep)
|
||||
sys.exit(1)
|
||||
|
||||
with open('requirements.txt') as file:
|
||||
|
||||
for line in file.readlines():
|
||||
@@ -64,17 +65,10 @@ def run(program : ArgumentParser) -> None:
|
||||
if not __line__.startswith('onnxruntime'):
|
||||
commands.append(__line__)
|
||||
|
||||
if args.onnxruntime == 'rocm':
|
||||
onnxruntime_name, onnxruntime_version, rocm_version = ONNXRUNTIME_SET.get(args.onnxruntime) #type:ignore[misc]
|
||||
python_id = 'cp' + str(sys.version_info.major) + str(sys.version_info.minor)
|
||||
onnxruntime_name, onnxruntime_version = ONNXRUNTIME_SET.get(args.onnxruntime)
|
||||
commands.append(onnxruntime_name + '==' + onnxruntime_version)
|
||||
|
||||
if python_id in [ 'cp310', 'cp312' ]:
|
||||
wheel_name = onnxruntime_name + '-' + onnxruntime_version + '-' + python_id + '-' + python_id + '-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl'
|
||||
wheel_url = 'https://repo.radeon.com/rocm/manylinux/rocm-rel-' + rocm_version + '/' + wheel_name
|
||||
commands.append(wheel_url)
|
||||
else:
|
||||
onnxruntime_name, onnxruntime_version = ONNXRUNTIME_SET.get(args.onnxruntime)
|
||||
commands.append(onnxruntime_name + '==' + onnxruntime_version)
|
||||
subprocess.call([shutil.which('pip'), 'uninstall', 'onnxruntime', onnxruntime_name, '-y', '-q' ])
|
||||
|
||||
subprocess.call(commands)
|
||||
|
||||
@@ -82,28 +76,30 @@ def run(program : ArgumentParser) -> None:
|
||||
library_paths = []
|
||||
|
||||
if is_linux():
|
||||
if os.getenv('LD_LIBRARY_PATH'):
|
||||
library_paths = os.getenv('LD_LIBRARY_PATH').split(os.pathsep)
|
||||
|
||||
python_id = 'python' + str(sys.version_info.major) + '.' + str(sys.version_info.minor)
|
||||
library_paths.extend(
|
||||
[
|
||||
os.path.join(os.getenv('CONDA_PREFIX'), 'lib'),
|
||||
os.path.join(os.getenv('CONDA_PREFIX'), 'lib', python_id, 'site-packages', 'tensorrt_libs')
|
||||
])
|
||||
library_paths = list(dict.fromkeys([ library_path for library_path in library_paths if os.path.exists(library_path) ]))
|
||||
|
||||
if os.getenv('LD_LIBRARY_PATH'):
|
||||
library_paths.extend(os.getenv('LD_LIBRARY_PATH').split(os.pathsep))
|
||||
|
||||
library_paths = list(dict.fromkeys(filter(os.path.exists, library_paths)))
|
||||
|
||||
subprocess.call([ shutil.which('conda'), 'env', 'config', 'vars', 'set', 'LD_LIBRARY_PATH=' + os.pathsep.join(library_paths) ])
|
||||
|
||||
if is_windows():
|
||||
if os.getenv('PATH'):
|
||||
library_paths = os.getenv('PATH').split(os.pathsep)
|
||||
|
||||
library_paths.extend(
|
||||
[
|
||||
os.path.join(os.getenv('CONDA_PREFIX'), 'Lib'),
|
||||
os.path.join(os.getenv('CONDA_PREFIX'), 'Lib', 'site-packages', 'tensorrt_libs')
|
||||
])
|
||||
library_paths = list(dict.fromkeys([ library_path for library_path in library_paths if os.path.exists(library_path) ]))
|
||||
|
||||
if os.getenv('PATH'):
|
||||
library_paths.extend(os.getenv('PATH').split(os.pathsep))
|
||||
|
||||
library_paths = list(dict.fromkeys(filter(os.path.exists, library_paths)))
|
||||
|
||||
subprocess.call([ shutil.which('conda'), 'env', 'config', 'vars', 'set', 'PATH=' + os.pathsep.join(library_paths) ])
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from facefusion.types import Locals
|
||||
from facefusion.types import Locales
|
||||
|
||||
LOCALS : Locals =\
|
||||
LOCALES : Locales =\
|
||||
{
|
||||
'en':
|
||||
{
|
||||
@@ -189,7 +189,7 @@ LOCALS : Locals =\
|
||||
},
|
||||
'about':
|
||||
{
|
||||
'fund': 'fund training server',
|
||||
'fund': 'fund ai workstation',
|
||||
'subscribe': 'become a member',
|
||||
'join': 'join our community'
|
||||
},
|
||||
@@ -4,7 +4,7 @@ METADATA =\
|
||||
{
|
||||
'name': 'FaceFusion',
|
||||
'description': 'Industry leading face manipulation platform',
|
||||
'version': '3.5.2',
|
||||
'version': '3.5.3',
|
||||
'license': 'OpenRAIL-AS',
|
||||
'author': 'Henry Ruhs',
|
||||
'url': 'https://facefusion.io'
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
from facefusion.types import Locals
|
||||
from facefusion.types import Locales
|
||||
|
||||
LOCALS : Locals =\
|
||||
LOCALES : Locales =\
|
||||
{
|
||||
'en':
|
||||
{
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
from facefusion.types import Locals
|
||||
from facefusion.types import Locales
|
||||
|
||||
LOCALS : Locals =\
|
||||
LOCALES : Locales =\
|
||||
{
|
||||
'en':
|
||||
{
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
from facefusion.types import Locals
|
||||
from facefusion.types import Locales
|
||||
|
||||
LOCALS : Locals =\
|
||||
LOCALES : Locales =\
|
||||
{
|
||||
'en':
|
||||
{
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
from facefusion.types import Locals
|
||||
from facefusion.types import Locales
|
||||
|
||||
LOCALS : Locals =\
|
||||
LOCALES : Locales =\
|
||||
{
|
||||
'en':
|
||||
{
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
from facefusion.types import Locals
|
||||
from facefusion.types import Locales
|
||||
|
||||
LOCALS : Locals =\
|
||||
LOCALES : Locales =\
|
||||
{
|
||||
'en':
|
||||
{
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
from facefusion.types import Locals
|
||||
from facefusion.types import Locales
|
||||
|
||||
LOCALS : Locals =\
|
||||
LOCALES : Locales =\
|
||||
{
|
||||
'en':
|
||||
{
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
from facefusion.types import Locals
|
||||
from facefusion.types import Locales
|
||||
|
||||
LOCALS : Locals =\
|
||||
LOCALES : Locales =\
|
||||
{
|
||||
'en':
|
||||
{
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
from facefusion.types import Locals
|
||||
from facefusion.types import Locales
|
||||
|
||||
LOCALS : Locals =\
|
||||
LOCALES : Locales =\
|
||||
{
|
||||
'en':
|
||||
{
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
from facefusion.types import Locals
|
||||
from facefusion.types import Locales
|
||||
|
||||
LOCALS : Locals =\
|
||||
LOCALES : Locales =\
|
||||
{
|
||||
'en':
|
||||
{
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
from facefusion.types import Locals
|
||||
from facefusion.types import Locales
|
||||
|
||||
LOCALS : Locals =\
|
||||
LOCALES : Locales =\
|
||||
{
|
||||
'en':
|
||||
{
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
from facefusion.types import Locals
|
||||
from facefusion.types import Locales
|
||||
|
||||
LOCALS : Locals =\
|
||||
LOCALES : Locales =\
|
||||
{
|
||||
'en':
|
||||
{
|
||||
@@ -1,29 +1,29 @@
|
||||
import importlib
|
||||
from typing import Optional
|
||||
|
||||
from facefusion.types import Language, LocalPoolSet, Locals
|
||||
from facefusion.types import Language, LocalePoolSet, Locales
|
||||
|
||||
LOCAL_POOL_SET : LocalPoolSet = {}
|
||||
LOCALE_POOL_SET : LocalePoolSet = {}
|
||||
CURRENT_LANGUAGE : Language = 'en'
|
||||
|
||||
|
||||
def __autoload__(module_name : str) -> None:
|
||||
try:
|
||||
__locals__ = importlib.import_module(module_name + '.locals')
|
||||
load(__locals__.LOCALS, module_name)
|
||||
__locales__ = importlib.import_module(module_name + '.locales')
|
||||
load(__locales__.LOCALES, module_name)
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
def load(__locals__ : Locals, module_name : str) -> None:
|
||||
LOCAL_POOL_SET[module_name] = __locals__
|
||||
def load(__locales__ : Locales, module_name : str) -> None:
|
||||
LOCALE_POOL_SET[module_name] = __locales__
|
||||
|
||||
|
||||
def get(notation : str, module_name : str = 'facefusion') -> Optional[str]:
|
||||
if module_name not in LOCAL_POOL_SET:
|
||||
if module_name not in LOCALE_POOL_SET:
|
||||
__autoload__(module_name)
|
||||
|
||||
current = LOCAL_POOL_SET.get(module_name).get(CURRENT_LANGUAGE)
|
||||
current = LOCALE_POOL_SET.get(module_name).get(CURRENT_LANGUAGE)
|
||||
|
||||
for fragment in notation.split('.'):
|
||||
if fragment in current:
|
||||
|
||||
+2
-2
@@ -51,8 +51,8 @@ FaceStore = TypedDict('FaceStore',
|
||||
})
|
||||
|
||||
Language = Literal['en']
|
||||
Locals : TypeAlias = Dict[Language, Dict[str, Any]]
|
||||
LocalPoolSet : TypeAlias = Dict[str, Locals]
|
||||
Locales : TypeAlias = Dict[Language, Dict[str, Any]]
|
||||
LocalePoolSet : TypeAlias = Dict[str, Locales]
|
||||
|
||||
VideoCaptureSet : TypeAlias = Dict[str, cv2.VideoCapture]
|
||||
VideoWriterSet : TypeAlias = Dict[str, cv2.VideoWriter]
|
||||
|
||||
@@ -10,7 +10,7 @@ from facefusion.streamer import multi_process_capture, open_stream
|
||||
from facefusion.types import Fps, VisionFrame, WebcamMode
|
||||
from facefusion.uis.core import get_ui_component
|
||||
from facefusion.uis.types import File
|
||||
from facefusion.vision import unpack_resolution
|
||||
from facefusion.vision import fit_cover_frame, unpack_resolution
|
||||
|
||||
SOURCE_FILE : Optional[gradio.File] = None
|
||||
WEBCAM_IMAGE : Optional[gradio.Image] = None
|
||||
@@ -100,10 +100,11 @@ def start(webcam_device_id : int, webcam_mode : WebcamMode, webcam_resolution :
|
||||
|
||||
for capture_frame in multi_process_capture(camera_capture, webcam_fps):
|
||||
capture_frame = cv2.cvtColor(capture_frame, cv2.COLOR_BGR2RGB)
|
||||
capture_frame = fit_cover_frame(capture_frame, (webcam_width, webcam_height))
|
||||
|
||||
if webcam_mode == 'inline':
|
||||
yield capture_frame
|
||||
else:
|
||||
if webcam_mode in [ 'udp', 'v4l2' ]:
|
||||
try:
|
||||
stream.stdin.write(capture_frame.tobytes())
|
||||
except Exception:
|
||||
|
||||
+6
-7
@@ -1,9 +1,8 @@
|
||||
gradio-rangeslider==0.0.8
|
||||
gradio==5.44.1
|
||||
numpy==2.2.6
|
||||
onnx==1.19.1
|
||||
onnxruntime==1.23.2
|
||||
opencv-python==4.12.0.88
|
||||
psutil==7.1.3
|
||||
tqdm==4.67.1
|
||||
scipy==1.16.3
|
||||
numpy==2.2.1
|
||||
onnx==1.20.1
|
||||
onnxruntime==1.24.1
|
||||
opencv-python==4.13.0.92
|
||||
tqdm==4.67.3
|
||||
scipy==1.17.0
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from facefusion import translator
|
||||
from facefusion.locals import LOCALS
|
||||
from facefusion.locales import LOCALES
|
||||
|
||||
|
||||
def test_load() -> None:
|
||||
translator.load(LOCALS, __name__)
|
||||
translator.load(LOCALES, __name__)
|
||||
|
||||
assert __name__ in translator.LOCAL_POOL_SET
|
||||
assert __name__ in translator.LOCALE_POOL_SET
|
||||
|
||||
|
||||
def test_get() -> None:
|
||||
|
||||
Reference in New Issue
Block a user