diff --git a/DeepFakeAI/__pycache__/__init__.cpython-310.pyc b/DeepFakeAI/__pycache__/__init__.cpython-310.pyc index 568166eb25f4837fa6a81e00f941a91c48e4c679..8358ef61ae3a0144aecda984a7c8ae5aafb5f0fc 100644 Binary files a/DeepFakeAI/__pycache__/__init__.cpython-310.pyc and b/DeepFakeAI/__pycache__/__init__.cpython-310.pyc differ diff --git a/DeepFakeAI/__pycache__/capturer.cpython-310.pyc b/DeepFakeAI/__pycache__/capturer.cpython-310.pyc index 5d80c2f73ab16d42170e9aa2d07e0eeb8752448e..3c7feaea452e1f425b3efe45e3233fe5b0230bcb 100644 Binary files a/DeepFakeAI/__pycache__/capturer.cpython-310.pyc and b/DeepFakeAI/__pycache__/capturer.cpython-310.pyc differ diff --git a/DeepFakeAI/__pycache__/choices.cpython-310.pyc b/DeepFakeAI/__pycache__/choices.cpython-310.pyc index 74879608ab48ca7837a52aaaeb9fc2c63b0cb32e..abf5164f610c4412e9593c8d4d66b816822b11f9 100644 Binary files a/DeepFakeAI/__pycache__/choices.cpython-310.pyc and b/DeepFakeAI/__pycache__/choices.cpython-310.pyc differ diff --git a/DeepFakeAI/__pycache__/core.cpython-310.pyc b/DeepFakeAI/__pycache__/core.cpython-310.pyc index 8ea71515cbe72df3079ce654afa30710e610a377..0d9652d964ce98a681b5cfde1ff6619f5ae0f9fa 100644 Binary files a/DeepFakeAI/__pycache__/core.cpython-310.pyc and b/DeepFakeAI/__pycache__/core.cpython-310.pyc differ diff --git a/DeepFakeAI/__pycache__/face_analyser.cpython-310.pyc b/DeepFakeAI/__pycache__/face_analyser.cpython-310.pyc index 0c11bfcc38886e10f8798454cf33a535af014060..7e3c62f331f3a3d20546ae1c60b576b069cc393d 100644 Binary files a/DeepFakeAI/__pycache__/face_analyser.cpython-310.pyc and b/DeepFakeAI/__pycache__/face_analyser.cpython-310.pyc differ diff --git a/DeepFakeAI/__pycache__/face_reference.cpython-310.pyc b/DeepFakeAI/__pycache__/face_reference.cpython-310.pyc index b03fdcd1e92bfbd12fdca43d27f9fccdc83bc16b..c86ef8a7c647e3cd7d3d7f2da76cecc66a7e2a4e 100644 Binary files a/DeepFakeAI/__pycache__/face_reference.cpython-310.pyc and b/DeepFakeAI/__pycache__/face_reference.cpython-310.pyc differ diff --git a/DeepFakeAI/__pycache__/globals.cpython-310.pyc b/DeepFakeAI/__pycache__/globals.cpython-310.pyc index f6ba2c8bd91f7559eb4569f0f3d4bec929da3705..e461d925e1086cfc9335cb85b91b94d08ae31069 100644 Binary files a/DeepFakeAI/__pycache__/globals.cpython-310.pyc and b/DeepFakeAI/__pycache__/globals.cpython-310.pyc differ diff --git a/DeepFakeAI/__pycache__/metadata.cpython-310.pyc b/DeepFakeAI/__pycache__/metadata.cpython-310.pyc index e8d6b56c563d81d746e1731d5632e6c2b6a17885..a3b640ae15caeee0108f3e684795b115b180dade 100644 Binary files a/DeepFakeAI/__pycache__/metadata.cpython-310.pyc and b/DeepFakeAI/__pycache__/metadata.cpython-310.pyc differ diff --git a/DeepFakeAI/__pycache__/predictor.cpython-310.pyc b/DeepFakeAI/__pycache__/predictor.cpython-310.pyc index 18c3a742353e4579d2a5f780b1f08963cd660f6c..3ba281cab4650f56aa409d1036eed00d88f29a29 100644 Binary files a/DeepFakeAI/__pycache__/predictor.cpython-310.pyc and b/DeepFakeAI/__pycache__/predictor.cpython-310.pyc differ diff --git a/DeepFakeAI/__pycache__/typing.cpython-310.pyc b/DeepFakeAI/__pycache__/typing.cpython-310.pyc index 57e4cd024929c3c809bc9d4a5565b245b72ad489..cc2b5e0c567e3c8b3d8a0f8b010b67b809b04127 100644 Binary files a/DeepFakeAI/__pycache__/typing.cpython-310.pyc and b/DeepFakeAI/__pycache__/typing.cpython-310.pyc differ diff --git a/DeepFakeAI/__pycache__/utilities.cpython-310.pyc b/DeepFakeAI/__pycache__/utilities.cpython-310.pyc index e89b852e9303a63edca277e4463bd9227713f709..439a8dd450f32239f69624825fb66f0c1bbd4494 100644 Binary files a/DeepFakeAI/__pycache__/utilities.cpython-310.pyc and b/DeepFakeAI/__pycache__/utilities.cpython-310.pyc differ diff --git a/DeepFakeAI/__pycache__/wording.cpython-310.pyc b/DeepFakeAI/__pycache__/wording.cpython-310.pyc index 370e7d920c50ba8f188ebb966fae358a999e06ae..fd8a4d057f30b062869d62a65ee9fa05a9105dac 100644 Binary files a/DeepFakeAI/__pycache__/wording.cpython-310.pyc and b/DeepFakeAI/__pycache__/wording.cpython-310.pyc differ diff --git a/DeepFakeAI/capturer.py b/DeepFakeAI/capturer.py index 1f01b1eecbf6076ff77ecaf476b7d980328ed131..9ba555c222d55166c9fb5faf0b32f1afd6a69d46 100644 --- a/DeepFakeAI/capturer.py +++ b/DeepFakeAI/capturer.py @@ -1,7 +1,7 @@ from typing import Optional import cv2 -from facefusion.typing import Frame +from DeepFakeAI.typing import Frame def get_video_frame(video_path : str, frame_number : int = 0) -> Optional[Frame]: diff --git a/DeepFakeAI/choices.py b/DeepFakeAI/choices.py index ff1312ac1d473cb05ae12cf2d2af2ecac211b56f..4e34f2f477f91f8494935aee3495f7090404158a 100644 --- a/DeepFakeAI/choices.py +++ b/DeepFakeAI/choices.py @@ -1,6 +1,6 @@ from typing import List -from facefusion.typing import FaceRecognition, FaceAnalyserDirection, FaceAnalyserAge, FaceAnalyserGender, TempFrameFormat, OutputVideoEncoder +from DeepFakeAI.typing import FaceRecognition, FaceAnalyserDirection, FaceAnalyserAge, FaceAnalyserGender, TempFrameFormat, OutputVideoEncoder face_recognition : List[FaceRecognition] = [ 'reference', 'many' ] face_analyser_direction : List[FaceAnalyserDirection] = [ 'left-right', 'right-left', 'top-bottom', 'bottom-top', 'small-large', 'large-small'] diff --git a/DeepFakeAI/core.py b/DeepFakeAI/core.py index d3b423a4f2f2e0cfaeacbea394cfa5a1d9fe744d..538f78c6a43b0afbfdc027c1cfbbdb71bd93ee39 100644 --- a/DeepFakeAI/core.py +++ b/DeepFakeAI/core.py @@ -15,12 +15,12 @@ import argparse import onnxruntime import tensorflow -import facefusion.choices -import facefusion.globals -from facefusion import wording, metadata -from facefusion.predictor import predict_image, predict_video -from facefusion.processors.frame.core import get_frame_processors_modules -from facefusion.utilities import is_image, is_video, detect_fps, create_video, extract_frames, get_temp_frame_paths, restore_audio, create_temp, move_temp, clear_temp, normalize_output_path, list_module_names, decode_execution_providers, encode_execution_providers +import DeepFakeAI.choices +import DeepFakeAI.globals +from DeepFakeAI import wording, metadata +from DeepFakeAI.predictor import predict_image, predict_video +from DeepFakeAI.processors.frame.core import get_frame_processors_modules +from DeepFakeAI.utilities import is_image, is_video, detect_fps, create_video, extract_frames, get_temp_frame_paths, restore_audio, create_temp, move_temp, clear_temp, normalize_output_path, list_module_names, decode_execution_providers, encode_execution_providers warnings.filterwarnings('ignore', category = FutureWarning, module = 'insightface') warnings.filterwarnings('ignore', category = UserWarning, module = 'torchvision') @@ -32,23 +32,23 @@ def parse_args() -> None: program.add_argument('-s', '--source', help = wording.get('source_help'), dest = 'source_path') program.add_argument('-t', '--target', help = wording.get('target_help'), dest = 'target_path') program.add_argument('-o', '--output', help = wording.get('output_help'), dest = 'output_path') - program.add_argument('--frame-processors', help = wording.get('frame_processors_help').format(choices = ', '.join(list_module_names('facefusion/processors/frame/modules'))), dest = 'frame_processors', default = ['face_swapper'], nargs='+') - program.add_argument('--ui-layouts', help = wording.get('ui_layouts_help').format(choices = ', '.join(list_module_names('facefusion/uis/layouts'))), dest = 'ui_layouts', default = ['default'], nargs='+') + program.add_argument('--frame-processors', help = wording.get('frame_processors_help').format(choices = ', '.join(list_module_names('DeepFakeAI/processors/frame/modules'))), dest = 'frame_processors', default = ['face_swapper'], nargs='+') + program.add_argument('--ui-layouts', help = wording.get('ui_layouts_help').format(choices = ', '.join(list_module_names('DeepFakeAI/uis/layouts'))), dest = 'ui_layouts', default = ['default'], nargs='+') program.add_argument('--keep-fps', help = wording.get('keep_fps_help'), dest = 'keep_fps', action='store_true') program.add_argument('--keep-temp', help = wording.get('keep_temp_help'), dest = 'keep_temp', action='store_true') program.add_argument('--skip-audio', help = wording.get('skip_audio_help'), dest = 'skip_audio', action='store_true') - program.add_argument('--face-recognition', help = wording.get('face_recognition_help'), dest = 'face_recognition', default = 'reference', choices = facefusion.choices.face_recognition) - program.add_argument('--face-analyser-direction', help = wording.get('face_analyser_direction_help'), dest = 'face_analyser_direction', default = 'left-right', choices = facefusion.choices.face_analyser_direction) - program.add_argument('--face-analyser-age', help = wording.get('face_analyser_age_help'), dest = 'face_analyser_age', choices = facefusion.choices.face_analyser_age) - program.add_argument('--face-analyser-gender', help = wording.get('face_analyser_gender_help'), dest = 'face_analyser_gender', choices = facefusion.choices.face_analyser_gender) + program.add_argument('--face-recognition', help = wording.get('face_recognition_help'), dest = 'face_recognition', default = 'reference', choices = DeepFakeAI.choices.face_recognition) + program.add_argument('--face-analyser-direction', help = wording.get('face_analyser_direction_help'), dest = 'face_analyser_direction', default = 'left-right', choices = DeepFakeAI.choices.face_analyser_direction) + program.add_argument('--face-analyser-age', help = wording.get('face_analyser_age_help'), dest = 'face_analyser_age', choices = DeepFakeAI.choices.face_analyser_age) + program.add_argument('--face-analyser-gender', help = wording.get('face_analyser_gender_help'), dest = 'face_analyser_gender', choices = DeepFakeAI.choices.face_analyser_gender) program.add_argument('--reference-face-position', help = wording.get('reference_face_position_help'), dest = 'reference_face_position', type = int, default = 0) program.add_argument('--reference-face-distance', help = wording.get('reference_face_distance_help'), dest = 'reference_face_distance', type = float, default = 1.5) program.add_argument('--reference-frame-number', help = wording.get('reference_frame_number_help'), dest = 'reference_frame_number', type = int, default = 0) program.add_argument('--trim-frame-start', help = wording.get('trim_frame_start_help'), dest = 'trim_frame_start', type = int) program.add_argument('--trim-frame-end', help = wording.get('trim_frame_end_help'), dest = 'trim_frame_end', type = int) - program.add_argument('--temp-frame-format', help = wording.get('temp_frame_format_help'), dest = 'temp_frame_format', default = 'jpg', choices = facefusion.choices.temp_frame_format) + program.add_argument('--temp-frame-format', help = wording.get('temp_frame_format_help'), dest = 'temp_frame_format', default = 'jpg', choices = DeepFakeAI.choices.temp_frame_format) program.add_argument('--temp-frame-quality', help = wording.get('temp_frame_quality_help'), dest = 'temp_frame_quality', type = int, default = 100, choices = range(101), metavar = '[0-100]') - program.add_argument('--output-video-encoder', help = wording.get('output_video_encoder_help'), dest = 'output_video_encoder', default = 'libx264', choices = facefusion.choices.output_video_encoder) + program.add_argument('--output-video-encoder', help = wording.get('output_video_encoder_help'), dest = 'output_video_encoder', default = 'libx264', choices = DeepFakeAI.choices.output_video_encoder) program.add_argument('--output-video-quality', help = wording.get('output_video_quality_help'), dest = 'output_video_quality', type = int, default = 90, choices = range(101), metavar = '[0-100]') program.add_argument('--max-memory', help = wording.get('max_memory_help'), dest = 'max_memory', type = int) program.add_argument('--execution-providers', help = wording.get('execution_providers_help').format(choices = 'cpu'), dest = 'execution_providers', default = ['cpu'], choices = suggest_execution_providers_choices(), nargs='+') @@ -58,32 +58,32 @@ def parse_args() -> None: args = program.parse_args() - facefusion.globals.source_path = args.source_path - facefusion.globals.target_path = args.target_path - facefusion.globals.output_path = normalize_output_path(facefusion.globals.source_path, facefusion.globals.target_path, args.output_path) - facefusion.globals.headless = facefusion.globals.source_path is not None and facefusion.globals.target_path is not None and facefusion.globals.output_path is not None - facefusion.globals.frame_processors = args.frame_processors - facefusion.globals.ui_layouts = args.ui_layouts - facefusion.globals.keep_fps = args.keep_fps - facefusion.globals.keep_temp = args.keep_temp - facefusion.globals.skip_audio = args.skip_audio - facefusion.globals.face_recognition = args.face_recognition - facefusion.globals.face_analyser_direction = args.face_analyser_direction - facefusion.globals.face_analyser_age = args.face_analyser_age - facefusion.globals.face_analyser_gender = args.face_analyser_gender - facefusion.globals.reference_face_position = args.reference_face_position - facefusion.globals.reference_frame_number = args.reference_frame_number - facefusion.globals.reference_face_distance = args.reference_face_distance - facefusion.globals.trim_frame_start = args.trim_frame_start - facefusion.globals.trim_frame_end = args.trim_frame_end - facefusion.globals.temp_frame_format = args.temp_frame_format - facefusion.globals.temp_frame_quality = args.temp_frame_quality - facefusion.globals.output_video_encoder = args.output_video_encoder - facefusion.globals.output_video_quality = args.output_video_quality - facefusion.globals.max_memory = args.max_memory - facefusion.globals.execution_providers = decode_execution_providers(args.execution_providers) - facefusion.globals.execution_thread_count = args.execution_thread_count - facefusion.globals.execution_queue_count = args.execution_queue_count + DeepFakeAI.globals.source_path = args.source_path + DeepFakeAI.globals.target_path = args.target_path + DeepFakeAI.globals.output_path = normalize_output_path(DeepFakeAI.globals.source_path, DeepFakeAI.globals.target_path, args.output_path) + DeepFakeAI.globals.headless = DeepFakeAI.globals.source_path is not None and DeepFakeAI.globals.target_path is not None and DeepFakeAI.globals.output_path is not None + DeepFakeAI.globals.frame_processors = args.frame_processors + DeepFakeAI.globals.ui_layouts = args.ui_layouts + DeepFakeAI.globals.keep_fps = args.keep_fps + DeepFakeAI.globals.keep_temp = args.keep_temp + DeepFakeAI.globals.skip_audio = args.skip_audio + DeepFakeAI.globals.face_recognition = args.face_recognition + DeepFakeAI.globals.face_analyser_direction = args.face_analyser_direction + DeepFakeAI.globals.face_analyser_age = args.face_analyser_age + DeepFakeAI.globals.face_analyser_gender = args.face_analyser_gender + DeepFakeAI.globals.reference_face_position = args.reference_face_position + DeepFakeAI.globals.reference_frame_number = args.reference_frame_number + DeepFakeAI.globals.reference_face_distance = args.reference_face_distance + DeepFakeAI.globals.trim_frame_start = args.trim_frame_start + DeepFakeAI.globals.trim_frame_end = args.trim_frame_end + DeepFakeAI.globals.temp_frame_format = args.temp_frame_format + DeepFakeAI.globals.temp_frame_quality = args.temp_frame_quality + DeepFakeAI.globals.output_video_encoder = args.output_video_encoder + DeepFakeAI.globals.output_video_quality = args.output_video_quality + DeepFakeAI.globals.max_memory = args.max_memory + DeepFakeAI.globals.execution_providers = decode_execution_providers(args.execution_providers) + DeepFakeAI.globals.execution_thread_count = args.execution_thread_count + DeepFakeAI.globals.execution_queue_count = args.execution_queue_count def suggest_execution_providers_choices() -> List[str]: @@ -104,10 +104,10 @@ def limit_resources() -> None: tensorflow.config.experimental.VirtualDeviceConfiguration(memory_limit = 1024) ]) # limit memory usage - if facefusion.globals.max_memory: - memory = facefusion.globals.max_memory * 1024 ** 3 + if DeepFakeAI.globals.max_memory: + memory = DeepFakeAI.globals.max_memory * 1024 ** 3 if platform.system().lower() == 'darwin': - memory = facefusion.globals.max_memory * 1024 ** 6 + memory = DeepFakeAI.globals.max_memory * 1024 ** 6 if platform.system().lower() == 'windows': import ctypes kernel32 = ctypes.windll.kernel32 # type: ignore[attr-defined] @@ -132,69 +132,69 @@ def pre_check() -> bool: def process_image() -> None: - if predict_image(facefusion.globals.target_path): + if predict_image(DeepFakeAI.globals.target_path): return - shutil.copy2(facefusion.globals.target_path, facefusion.globals.output_path) + shutil.copy2(DeepFakeAI.globals.target_path, DeepFakeAI.globals.output_path) # process frame - for frame_processor_module in get_frame_processors_modules(facefusion.globals.frame_processors): + for frame_processor_module in get_frame_processors_modules(DeepFakeAI.globals.frame_processors): update_status(wording.get('processing'), frame_processor_module.NAME) - frame_processor_module.process_image(facefusion.globals.source_path, facefusion.globals.output_path, facefusion.globals.output_path) + frame_processor_module.process_image(DeepFakeAI.globals.source_path, DeepFakeAI.globals.output_path, DeepFakeAI.globals.output_path) frame_processor_module.post_process() # validate image - if is_image(facefusion.globals.target_path): + if is_image(DeepFakeAI.globals.target_path): update_status(wording.get('processing_image_succeed')) else: update_status(wording.get('processing_image_failed')) def process_video() -> None: - if predict_video(facefusion.globals.target_path): + if predict_video(DeepFakeAI.globals.target_path): return - fps = detect_fps(facefusion.globals.target_path) if facefusion.globals.keep_fps else 25.0 + fps = detect_fps(DeepFakeAI.globals.target_path) if DeepFakeAI.globals.keep_fps else 25.0 update_status(wording.get('creating_temp')) - create_temp(facefusion.globals.target_path) + create_temp(DeepFakeAI.globals.target_path) # extract frames update_status(wording.get('extracting_frames_fps').format(fps = fps)) - extract_frames(facefusion.globals.target_path, fps) + extract_frames(DeepFakeAI.globals.target_path, fps) # process frame - temp_frame_paths = get_temp_frame_paths(facefusion.globals.target_path) + temp_frame_paths = get_temp_frame_paths(DeepFakeAI.globals.target_path) if temp_frame_paths: - for frame_processor_module in get_frame_processors_modules(facefusion.globals.frame_processors): + for frame_processor_module in get_frame_processors_modules(DeepFakeAI.globals.frame_processors): update_status(wording.get('processing'), frame_processor_module.NAME) - frame_processor_module.process_video(facefusion.globals.source_path, temp_frame_paths) + frame_processor_module.process_video(DeepFakeAI.globals.source_path, temp_frame_paths) frame_processor_module.post_process() else: update_status(wording.get('temp_frames_not_found')) return # create video update_status(wording.get('creating_video_fps').format(fps = fps)) - if not create_video(facefusion.globals.target_path, fps): + if not create_video(DeepFakeAI.globals.target_path, fps): update_status(wording.get('creating_video_failed')) return # handle audio - if facefusion.globals.skip_audio: + if DeepFakeAI.globals.skip_audio: update_status(wording.get('skipping_audio')) - move_temp(facefusion.globals.target_path, facefusion.globals.output_path) + move_temp(DeepFakeAI.globals.target_path, DeepFakeAI.globals.output_path) else: update_status(wording.get('restoring_audio')) - restore_audio(facefusion.globals.target_path, facefusion.globals.output_path) + restore_audio(DeepFakeAI.globals.target_path, DeepFakeAI.globals.output_path) # clear temp update_status(wording.get('clearing_temp')) - clear_temp(facefusion.globals.target_path) + clear_temp(DeepFakeAI.globals.target_path) # validate video - if is_video(facefusion.globals.target_path): + if is_video(DeepFakeAI.globals.target_path): update_status(wording.get('processing_video_succeed')) else: update_status(wording.get('processing_video_failed')) def conditional_process() -> None: - for frame_processor_module in get_frame_processors_modules(facefusion.globals.frame_processors): + for frame_processor_module in get_frame_processors_modules(DeepFakeAI.globals.frame_processors): if not frame_processor_module.pre_process(): return - if is_image(facefusion.globals.target_path): + if is_image(DeepFakeAI.globals.target_path): process_image() - if is_video(facefusion.globals.target_path): + if is_video(DeepFakeAI.globals.target_path): process_video() @@ -204,19 +204,19 @@ def run() -> None: # pre check if not pre_check(): return - for frame_processor in get_frame_processors_modules(facefusion.globals.frame_processors): + for frame_processor in get_frame_processors_modules(DeepFakeAI.globals.frame_processors): if not frame_processor.pre_check(): return # process or launch - if facefusion.globals.headless: + if DeepFakeAI.globals.headless: conditional_process() else: - import facefusion.uis.core as ui + import DeepFakeAI.uis.core as ui ui.launch() def destroy() -> None: - if facefusion.globals.target_path: - clear_temp(facefusion.globals.target_path) + if DeepFakeAI.globals.target_path: + clear_temp(DeepFakeAI.globals.target_path) sys.exit() diff --git a/DeepFakeAI/face_analyser.py b/DeepFakeAI/face_analyser.py index 1929840eb8efac04b9a223d9b03296f105ae77d7..df8f6c205078da7dd40a5499db21a5a215cc3498 100644 --- a/DeepFakeAI/face_analyser.py +++ b/DeepFakeAI/face_analyser.py @@ -3,8 +3,8 @@ from typing import Any, Optional, List import insightface import numpy -import facefusion.globals -from facefusion.typing import Frame, Face, FaceAnalyserDirection, FaceAnalyserAge, FaceAnalyserGender +import DeepFakeAI.globals +from DeepFakeAI.typing import Frame, Face, FaceAnalyserDirection, FaceAnalyserAge, FaceAnalyserGender FACE_ANALYSER = None THREAD_LOCK = threading.Lock() @@ -15,7 +15,7 @@ def get_face_analyser() -> Any: with THREAD_LOCK: if FACE_ANALYSER is None: - FACE_ANALYSER = insightface.app.FaceAnalysis(name = 'buffalo_l', providers = facefusion.globals.execution_providers) + FACE_ANALYSER = insightface.app.FaceAnalysis(name = 'buffalo_l', providers = DeepFakeAI.globals.execution_providers) FACE_ANALYSER.prepare(ctx_id = 0) return FACE_ANALYSER @@ -39,12 +39,12 @@ def get_one_face(frame : Frame, position : int = 0) -> Optional[Face]: def get_many_faces(frame : Frame) -> List[Face]: try: faces = get_face_analyser().get(frame) - if facefusion.globals.face_analyser_direction: - faces = sort_by_direction(faces, facefusion.globals.face_analyser_direction) - if facefusion.globals.face_analyser_age: - faces = filter_by_age(faces, facefusion.globals.face_analyser_age) - if facefusion.globals.face_analyser_gender: - faces = filter_by_gender(faces, facefusion.globals.face_analyser_gender) + if DeepFakeAI.globals.face_analyser_direction: + faces = sort_by_direction(faces, DeepFakeAI.globals.face_analyser_direction) + if DeepFakeAI.globals.face_analyser_age: + faces = filter_by_age(faces, DeepFakeAI.globals.face_analyser_age) + if DeepFakeAI.globals.face_analyser_gender: + faces = filter_by_gender(faces, DeepFakeAI.globals.face_analyser_gender) return faces except (AttributeError, ValueError): return [] diff --git a/DeepFakeAI/face_reference.py b/DeepFakeAI/face_reference.py index 72281fe6ad8dfaa7d35382011686761752077a94..497eb384752c945886259b6814170562c99e5d3b 100644 --- a/DeepFakeAI/face_reference.py +++ b/DeepFakeAI/face_reference.py @@ -1,6 +1,6 @@ from typing import Optional -from facefusion.typing import Face +from DeepFakeAI.typing import Face FACE_REFERENCE = None diff --git a/DeepFakeAI/globals.py b/DeepFakeAI/globals.py index d88ec95e34345f2a528e4e78e29cc1ce8af845a8..aa63522665497a0301cd90b00e0ccc5a1b87ae2e 100644 --- a/DeepFakeAI/globals.py +++ b/DeepFakeAI/globals.py @@ -1,6 +1,6 @@ from typing import List, Optional -from facefusion.typing import FaceRecognition, FaceAnalyserDirection, FaceAnalyserAge, FaceAnalyserGender, TempFrameFormat +from DeepFakeAI.typing import FaceRecognition, FaceAnalyserDirection, FaceAnalyserAge, FaceAnalyserGender, TempFrameFormat source_path : Optional[str] = None target_path : Optional[str] = None diff --git a/DeepFakeAI/metadata.py b/DeepFakeAI/metadata.py index b6f1ac56f45ba1c9c276ed2c179962a92b59b998..60e28114ef71969fc97a4586813aad85784e0cd7 100644 --- a/DeepFakeAI/metadata.py +++ b/DeepFakeAI/metadata.py @@ -5,7 +5,7 @@ METADATA =\ 'version': '1.0.0', 'license': 'MIT', 'author': 'Henry Ruhs', - 'url': 'https://facefusion.io' + 'url': 'https://DeepFakeAI.io' } diff --git a/DeepFakeAI/predictor.py b/DeepFakeAI/predictor.py index 75b6ed4d328db9f991bbeb7c1ae425a62b4fbacb..581b26e5995b92de64498386270868014748446d 100644 --- a/DeepFakeAI/predictor.py +++ b/DeepFakeAI/predictor.py @@ -4,7 +4,7 @@ import opennsfw2 from PIL import Image from keras import Model -from facefusion.typing import Frame +from DeepFakeAI.typing import Frame PREDICTOR = None THREAD_LOCK = threading.Lock() diff --git a/DeepFakeAI/processors/__pycache__/__init__.cpython-310.pyc b/DeepFakeAI/processors/__pycache__/__init__.cpython-310.pyc index 85a762e3da95b4ee66eb6d3bb914fb3db928c50f..a63dc8d7b97fde386a2299102d6439b7457ef40e 100644 Binary files a/DeepFakeAI/processors/__pycache__/__init__.cpython-310.pyc and b/DeepFakeAI/processors/__pycache__/__init__.cpython-310.pyc differ diff --git a/DeepFakeAI/processors/frame/__pycache__/__init__.cpython-310.pyc b/DeepFakeAI/processors/frame/__pycache__/__init__.cpython-310.pyc index 195ebe452a6f6bbc778c791cfce0e0247bdf6d71..7ecca3406f4ae7e13444f3b775c841afc694e716 100644 Binary files a/DeepFakeAI/processors/frame/__pycache__/__init__.cpython-310.pyc and b/DeepFakeAI/processors/frame/__pycache__/__init__.cpython-310.pyc differ diff --git a/DeepFakeAI/processors/frame/__pycache__/core.cpython-310.pyc b/DeepFakeAI/processors/frame/__pycache__/core.cpython-310.pyc index 6e2bc471d7788483c8f1a04adb250bd3d99a7ecf..5582825d675d2d0afd5ca8c46fc349362a1ba0c8 100644 Binary files a/DeepFakeAI/processors/frame/__pycache__/core.cpython-310.pyc and b/DeepFakeAI/processors/frame/__pycache__/core.cpython-310.pyc differ diff --git a/DeepFakeAI/processors/frame/core.py b/DeepFakeAI/processors/frame/core.py index 73165e2f4eecbf6993b984ce85abcf16ed4b3657..8a44cb2413b53b88dec2d65667ef0e8b2fe11e72 100644 --- a/DeepFakeAI/processors/frame/core.py +++ b/DeepFakeAI/processors/frame/core.py @@ -8,8 +8,8 @@ from types import ModuleType from typing import Any, List, Callable from tqdm import tqdm -import facefusion.globals -from facefusion import wording +import DeepFakeAI.globals +from DeepFakeAI import wording FRAME_PROCESSORS_MODULES : List[ModuleType] = [] FRAME_PROCESSORS_METHODS =\ @@ -28,7 +28,7 @@ FRAME_PROCESSORS_METHODS =\ def load_frame_processor_module(frame_processor : str) -> Any: try: - frame_processor_module = importlib.import_module('facefusion.processors.frame.modules.' + frame_processor) + frame_processor_module = importlib.import_module('DeepFakeAI.processors.frame.modules.' + frame_processor) for method_name in FRAME_PROCESSORS_METHODS: if not hasattr(frame_processor_module, method_name): raise NotImplementedError @@ -52,16 +52,16 @@ def get_frame_processors_modules(frame_processors : List[str]) -> List[ModuleTyp def clear_frame_processors_modules() -> None: global FRAME_PROCESSORS_MODULES - for frame_processor_module in get_frame_processors_modules(facefusion.globals.frame_processors): + for frame_processor_module in get_frame_processors_modules(DeepFakeAI.globals.frame_processors): frame_processor_module.clear_frame_processor() FRAME_PROCESSORS_MODULES = [] def multi_process_frame(source_path : str, temp_frame_paths : List[str], process_frames: Callable[[str, List[str], Any], None], update: Callable[[], None]) -> None: - with ThreadPoolExecutor(max_workers = facefusion.globals.execution_thread_count) as executor: + with ThreadPoolExecutor(max_workers = DeepFakeAI.globals.execution_thread_count) as executor: futures = [] queue = create_queue(temp_frame_paths) - queue_per_future = max(len(temp_frame_paths) // facefusion.globals.execution_thread_count * facefusion.globals.execution_queue_count, 1) + queue_per_future = max(len(temp_frame_paths) // DeepFakeAI.globals.execution_thread_count * DeepFakeAI.globals.execution_queue_count, 1) while not queue.empty(): future = executor.submit(process_frames, source_path, pick_queue(queue, queue_per_future), update) futures.append(future) @@ -97,17 +97,17 @@ def update_progress(progress : Any = None) -> None: progress.set_postfix( { 'memory_usage': '{:.2f}'.format(memory_usage).zfill(5) + 'GB', - 'execution_providers': facefusion.globals.execution_providers, - 'execution_thread_count': facefusion.globals.execution_thread_count, - 'execution_queue_count': facefusion.globals.execution_queue_count + 'execution_providers': DeepFakeAI.globals.execution_providers, + 'execution_thread_count': DeepFakeAI.globals.execution_thread_count, + 'execution_queue_count': DeepFakeAI.globals.execution_queue_count }) progress.refresh() progress.update(1) def get_device() -> str: - if 'CUDAExecutionProvider' in facefusion.globals.execution_providers: + if 'CUDAExecutionProvider' in DeepFakeAI.globals.execution_providers: return 'cuda' - if 'CoreMLExecutionProvider' in facefusion.globals.execution_providers: + if 'CoreMLExecutionProvider' in DeepFakeAI.globals.execution_providers: return 'mps' return 'cpu' diff --git a/DeepFakeAI/processors/frame/modules/__pycache__/__init__.cpython-310.pyc b/DeepFakeAI/processors/frame/modules/__pycache__/__init__.cpython-310.pyc index 310f8f765e398fff96cf1b7e8a5f376285e2ca27..bbb05ebcf0a34b48cf9942c3ae2ac3390ba1de85 100644 Binary files a/DeepFakeAI/processors/frame/modules/__pycache__/__init__.cpython-310.pyc and b/DeepFakeAI/processors/frame/modules/__pycache__/__init__.cpython-310.pyc differ diff --git a/DeepFakeAI/processors/frame/modules/__pycache__/face_swapper.cpython-310.pyc b/DeepFakeAI/processors/frame/modules/__pycache__/face_swapper.cpython-310.pyc index dbab8feea0852b5de97608cf8b8de5a4bd174cc5..7c48ec61eac989300061d970d0ce803824ddcd1a 100644 Binary files a/DeepFakeAI/processors/frame/modules/__pycache__/face_swapper.cpython-310.pyc and b/DeepFakeAI/processors/frame/modules/__pycache__/face_swapper.cpython-310.pyc differ diff --git a/DeepFakeAI/processors/frame/modules/face_enhancer.py b/DeepFakeAI/processors/frame/modules/face_enhancer.py index 7c076125c9daef8e9f1b5199998619e10dba8d4e..2d99f8d0530ff9719f3dba40af88af23bfc67338 100644 --- a/DeepFakeAI/processors/frame/modules/face_enhancer.py +++ b/DeepFakeAI/processors/frame/modules/face_enhancer.py @@ -3,13 +3,13 @@ import cv2 import threading from gfpgan.utils import GFPGANer -import facefusion.globals -import facefusion.processors.frame.core as frame_processors -from facefusion import wording -from facefusion.core import update_status -from facefusion.face_analyser import get_many_faces -from facefusion.typing import Frame, Face -from facefusion.utilities import conditional_download, resolve_relative_path, is_image, is_video +import DeepFakeAI.globals +import DeepFakeAI.processors.frame.core as frame_processors +from DeepFakeAI import wording +from DeepFakeAI.core import update_status +from DeepFakeAI.face_analyser import get_many_faces +from DeepFakeAI.typing import Frame, Face +from DeepFakeAI.utilities import conditional_download, resolve_relative_path, is_image, is_video FRAME_PROCESSOR = None THREAD_SEMAPHORE = threading.Semaphore() @@ -39,12 +39,12 @@ def clear_frame_processor() -> None: def pre_check() -> bool: download_directory_path = resolve_relative_path('../.assets/models') - conditional_download(download_directory_path, ['https://github.com/facefusion/facefusion-assets/releases/download/models/GFPGANv1.4.pth']) + conditional_download(download_directory_path, ['https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/models/GFPGANv1.4.pth']) return True def pre_process() -> bool: - if not is_image(facefusion.globals.target_path) and not is_video(facefusion.globals.target_path): + if not is_image(DeepFakeAI.globals.target_path) and not is_video(DeepFakeAI.globals.target_path): update_status(wording.get('select_image_or_video_target') + wording.get('exclamation_mark'), NAME) return False return True @@ -97,4 +97,4 @@ def process_image(source_path : str, target_path : str, output_path : str) -> No def process_video(source_path : str, temp_frame_paths : List[str]) -> None: - facefusion.processors.frame.core.process_video(None, temp_frame_paths, process_frames) + DeepFakeAI.processors.frame.core.process_video(None, temp_frame_paths, process_frames) diff --git a/DeepFakeAI/processors/frame/modules/face_swapper.py b/DeepFakeAI/processors/frame/modules/face_swapper.py index 003bebb4173155aca2b77683e273547a9080e380..4a3d024fbe66148cafdb2dadb61a3fd3ee0696cb 100644 --- a/DeepFakeAI/processors/frame/modules/face_swapper.py +++ b/DeepFakeAI/processors/frame/modules/face_swapper.py @@ -3,14 +3,14 @@ import cv2 import insightface import threading -import facefusion.globals -import facefusion.processors.frame.core as frame_processors -from facefusion import wording -from facefusion.core import update_status -from facefusion.face_analyser import get_one_face, get_many_faces, find_similar_faces -from facefusion.face_reference import get_face_reference, set_face_reference -from facefusion.typing import Face, Frame -from facefusion.utilities import conditional_download, resolve_relative_path, is_image, is_video +import DeepFakeAI.globals +import DeepFakeAI.processors.frame.core as frame_processors +from DeepFakeAI import wording +from DeepFakeAI.core import update_status +from DeepFakeAI.face_analyser import get_one_face, get_many_faces, find_similar_faces +from DeepFakeAI.face_reference import get_face_reference, set_face_reference +from DeepFakeAI.typing import Face, Frame +from DeepFakeAI.utilities import conditional_download, resolve_relative_path, is_image, is_video FRAME_PROCESSOR = None THREAD_LOCK = threading.Lock() @@ -23,7 +23,7 @@ def get_frame_processor() -> Any: with THREAD_LOCK: if FRAME_PROCESSOR is None: model_path = resolve_relative_path('../.assets/models/inswapper_128.onnx') - FRAME_PROCESSOR = insightface.model_zoo.get_model(model_path, providers = facefusion.globals.execution_providers) + FRAME_PROCESSOR = insightface.model_zoo.get_model(model_path, providers = DeepFakeAI.globals.execution_providers) return FRAME_PROCESSOR @@ -35,18 +35,18 @@ def clear_frame_processor() -> None: def pre_check() -> bool: download_directory_path = resolve_relative_path('../.assets/models') - conditional_download(download_directory_path, ['https://github.com/facefusion/facefusion-assets/releases/download/models/inswapper_128.onnx']) + conditional_download(download_directory_path, ['https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/models/inswapper_128.onnx']) return True def pre_process() -> bool: - if not is_image(facefusion.globals.source_path): + if not is_image(DeepFakeAI.globals.source_path): update_status(wording.get('select_image_source') + wording.get('exclamation_mark'), NAME) return False - elif not get_one_face(cv2.imread(facefusion.globals.source_path)): + elif not get_one_face(cv2.imread(DeepFakeAI.globals.source_path)): update_status(wording.get('no_source_face_detected') + wording.get('exclamation_mark'), NAME) return False - if not is_image(facefusion.globals.target_path) and not is_video(facefusion.globals.target_path): + if not is_image(DeepFakeAI.globals.target_path) and not is_video(DeepFakeAI.globals.target_path): update_status(wording.get('select_image_or_video_target') + wording.get('exclamation_mark'), NAME) return False return True @@ -61,12 +61,12 @@ def swap_face(source_face : Face, target_face : Face, temp_frame : Frame) -> Fra def process_frame(source_face : Face, reference_face : Face, temp_frame : Frame) -> Frame: - if 'reference' in facefusion.globals.face_recognition: - similar_faces = find_similar_faces(temp_frame, reference_face, facefusion.globals.reference_face_distance) + if 'reference' in DeepFakeAI.globals.face_recognition: + similar_faces = find_similar_faces(temp_frame, reference_face, DeepFakeAI.globals.reference_face_distance) if similar_faces: for similar_face in similar_faces: temp_frame = swap_face(source_face, similar_face, temp_frame) - if 'many' in facefusion.globals.face_recognition: + if 'many' in DeepFakeAI.globals.face_recognition: many_faces = get_many_faces(temp_frame) if many_faces: for target_face in many_faces: @@ -76,7 +76,7 @@ def process_frame(source_face : Face, reference_face : Face, temp_frame : Frame) def process_frames(source_path : str, temp_frame_paths : List[str], update: Callable[[], None]) -> None: source_face = get_one_face(cv2.imread(source_path)) - reference_face = get_face_reference() if 'reference' in facefusion.globals.face_recognition else None + reference_face = get_face_reference() if 'reference' in DeepFakeAI.globals.face_recognition else None for temp_frame_path in temp_frame_paths: temp_frame = cv2.imread(temp_frame_path) result_frame = process_frame(source_face, reference_face, temp_frame) @@ -88,7 +88,7 @@ def process_frames(source_path : str, temp_frame_paths : List[str], update: Call def process_image(source_path : str, target_path : str, output_path : str) -> None: source_face = get_one_face(cv2.imread(source_path)) target_frame = cv2.imread(target_path) - reference_face = get_one_face(target_frame, facefusion.globals.reference_face_position) if 'reference' in facefusion.globals.face_recognition else None + reference_face = get_one_face(target_frame, DeepFakeAI.globals.reference_face_position) if 'reference' in DeepFakeAI.globals.face_recognition else None result_frame = process_frame(source_face, reference_face, target_frame) cv2.imwrite(output_path, result_frame) @@ -99,7 +99,7 @@ def process_video(source_path : str, temp_frame_paths : List[str]) -> None: def conditional_set_face_reference(temp_frame_paths : List[str]) -> None: - if 'reference' in facefusion.globals.face_recognition and not get_face_reference(): - reference_frame = cv2.imread(temp_frame_paths[facefusion.globals.reference_frame_number]) - reference_face = get_one_face(reference_frame, facefusion.globals.reference_face_position) + if 'reference' in DeepFakeAI.globals.face_recognition and not get_face_reference(): + reference_frame = cv2.imread(temp_frame_paths[DeepFakeAI.globals.reference_frame_number]) + reference_face = get_one_face(reference_frame, DeepFakeAI.globals.reference_face_position) set_face_reference(reference_face) diff --git a/DeepFakeAI/processors/frame/modules/frame_enhancer.py b/DeepFakeAI/processors/frame/modules/frame_enhancer.py index 21f51ab944a8e79f94e348aa46988c5b0cbd9076..c8df474272e4b58488720aac6eb46c6327cdcc32 100644 --- a/DeepFakeAI/processors/frame/modules/frame_enhancer.py +++ b/DeepFakeAI/processors/frame/modules/frame_enhancer.py @@ -4,9 +4,9 @@ import threading from basicsr.archs.rrdbnet_arch import RRDBNet from realesrgan import RealESRGANer -import facefusion.processors.frame.core as frame_processors -from facefusion.typing import Frame, Face -from facefusion.utilities import conditional_download, resolve_relative_path +import DeepFakeAI.processors.frame.core as frame_processors +from DeepFakeAI.typing import Frame, Face +from DeepFakeAI.utilities import conditional_download, resolve_relative_path FRAME_PROCESSOR = None THREAD_SEMAPHORE = threading.Semaphore() @@ -47,7 +47,7 @@ def clear_frame_processor() -> None: def pre_check() -> bool: download_directory_path = resolve_relative_path('../.assets/models') - conditional_download(download_directory_path, ['https://github.com/facefusion/facefusion-assets/releases/download/models/RealESRGAN_x4plus.pth']) + conditional_download(download_directory_path, ['https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/models/RealESRGAN_x4plus.pth']) return True diff --git a/DeepFakeAI/uis/__pycache__/__init__.cpython-310.pyc b/DeepFakeAI/uis/__pycache__/__init__.cpython-310.pyc index 88430855f8a7e101b63ccd87cc52762c294c0764..154c1087c9bd41e51fb80521d0b0ff8b0ee40985 100644 Binary files a/DeepFakeAI/uis/__pycache__/__init__.cpython-310.pyc and b/DeepFakeAI/uis/__pycache__/__init__.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/__pycache__/core.cpython-310.pyc b/DeepFakeAI/uis/__pycache__/core.cpython-310.pyc index e540a0b285a982ad80e719250e7533852c1e230e..1971e9abba1700de5e50fd8972f849ad1ede2545 100644 Binary files a/DeepFakeAI/uis/__pycache__/core.cpython-310.pyc and b/DeepFakeAI/uis/__pycache__/core.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/__pycache__/typing.cpython-310.pyc b/DeepFakeAI/uis/__pycache__/typing.cpython-310.pyc index 9c309212d3fd4ff4717aac2c0abd1c6fd48b482d..9bdf0d98188d0e2988eda5b4206582537763ae51 100644 Binary files a/DeepFakeAI/uis/__pycache__/typing.cpython-310.pyc and b/DeepFakeAI/uis/__pycache__/typing.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/__pycache__/__init__.cpython-310.pyc b/DeepFakeAI/uis/components/__pycache__/__init__.cpython-310.pyc index 218689ccabd6afffc212796346d5c3953e4abebe..06ffca9c6f9edc17b8a1468f5ca33001a1921138 100644 Binary files a/DeepFakeAI/uis/components/__pycache__/__init__.cpython-310.pyc and b/DeepFakeAI/uis/components/__pycache__/__init__.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/__pycache__/about.cpython-310.pyc b/DeepFakeAI/uis/components/__pycache__/about.cpython-310.pyc index 7dac7b1d459f492fe041b50527fb798f4bf8a680..34753af3bf8da5d9a7b39199b8fd5eb7cc68d31c 100644 Binary files a/DeepFakeAI/uis/components/__pycache__/about.cpython-310.pyc and b/DeepFakeAI/uis/components/__pycache__/about.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/__pycache__/execution.cpython-310.pyc b/DeepFakeAI/uis/components/__pycache__/execution.cpython-310.pyc index 313f2d8fef5006fa7f276e0ac8df65395f569bf8..0f7122bd190c75ddf55facf8c81b298d5fde3933 100644 Binary files a/DeepFakeAI/uis/components/__pycache__/execution.cpython-310.pyc and b/DeepFakeAI/uis/components/__pycache__/execution.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/__pycache__/face_analyser.cpython-310.pyc b/DeepFakeAI/uis/components/__pycache__/face_analyser.cpython-310.pyc index 73dd9e4add8205157105f8ae03fbd228d299f41c..e2bfa8ea14249259a72037acb97e75135d93b874 100644 Binary files a/DeepFakeAI/uis/components/__pycache__/face_analyser.cpython-310.pyc and b/DeepFakeAI/uis/components/__pycache__/face_analyser.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/__pycache__/face_selector.cpython-310.pyc b/DeepFakeAI/uis/components/__pycache__/face_selector.cpython-310.pyc index a500abd49fc6bed6cbfa537b1618dc87a2b1e3ff..61150fb74aef952732869192de3b394c81b5bc70 100644 Binary files a/DeepFakeAI/uis/components/__pycache__/face_selector.cpython-310.pyc and b/DeepFakeAI/uis/components/__pycache__/face_selector.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/__pycache__/output.cpython-310.pyc b/DeepFakeAI/uis/components/__pycache__/output.cpython-310.pyc index 9dc2510cf2b96b90984d973e2e552bfd7365fb06..c70776b99c2a488ea0f464b74c881ccc0817e8c7 100644 Binary files a/DeepFakeAI/uis/components/__pycache__/output.cpython-310.pyc and b/DeepFakeAI/uis/components/__pycache__/output.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/__pycache__/output_settings.cpython-310.pyc b/DeepFakeAI/uis/components/__pycache__/output_settings.cpython-310.pyc index 983cef80c185ebafaa252c052dc62b9e658c714d..80e01cf4bdbcb467285ab8636afd916de163ae0c 100644 Binary files a/DeepFakeAI/uis/components/__pycache__/output_settings.cpython-310.pyc and b/DeepFakeAI/uis/components/__pycache__/output_settings.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/__pycache__/preview.cpython-310.pyc b/DeepFakeAI/uis/components/__pycache__/preview.cpython-310.pyc index 4b6891e222567ec066938462796f526016e43a5f..374ff6221358d5a21b7dcef0caae7c36a49ccf56 100644 Binary files a/DeepFakeAI/uis/components/__pycache__/preview.cpython-310.pyc and b/DeepFakeAI/uis/components/__pycache__/preview.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/__pycache__/processors.cpython-310.pyc b/DeepFakeAI/uis/components/__pycache__/processors.cpython-310.pyc index 8ac92c9fe9641e37ec3a7c1b066b5c75d2904401..b947b12367bb9b3c5455d37cb7dfb99704f53a4b 100644 Binary files a/DeepFakeAI/uis/components/__pycache__/processors.cpython-310.pyc and b/DeepFakeAI/uis/components/__pycache__/processors.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/__pycache__/settings.cpython-310.pyc b/DeepFakeAI/uis/components/__pycache__/settings.cpython-310.pyc index 2ab9b19a6293d2dc6ba2a0f1e6953418676494d6..ad71ea15e2aecf116f562bca3956a0d29e9e2b91 100644 Binary files a/DeepFakeAI/uis/components/__pycache__/settings.cpython-310.pyc and b/DeepFakeAI/uis/components/__pycache__/settings.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/__pycache__/source.cpython-310.pyc b/DeepFakeAI/uis/components/__pycache__/source.cpython-310.pyc index f71c2e4aa379575ec3c6ebe81e32a0cde1ca821a..e9d6d14c9121d6a15cb56735c98f84d8f6d94898 100644 Binary files a/DeepFakeAI/uis/components/__pycache__/source.cpython-310.pyc and b/DeepFakeAI/uis/components/__pycache__/source.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/__pycache__/target.cpython-310.pyc b/DeepFakeAI/uis/components/__pycache__/target.cpython-310.pyc index ab096ba1051920658b1589104c1adacf5ee0fe03..a29c5d14ba9db983ad383385097646289ffc1182 100644 Binary files a/DeepFakeAI/uis/components/__pycache__/target.cpython-310.pyc and b/DeepFakeAI/uis/components/__pycache__/target.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/__pycache__/temp_frame.cpython-310.pyc b/DeepFakeAI/uis/components/__pycache__/temp_frame.cpython-310.pyc index 1e075b585ca581f4ac9ca7ee8ae3330dcfb55b51..a449dbc5e1b45d9b8d3b9451015e1d7162df1848 100644 Binary files a/DeepFakeAI/uis/components/__pycache__/temp_frame.cpython-310.pyc and b/DeepFakeAI/uis/components/__pycache__/temp_frame.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/__pycache__/trim_frame.cpython-310.pyc b/DeepFakeAI/uis/components/__pycache__/trim_frame.cpython-310.pyc index 24efa8cfb068eb2437deaadd6c459c5b47b1cd4c..9f05806e8732f19fb230ae9c055de22adc43c9e3 100644 Binary files a/DeepFakeAI/uis/components/__pycache__/trim_frame.cpython-310.pyc and b/DeepFakeAI/uis/components/__pycache__/trim_frame.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/components/about.py b/DeepFakeAI/uis/components/about.py index e6caffaf324d8e12dceaaeca2528ee4ecc01ecf8..8e7beed10c76eb9d3d6900563aa2be23897beb28 100644 --- a/DeepFakeAI/uis/components/about.py +++ b/DeepFakeAI/uis/components/about.py @@ -1,7 +1,7 @@ from typing import Optional import gradio -from facefusion import metadata +from DeepFakeAI import metadata ABOUT_HTML : Optional[gradio.HTML] = None diff --git a/DeepFakeAI/uis/components/benchmark.py b/DeepFakeAI/uis/components/benchmark.py index b56958e29169d1f0510da3a7a8a1704ce8542a29..450cdd0dc82cf74fa203698b66b8860d913917a8 100644 --- a/DeepFakeAI/uis/components/benchmark.py +++ b/DeepFakeAI/uis/components/benchmark.py @@ -4,12 +4,12 @@ import tempfile import statistics import gradio -import facefusion.globals -from facefusion import wording -from facefusion.capturer import get_video_frame_total -from facefusion.core import conditional_process -from facefusion.uis.typing import Update -from facefusion.utilities import normalize_output_path, clear_temp +import DeepFakeAI.globals +from DeepFakeAI import wording +from DeepFakeAI.capturer import get_video_frame_total +from DeepFakeAI.core import conditional_process +from DeepFakeAI.uis.typing import Update +from DeepFakeAI.utilities import normalize_output_path, clear_temp BENCHMARK_RESULT_DATAFRAME : Optional[gradio.Dataframe] = None BENCHMARK_CYCLES_SLIDER : Optional[gradio.Button] = None @@ -65,7 +65,7 @@ def listen() -> None: def update(benchmark_cycles : int) -> Update: - facefusion.globals.source_path = '.assets/examples/source.jpg' + DeepFakeAI.globals.source_path = '.assets/examples/source.jpg' target_paths =\ [ '.assets/examples/target-240p.mp4', @@ -84,9 +84,9 @@ def benchmark(target_path : str, benchmark_cycles : int) -> List[Any]: process_times = [] total_fps = 0.0 for i in range(benchmark_cycles + 1): - facefusion.globals.target_path = target_path - facefusion.globals.output_path = normalize_output_path(facefusion.globals.source_path, facefusion.globals.target_path, tempfile.gettempdir()) - video_frame_total = get_video_frame_total(facefusion.globals.target_path) + DeepFakeAI.globals.target_path = target_path + DeepFakeAI.globals.output_path = normalize_output_path(DeepFakeAI.globals.source_path, DeepFakeAI.globals.target_path, tempfile.gettempdir()) + video_frame_total = get_video_frame_total(DeepFakeAI.globals.target_path) start_time = time.perf_counter() conditional_process() end_time = time.perf_counter() @@ -101,7 +101,7 @@ def benchmark(target_path : str, benchmark_cycles : int) -> List[Any]: relative_fps = round(total_fps / benchmark_cycles, 2) return\ [ - facefusion.globals.target_path, + DeepFakeAI.globals.target_path, benchmark_cycles, average_run, fastest_run, @@ -111,6 +111,6 @@ def benchmark(target_path : str, benchmark_cycles : int) -> List[Any]: def clear() -> Update: - if facefusion.globals.target_path: - clear_temp(facefusion.globals.target_path) + if DeepFakeAI.globals.target_path: + clear_temp(DeepFakeAI.globals.target_path) return gradio.update(value = None) diff --git a/DeepFakeAI/uis/components/execution.py b/DeepFakeAI/uis/components/execution.py index 78abc1dfe2a813d8c747d975089191243c560541..23de9f5d50b365eeeee50db56af8cc78e6eccf73 100644 --- a/DeepFakeAI/uis/components/execution.py +++ b/DeepFakeAI/uis/components/execution.py @@ -2,12 +2,12 @@ from typing import List, Optional import gradio import onnxruntime -import facefusion.globals -from facefusion import wording -from facefusion.face_analyser import clear_face_analyser -from facefusion.processors.frame.core import clear_frame_processors_modules -from facefusion.uis.typing import Update -from facefusion.utilities import encode_execution_providers, decode_execution_providers +import DeepFakeAI.globals +from DeepFakeAI import wording +from DeepFakeAI.face_analyser import clear_face_analyser +from DeepFakeAI.processors.frame.core import clear_frame_processors_modules +from DeepFakeAI.uis.typing import Update +from DeepFakeAI.utilities import encode_execution_providers, decode_execution_providers EXECUTION_PROVIDERS_CHECKBOX_GROUP : Optional[gradio.CheckboxGroup] = None EXECUTION_THREAD_COUNT_SLIDER : Optional[gradio.Slider] = None @@ -23,18 +23,18 @@ def render() -> None: EXECUTION_PROVIDERS_CHECKBOX_GROUP = gradio.CheckboxGroup( label = wording.get('execution_providers_checkbox_group_label'), choices = encode_execution_providers(onnxruntime.get_available_providers()), - value = encode_execution_providers(facefusion.globals.execution_providers) + value = encode_execution_providers(DeepFakeAI.globals.execution_providers) ) EXECUTION_THREAD_COUNT_SLIDER = gradio.Slider( label = wording.get('execution_thread_count_slider_label'), - value = facefusion.globals.execution_thread_count, + value = DeepFakeAI.globals.execution_thread_count, step = 1, minimum = 1, maximum = 128 ) EXECUTION_QUEUE_COUNT_SLIDER = gradio.Slider( label = wording.get('execution_queue_count_slider_label'), - value = facefusion.globals.execution_queue_count, + value = DeepFakeAI.globals.execution_queue_count, step = 1, minimum = 1, maximum = 16 @@ -50,15 +50,15 @@ def listen() -> None: def update_execution_providers(execution_providers : List[str]) -> Update: clear_face_analyser() clear_frame_processors_modules() - facefusion.globals.execution_providers = decode_execution_providers(execution_providers) + DeepFakeAI.globals.execution_providers = decode_execution_providers(execution_providers) return gradio.update(value = execution_providers) def update_execution_thread_count(execution_thread_count : int = 1) -> Update: - facefusion.globals.execution_thread_count = execution_thread_count + DeepFakeAI.globals.execution_thread_count = execution_thread_count return gradio.update(value = execution_thread_count) def update_execution_queue_count(execution_queue_count : int = 1) -> Update: - facefusion.globals.execution_queue_count = execution_queue_count + DeepFakeAI.globals.execution_queue_count = execution_queue_count return gradio.update(value = execution_queue_count) diff --git a/DeepFakeAI/uis/components/face_analyser.py b/DeepFakeAI/uis/components/face_analyser.py index 6b96a313de06c8194ef064eeb42f90702732aa20..117cd3ee22c36344954ccd18c18f4fabbeeee96d 100644 --- a/DeepFakeAI/uis/components/face_analyser.py +++ b/DeepFakeAI/uis/components/face_analyser.py @@ -2,11 +2,11 @@ from typing import Optional import gradio -import facefusion.choices -import facefusion.globals -from facefusion import wording -from facefusion.uis import core as ui -from facefusion.uis.typing import Update +import DeepFakeAI.choices +import DeepFakeAI.globals +from DeepFakeAI import wording +from DeepFakeAI.uis import core as ui +from DeepFakeAI.uis.typing import Update FACE_ANALYSER_DIRECTION_DROPDOWN : Optional[gradio.Dropdown] = None FACE_ANALYSER_AGE_DROPDOWN : Optional[gradio.Dropdown] = None @@ -22,18 +22,18 @@ def render() -> None: with gradio.Row(): FACE_ANALYSER_DIRECTION_DROPDOWN = gradio.Dropdown( label = wording.get('face_analyser_direction_dropdown_label'), - choices = facefusion.choices.face_analyser_direction, - value = facefusion.globals.face_analyser_direction + choices = DeepFakeAI.choices.face_analyser_direction, + value = DeepFakeAI.globals.face_analyser_direction ) FACE_ANALYSER_AGE_DROPDOWN = gradio.Dropdown( label = wording.get('face_analyser_age_dropdown_label'), - choices = ['none'] + facefusion.choices.face_analyser_age, - value = facefusion.globals.face_analyser_age or 'none' + choices = ['none'] + DeepFakeAI.choices.face_analyser_age, + value = DeepFakeAI.globals.face_analyser_age or 'none' ) FACE_ANALYSER_GENDER_DROPDOWN = gradio.Dropdown( label = wording.get('face_analyser_gender_dropdown_label'), - choices = ['none'] + facefusion.choices.face_analyser_gender, - value = facefusion.globals.face_analyser_gender or 'none' + choices = ['none'] + DeepFakeAI.choices.face_analyser_gender, + value = DeepFakeAI.globals.face_analyser_gender or 'none' ) ui.register_component('face_analyser_direction_dropdown', FACE_ANALYSER_DIRECTION_DROPDOWN) ui.register_component('face_analyser_age_dropdown', FACE_ANALYSER_AGE_DROPDOWN) @@ -48,7 +48,7 @@ def listen() -> None: def update_dropdown(name : str, value : str) -> Update: if value == 'none': - setattr(facefusion.globals, name, None) + setattr(DeepFakeAI.globals, name, None) else: - setattr(facefusion.globals, name, value) + setattr(DeepFakeAI.globals, name, value) return gradio.update(value = value) diff --git a/DeepFakeAI/uis/components/face_selector.py b/DeepFakeAI/uis/components/face_selector.py index 58dc44df8dda93790a566abafcb439fb718911b8..b6f4c66e07c46ce0f961acbd99289e421cd4e619 100644 --- a/DeepFakeAI/uis/components/face_selector.py +++ b/DeepFakeAI/uis/components/face_selector.py @@ -4,16 +4,16 @@ from time import sleep import cv2 import gradio -import facefusion.choices -import facefusion.globals -from facefusion import wording -from facefusion.capturer import get_video_frame -from facefusion.face_analyser import get_many_faces -from facefusion.face_reference import clear_face_reference -from facefusion.typing import Frame, FaceRecognition -from facefusion.uis import core as ui -from facefusion.uis.typing import ComponentName, Update -from facefusion.utilities import is_image, is_video +import DeepFakeAI.choices +import DeepFakeAI.globals +from DeepFakeAI import wording +from DeepFakeAI.capturer import get_video_frame +from DeepFakeAI.face_analyser import get_many_faces +from DeepFakeAI.face_reference import clear_face_reference +from DeepFakeAI.typing import Frame, FaceRecognition +from DeepFakeAI.uis import core as ui +from DeepFakeAI.uis.typing import ComponentName, Update +from DeepFakeAI.utilities import is_image, is_video FACE_RECOGNITION_DROPDOWN : Optional[gradio.Dropdown] = None REFERENCE_FACE_POSITION_GALLERY : Optional[gradio.Gallery] = None @@ -32,26 +32,26 @@ def render() -> None: 'object_fit': 'cover', 'columns': 10, 'allow_preview': False, - 'visible': 'reference' in facefusion.globals.face_recognition + 'visible': 'reference' in DeepFakeAI.globals.face_recognition } - if is_image(facefusion.globals.target_path): - reference_frame = cv2.imread(facefusion.globals.target_path) + if is_image(DeepFakeAI.globals.target_path): + reference_frame = cv2.imread(DeepFakeAI.globals.target_path) reference_face_gallery_args['value'] = extract_gallery_frames(reference_frame) - if is_video(facefusion.globals.target_path): - reference_frame = get_video_frame(facefusion.globals.target_path, facefusion.globals.reference_frame_number) + if is_video(DeepFakeAI.globals.target_path): + reference_frame = get_video_frame(DeepFakeAI.globals.target_path, DeepFakeAI.globals.reference_frame_number) reference_face_gallery_args['value'] = extract_gallery_frames(reference_frame) FACE_RECOGNITION_DROPDOWN = gradio.Dropdown( label = wording.get('face_recognition_dropdown_label'), - choices = facefusion.choices.face_recognition, - value = facefusion.globals.face_recognition + choices = DeepFakeAI.choices.face_recognition, + value = DeepFakeAI.globals.face_recognition ) REFERENCE_FACE_POSITION_GALLERY = gradio.Gallery(**reference_face_gallery_args) REFERENCE_FACE_DISTANCE_SLIDER = gradio.Slider( label = wording.get('reference_face_distance_slider_label'), - value = facefusion.globals.reference_face_distance, + value = DeepFakeAI.globals.reference_face_distance, maximum = 3, step = 0.05, - visible = 'reference' in facefusion.globals.face_recognition + visible = 'reference' in DeepFakeAI.globals.face_recognition ) ui.register_component('face_recognition_dropdown', FACE_RECOGNITION_DROPDOWN) ui.register_component('reference_face_position_gallery', REFERENCE_FACE_POSITION_GALLERY) @@ -85,10 +85,10 @@ def listen() -> None: def update_face_recognition(face_recognition : FaceRecognition) -> Tuple[Update, Update]: if face_recognition == 'reference': - facefusion.globals.face_recognition = face_recognition + DeepFakeAI.globals.face_recognition = face_recognition return gradio.update(visible = True), gradio.update(visible = True) if face_recognition == 'many': - facefusion.globals.face_recognition = face_recognition + DeepFakeAI.globals.face_recognition = face_recognition return gradio.update(visible = False), gradio.update(visible = False) @@ -100,12 +100,12 @@ def clear_and_update_face_reference_position(event: gradio.SelectData) -> Update def update_face_reference_position(reference_face_position : int = 0) -> Update: sleep(0.2) gallery_frames = [] - facefusion.globals.reference_face_position = reference_face_position - if is_image(facefusion.globals.target_path): - reference_frame = cv2.imread(facefusion.globals.target_path) + DeepFakeAI.globals.reference_face_position = reference_face_position + if is_image(DeepFakeAI.globals.target_path): + reference_frame = cv2.imread(DeepFakeAI.globals.target_path) gallery_frames = extract_gallery_frames(reference_frame) - if is_video(facefusion.globals.target_path): - reference_frame = get_video_frame(facefusion.globals.target_path, facefusion.globals.reference_frame_number) + if is_video(DeepFakeAI.globals.target_path): + reference_frame = get_video_frame(DeepFakeAI.globals.target_path, DeepFakeAI.globals.reference_frame_number) gallery_frames = extract_gallery_frames(reference_frame) if gallery_frames: return gradio.update(value = gallery_frames) @@ -113,7 +113,7 @@ def update_face_reference_position(reference_face_position : int = 0) -> Update: def update_reference_face_distance(reference_face_distance : float) -> Update: - facefusion.globals.reference_face_distance = reference_face_distance + DeepFakeAI.globals.reference_face_distance = reference_face_distance return gradio.update(value = reference_face_distance) diff --git a/DeepFakeAI/uis/components/output.py b/DeepFakeAI/uis/components/output.py index 78655f5ee36bdf2f1114b1afbc1563abaaea8d1e..f2f1736e9b6b6e9b394cbdfd635b87a570fa6f72 100644 --- a/DeepFakeAI/uis/components/output.py +++ b/DeepFakeAI/uis/components/output.py @@ -1,11 +1,11 @@ from typing import Tuple, Optional import gradio -import facefusion.globals -from facefusion import wording -from facefusion.core import conditional_process -from facefusion.uis.typing import Update -from facefusion.utilities import is_image, is_video, normalize_output_path, clear_temp +import DeepFakeAI.globals +from DeepFakeAI import wording +from DeepFakeAI.core import conditional_process +from DeepFakeAI.uis.typing import Update +from DeepFakeAI.utilities import is_image, is_video, normalize_output_path, clear_temp OUTPUT_START_BUTTON : Optional[gradio.Button] = None OUTPUT_CLEAR_BUTTON : Optional[gradio.Button] = None @@ -39,17 +39,17 @@ def listen() -> None: def update() -> Tuple[Update, Update]: - facefusion.globals.output_path = normalize_output_path(facefusion.globals.source_path, facefusion.globals.target_path, '.') - if facefusion.globals.output_path: + DeepFakeAI.globals.output_path = normalize_output_path(DeepFakeAI.globals.source_path, DeepFakeAI.globals.target_path, '.') + if DeepFakeAI.globals.output_path: conditional_process() - if is_image(facefusion.globals.output_path): - return gradio.update(value = facefusion.globals.output_path, visible = True), gradio.update(value = None, visible = False) - if is_video(facefusion.globals.output_path): - return gradio.update(value = None, visible = False), gradio.update(value = facefusion.globals.output_path, visible = True) + if is_image(DeepFakeAI.globals.output_path): + return gradio.update(value = DeepFakeAI.globals.output_path, visible = True), gradio.update(value = None, visible = False) + if is_video(DeepFakeAI.globals.output_path): + return gradio.update(value = None, visible = False), gradio.update(value = DeepFakeAI.globals.output_path, visible = True) return gradio.update(value = None, visible = False), gradio.update(value = None, visible = False) def clear() -> Tuple[Update, Update]: - if facefusion.globals.target_path: - clear_temp(facefusion.globals.target_path) + if DeepFakeAI.globals.target_path: + clear_temp(DeepFakeAI.globals.target_path) return gradio.update(value = None), gradio.update(value = None) diff --git a/DeepFakeAI/uis/components/output_settings.py b/DeepFakeAI/uis/components/output_settings.py index 257abbb121b75b67f0f9f225fd29ec6d7c832ba5..4146cd955361fe738525c50b033054a6ae1b3a82 100644 --- a/DeepFakeAI/uis/components/output_settings.py +++ b/DeepFakeAI/uis/components/output_settings.py @@ -1,11 +1,11 @@ from typing import Optional import gradio -import facefusion.choices -import facefusion.globals -from facefusion import wording -from facefusion.typing import OutputVideoEncoder -from facefusion.uis.typing import Update +import DeepFakeAI.choices +import DeepFakeAI.globals +from DeepFakeAI import wording +from DeepFakeAI.typing import OutputVideoEncoder +from DeepFakeAI.uis.typing import Update OUTPUT_VIDEO_ENCODER_DROPDOWN : Optional[gradio.Dropdown] = None OUTPUT_VIDEO_QUALITY_SLIDER : Optional[gradio.Slider] = None @@ -18,12 +18,12 @@ def render() -> None: with gradio.Box(): OUTPUT_VIDEO_ENCODER_DROPDOWN = gradio.Dropdown( label = wording.get('output_video_encoder_dropdown_label'), - choices = facefusion.choices.output_video_encoder, - value = facefusion.globals.output_video_encoder + choices = DeepFakeAI.choices.output_video_encoder, + value = DeepFakeAI.globals.output_video_encoder ) OUTPUT_VIDEO_QUALITY_SLIDER = gradio.Slider( label = wording.get('output_video_quality_slider_label'), - value = facefusion.globals.output_video_quality, + value = DeepFakeAI.globals.output_video_quality, step = 1 ) @@ -34,10 +34,10 @@ def listen() -> None: def update_output_video_encoder(output_video_encoder: OutputVideoEncoder) -> Update: - facefusion.globals.output_video_encoder = output_video_encoder + DeepFakeAI.globals.output_video_encoder = output_video_encoder return gradio.update(value = output_video_encoder) def update_output_video_quality(output_video_quality : int) -> Update: - facefusion.globals.output_video_quality = output_video_quality + DeepFakeAI.globals.output_video_quality = output_video_quality return gradio.update(value = output_video_quality) diff --git a/DeepFakeAI/uis/components/preview.py b/DeepFakeAI/uis/components/preview.py index 9c0f013d8486107ad6c07008fdec218728797e62..f86acaacc7f83c814d73b29186e019e97034a45e 100644 --- a/DeepFakeAI/uis/components/preview.py +++ b/DeepFakeAI/uis/components/preview.py @@ -3,17 +3,17 @@ from typing import Any, Dict, Tuple, List, Optional import cv2 import gradio -import facefusion.globals -from facefusion import wording -from facefusion.capturer import get_video_frame, get_video_frame_total -from facefusion.face_analyser import get_one_face -from facefusion.face_reference import get_face_reference, set_face_reference -from facefusion.predictor import predict_frame -from facefusion.processors.frame.core import load_frame_processor_module -from facefusion.typing import Frame -from facefusion.uis import core as ui -from facefusion.uis.typing import ComponentName, Update -from facefusion.utilities import is_video, is_image +import DeepFakeAI.globals +from DeepFakeAI import wording +from DeepFakeAI.capturer import get_video_frame, get_video_frame_total +from DeepFakeAI.face_analyser import get_one_face +from DeepFakeAI.face_reference import get_face_reference, set_face_reference +from DeepFakeAI.predictor import predict_frame +from DeepFakeAI.processors.frame.core import load_frame_processor_module +from DeepFakeAI.typing import Frame +from DeepFakeAI.uis import core as ui +from DeepFakeAI.uis.typing import ComponentName, Update +from DeepFakeAI.utilities import is_video, is_image PREVIEW_IMAGE : Optional[gradio.Image] = None PREVIEW_FRAME_SLIDER : Optional[gradio.Slider] = None @@ -32,17 +32,17 @@ def render() -> None: 'step': 1, 'visible': False } - if is_image(facefusion.globals.target_path): - target_frame = cv2.imread(facefusion.globals.target_path) + if is_image(DeepFakeAI.globals.target_path): + target_frame = cv2.imread(DeepFakeAI.globals.target_path) preview_frame = extract_preview_frame(target_frame) preview_image_args['value'] = ui.normalize_frame(preview_frame) - if is_video(facefusion.globals.target_path): - temp_frame = get_video_frame(facefusion.globals.target_path, facefusion.globals.reference_frame_number) + if is_video(DeepFakeAI.globals.target_path): + temp_frame = get_video_frame(DeepFakeAI.globals.target_path, DeepFakeAI.globals.reference_frame_number) preview_frame = extract_preview_frame(temp_frame) preview_image_args['value'] = ui.normalize_frame(preview_frame) preview_image_args['visible'] = True - preview_frame_slider_args['value'] = facefusion.globals.reference_frame_number - preview_frame_slider_args['maximum'] = get_video_frame_total(facefusion.globals.target_path) + preview_frame_slider_args['value'] = DeepFakeAI.globals.reference_frame_number + preview_frame_slider_args['maximum'] = get_video_frame_total(DeepFakeAI.globals.target_path) preview_frame_slider_args['visible'] = True PREVIEW_IMAGE = gradio.Image(**preview_image_args) PREVIEW_FRAME_SLIDER = gradio.Slider(**preview_frame_slider_args) @@ -78,14 +78,14 @@ def listen() -> None: def update(frame_number : int = 0) -> Tuple[Update, Update]: sleep(0.1) - if is_image(facefusion.globals.target_path): - target_frame = cv2.imread(facefusion.globals.target_path) + if is_image(DeepFakeAI.globals.target_path): + target_frame = cv2.imread(DeepFakeAI.globals.target_path) preview_frame = extract_preview_frame(target_frame) return gradio.update(value = ui.normalize_frame(preview_frame)), gradio.update(value = None, maximum = None, visible = False) - if is_video(facefusion.globals.target_path): - facefusion.globals.reference_frame_number = frame_number - video_frame_total = get_video_frame_total(facefusion.globals.target_path) - temp_frame = get_video_frame(facefusion.globals.target_path, facefusion.globals.reference_frame_number) + if is_video(DeepFakeAI.globals.target_path): + DeepFakeAI.globals.reference_frame_number = frame_number + video_frame_total = get_video_frame_total(DeepFakeAI.globals.target_path) + temp_frame = get_video_frame(DeepFakeAI.globals.target_path, DeepFakeAI.globals.reference_frame_number) preview_frame = extract_preview_frame(temp_frame) return gradio.update(value = ui.normalize_frame(preview_frame)), gradio.update(maximum = video_frame_total, visible = True) return gradio.update(value = None), gradio.update(value = None, maximum = None, visible = False) @@ -94,14 +94,14 @@ def update(frame_number : int = 0) -> Tuple[Update, Update]: def extract_preview_frame(temp_frame : Frame) -> Frame: if predict_frame(temp_frame): return cv2.GaussianBlur(temp_frame, (99, 99), 0) - source_face = get_one_face(cv2.imread(facefusion.globals.source_path)) if facefusion.globals.source_path else None + source_face = get_one_face(cv2.imread(DeepFakeAI.globals.source_path)) if DeepFakeAI.globals.source_path else None temp_frame = reduce_preview_frame(temp_frame) - if 'reference' in facefusion.globals.face_recognition and not get_face_reference(): - reference_frame = get_video_frame(facefusion.globals.target_path, facefusion.globals.reference_frame_number) - reference_face = get_one_face(reference_frame, facefusion.globals.reference_face_position) + if 'reference' in DeepFakeAI.globals.face_recognition and not get_face_reference(): + reference_frame = get_video_frame(DeepFakeAI.globals.target_path, DeepFakeAI.globals.reference_frame_number) + reference_face = get_one_face(reference_frame, DeepFakeAI.globals.reference_face_position) set_face_reference(reference_face) - reference_face = get_face_reference() if 'reference' in facefusion.globals.face_recognition else None - for frame_processor in facefusion.globals.frame_processors: + reference_face = get_face_reference() if 'reference' in DeepFakeAI.globals.face_recognition else None + for frame_processor in DeepFakeAI.globals.frame_processors: frame_processor_module = load_frame_processor_module(frame_processor) if frame_processor_module.pre_process(): temp_frame = frame_processor_module.process_frame( diff --git a/DeepFakeAI/uis/components/processors.py b/DeepFakeAI/uis/components/processors.py index 5f97b5743e5a87179c2bc1a0fc83bdd6f7c06466..b87da139b019f6c51a1adc45ad65a09f4578aa66 100644 --- a/DeepFakeAI/uis/components/processors.py +++ b/DeepFakeAI/uis/components/processors.py @@ -1,12 +1,12 @@ from typing import List, Optional import gradio -import facefusion.globals -from facefusion import wording -from facefusion.processors.frame.core import load_frame_processor_module, clear_frame_processors_modules -from facefusion.uis import core as ui -from facefusion.uis.typing import Update -from facefusion.utilities import list_module_names +import DeepFakeAI.globals +from DeepFakeAI import wording +from DeepFakeAI.processors.frame.core import load_frame_processor_module, clear_frame_processors_modules +from DeepFakeAI.uis import core as ui +from DeepFakeAI.uis.typing import Update +from DeepFakeAI.utilities import list_module_names FRAME_PROCESSORS_CHECKBOX_GROUP : Optional[gradio.CheckboxGroup] = None @@ -17,8 +17,8 @@ def render() -> None: with gradio.Box(): FRAME_PROCESSORS_CHECKBOX_GROUP = gradio.CheckboxGroup( label = wording.get('frame_processors_checkbox_group_label'), - choices = sort_frame_processors(facefusion.globals.frame_processors), - value = facefusion.globals.frame_processors + choices = sort_frame_processors(DeepFakeAI.globals.frame_processors), + value = DeepFakeAI.globals.frame_processors ) ui.register_component('frame_processors_checkbox_group', FRAME_PROCESSORS_CHECKBOX_GROUP) @@ -29,13 +29,13 @@ def listen() -> None: def update_frame_processors(frame_processors : List[str]) -> Update: clear_frame_processors_modules() - facefusion.globals.frame_processors = frame_processors - for frame_processor in facefusion.globals.frame_processors: + DeepFakeAI.globals.frame_processors = frame_processors + for frame_processor in DeepFakeAI.globals.frame_processors: frame_processor_module = load_frame_processor_module(frame_processor) frame_processor_module.pre_check() return gradio.update(value = frame_processors, choices = sort_frame_processors(frame_processors)) def sort_frame_processors(frame_processors : List[str]) -> list[str]: - frame_processors_names = list_module_names('facefusion/processors/frame/modules') + frame_processors_names = list_module_names('DeepFakeAI/processors/frame/modules') return sorted(frame_processors_names, key = lambda frame_processor : frame_processors.index(frame_processor) if frame_processor in frame_processors else len(frame_processors)) diff --git a/DeepFakeAI/uis/components/settings.py b/DeepFakeAI/uis/components/settings.py index 0f0efe087c111b505e68415ed50314c01ffce899..ec5c30b023f0ea5563a58dbaa5ea993a53ffba86 100644 --- a/DeepFakeAI/uis/components/settings.py +++ b/DeepFakeAI/uis/components/settings.py @@ -1,9 +1,9 @@ from typing import Optional import gradio -import facefusion.globals -from facefusion import wording -from facefusion.uis.typing import Update +import DeepFakeAI.globals +from DeepFakeAI import wording +from DeepFakeAI.uis.typing import Update KEEP_FPS_CHECKBOX : Optional[gradio.Checkbox] = None KEEP_TEMP_CHECKBOX : Optional[gradio.Checkbox] = None @@ -18,15 +18,15 @@ def render() -> None: with gradio.Box(): KEEP_FPS_CHECKBOX = gradio.Checkbox( label = wording.get('keep_fps_checkbox_label'), - value = facefusion.globals.keep_fps + value = DeepFakeAI.globals.keep_fps ) KEEP_TEMP_CHECKBOX = gradio.Checkbox( label = wording.get('keep_temp_checkbox_label'), - value = facefusion.globals.keep_temp + value = DeepFakeAI.globals.keep_temp ) SKIP_AUDIO_CHECKBOX = gradio.Checkbox( label = wording.get('skip_audio_checkbox_label'), - value = facefusion.globals.skip_audio + value = DeepFakeAI.globals.skip_audio ) @@ -37,5 +37,5 @@ def listen() -> None: def update_checkbox(name : str, value: bool) -> Update: - setattr(facefusion.globals, name, value) + setattr(DeepFakeAI.globals, name, value) return gradio.update(value = value) diff --git a/DeepFakeAI/uis/components/source.py b/DeepFakeAI/uis/components/source.py index 75b98fe70eacda9f76cfce713e7c6a0e5579eb04..29b77715b0648d49761a466bb9374dd7c32c4150 100644 --- a/DeepFakeAI/uis/components/source.py +++ b/DeepFakeAI/uis/components/source.py @@ -1,11 +1,11 @@ from typing import Any, IO, Optional import gradio -import facefusion.globals -from facefusion import wording -from facefusion.uis import core as ui -from facefusion.uis.typing import Update -from facefusion.utilities import is_image +import DeepFakeAI.globals +from DeepFakeAI import wording +from DeepFakeAI.uis import core as ui +from DeepFakeAI.uis.typing import Update +from DeepFakeAI.utilities import is_image SOURCE_FILE : Optional[gradio.File] = None SOURCE_IMAGE : Optional[gradio.Image] = None @@ -16,7 +16,7 @@ def render() -> None: global SOURCE_IMAGE with gradio.Box(): - is_source_image = is_image(facefusion.globals.source_path) + is_source_image = is_image(DeepFakeAI.globals.source_path) SOURCE_FILE = gradio.File( file_count = 'single', file_types= @@ -26,7 +26,7 @@ def render() -> None: '.webp' ], label = wording.get('source_file_label'), - value = facefusion.globals.source_path if is_source_image else None + value = DeepFakeAI.globals.source_path if is_source_image else None ) ui.register_component('source_file', SOURCE_FILE) SOURCE_IMAGE = gradio.Image( @@ -42,7 +42,7 @@ def listen() -> None: def update(file: IO[Any]) -> Update: if file and is_image(file.name): - facefusion.globals.source_path = file.name + DeepFakeAI.globals.source_path = file.name return gradio.update(value = file.name, visible = True) - facefusion.globals.source_path = None + DeepFakeAI.globals.source_path = None return gradio.update(value = None, visible = False) diff --git a/DeepFakeAI/uis/components/target.py b/DeepFakeAI/uis/components/target.py index 309d7f9a44c385a521f4cfcb347aaa544c651647..022cd8da664e0555e79f61bb875ffca47f98589e 100644 --- a/DeepFakeAI/uis/components/target.py +++ b/DeepFakeAI/uis/components/target.py @@ -1,12 +1,12 @@ from typing import Any, IO, Tuple, Optional import gradio -import facefusion.globals -from facefusion import wording -from facefusion.face_reference import clear_face_reference -from facefusion.uis import core as ui -from facefusion.uis.typing import Update -from facefusion.utilities import is_image, is_video +import DeepFakeAI.globals +from DeepFakeAI import wording +from DeepFakeAI.face_reference import clear_face_reference +from DeepFakeAI.uis import core as ui +from DeepFakeAI.uis.typing import Update +from DeepFakeAI.utilities import is_image, is_video TARGET_FILE : Optional[gradio.File] = None TARGET_IMAGE : Optional[gradio.Image] = None @@ -19,8 +19,8 @@ def render() -> None: global TARGET_VIDEO with gradio.Box(): - is_target_image = is_image(facefusion.globals.target_path) - is_target_video = is_video(facefusion.globals.target_path) + is_target_image = is_image(DeepFakeAI.globals.target_path) + is_target_video = is_video(DeepFakeAI.globals.target_path) TARGET_FILE = gradio.File( label = wording.get('target_file_label'), file_count = 'single', @@ -31,7 +31,7 @@ def render() -> None: '.webp', '.mp4' ], - value = facefusion.globals.target_path if is_target_image or is_target_video else None + value = DeepFakeAI.globals.target_path if is_target_image or is_target_video else None ) TARGET_IMAGE = gradio.Image( value = TARGET_FILE.value['name'] if is_target_image else None, @@ -53,10 +53,10 @@ def listen() -> None: def update(file : IO[Any]) -> Tuple[Update, Update]: clear_face_reference() if file and is_image(file.name): - facefusion.globals.target_path = file.name + DeepFakeAI.globals.target_path = file.name return gradio.update(value = file.name, visible = True), gradio.update(value = None, visible = False) if file and is_video(file.name): - facefusion.globals.target_path = file.name + DeepFakeAI.globals.target_path = file.name return gradio.update(value = None, visible = False), gradio.update(value = file.name, visible = True) - facefusion.globals.target_path = None + DeepFakeAI.globals.target_path = None return gradio.update(value = None, visible = False), gradio.update(value = None, visible = False) diff --git a/DeepFakeAI/uis/components/temp_frame.py b/DeepFakeAI/uis/components/temp_frame.py index 9584ec55d5606ddd99e1ca1f1ad21aa33bc4e02c..e1236f787144a8f87b8809c862f790f2abe5186c 100644 --- a/DeepFakeAI/uis/components/temp_frame.py +++ b/DeepFakeAI/uis/components/temp_frame.py @@ -1,12 +1,12 @@ from typing import Optional import gradio -import facefusion.choices -import facefusion.globals -from facefusion import wording -from facefusion.typing import TempFrameFormat +import DeepFakeAI.choices +import DeepFakeAI.globals +from DeepFakeAI import wording +from DeepFakeAI.typing import TempFrameFormat -from facefusion.uis.typing import Update +from DeepFakeAI.uis.typing import Update TEMP_FRAME_FORMAT_DROPDOWN : Optional[gradio.Dropdown] = None TEMP_FRAME_QUALITY_SLIDER : Optional[gradio.Slider] = None @@ -19,12 +19,12 @@ def render() -> None: with gradio.Box(): TEMP_FRAME_FORMAT_DROPDOWN = gradio.Dropdown( label = wording.get('temp_frame_format_dropdown_label'), - choices = facefusion.choices.temp_frame_format, - value = facefusion.globals.temp_frame_format + choices = DeepFakeAI.choices.temp_frame_format, + value = DeepFakeAI.globals.temp_frame_format ) TEMP_FRAME_QUALITY_SLIDER = gradio.Slider( label = wording.get('temp_frame_quality_slider_label'), - value = facefusion.globals.temp_frame_quality, + value = DeepFakeAI.globals.temp_frame_quality, step = 1 ) @@ -35,10 +35,10 @@ def listen() -> None: def update_temp_frame_format(temp_frame_format : TempFrameFormat) -> Update: - facefusion.globals.temp_frame_format = temp_frame_format + DeepFakeAI.globals.temp_frame_format = temp_frame_format return gradio.update(value = temp_frame_format) def update_temp_frame_quality(temp_frame_quality : int) -> Update: - facefusion.globals.temp_frame_quality = temp_frame_quality + DeepFakeAI.globals.temp_frame_quality = temp_frame_quality return gradio.update(value = temp_frame_quality) diff --git a/DeepFakeAI/uis/components/trim_frame.py b/DeepFakeAI/uis/components/trim_frame.py index 6af4e2255fdabbedc7d92fed5f1982f81488e096..cf95f81e36e32ebcd7acbdfd4e15fb78618ce0c3 100644 --- a/DeepFakeAI/uis/components/trim_frame.py +++ b/DeepFakeAI/uis/components/trim_frame.py @@ -3,12 +3,12 @@ from typing import Any, Dict, Tuple, Optional import gradio -import facefusion.globals -from facefusion import wording -from facefusion.capturer import get_video_frame_total -from facefusion.uis import core as ui -from facefusion.uis.typing import Update -from facefusion.utilities import is_video +import DeepFakeAI.globals +from DeepFakeAI import wording +from DeepFakeAI.capturer import get_video_frame_total +from DeepFakeAI.uis import core as ui +from DeepFakeAI.uis.typing import Update +from DeepFakeAI.utilities import is_video TRIM_FRAME_START_SLIDER : Optional[gradio.Slider] = None TRIM_FRAME_END_SLIDER : Optional[gradio.Slider] = None @@ -29,12 +29,12 @@ def render() -> None: 'step': 1, 'visible': False } - if is_video(facefusion.globals.target_path): - video_frame_total = get_video_frame_total(facefusion.globals.target_path) - trim_frame_start_slider_args['value'] = facefusion.globals.trim_frame_start or 0 + if is_video(DeepFakeAI.globals.target_path): + video_frame_total = get_video_frame_total(DeepFakeAI.globals.target_path) + trim_frame_start_slider_args['value'] = DeepFakeAI.globals.trim_frame_start or 0 trim_frame_start_slider_args['maximum'] = video_frame_total trim_frame_start_slider_args['visible'] = True - trim_frame_end_slider_args['value'] = facefusion.globals.trim_frame_end or video_frame_total + trim_frame_end_slider_args['value'] = DeepFakeAI.globals.trim_frame_end or video_frame_total trim_frame_end_slider_args['maximum'] = video_frame_total trim_frame_end_slider_args['visible'] = True with gradio.Row(): @@ -52,14 +52,14 @@ def listen() -> None: def remote_update() -> Tuple[Update, Update]: sleep(0.1) - if is_video(facefusion.globals.target_path): - video_frame_total = get_video_frame_total(facefusion.globals.target_path) - facefusion.globals.trim_frame_start = 0 - facefusion.globals.trim_frame_end = video_frame_total + if is_video(DeepFakeAI.globals.target_path): + video_frame_total = get_video_frame_total(DeepFakeAI.globals.target_path) + DeepFakeAI.globals.trim_frame_start = 0 + DeepFakeAI.globals.trim_frame_end = video_frame_total return gradio.update(value = 0, maximum = video_frame_total, visible = True), gradio.update(value = video_frame_total, maximum = video_frame_total, visible = True) return gradio.update(value = None, maximum = None, visible = False), gradio.update(value = None, maximum = None, visible = False) def update_number(name : str, value : int) -> Update: - setattr(facefusion.globals, name, value) + setattr(DeepFakeAI.globals, name, value) return gradio.update(value = value) diff --git a/DeepFakeAI/uis/core.py b/DeepFakeAI/uis/core.py index 4d4c351b96200135b41b1394841929f987d93a61..41612e5406258cc2be59a3fa5d2ef037fd9d4a0a 100644 --- a/DeepFakeAI/uis/core.py +++ b/DeepFakeAI/uis/core.py @@ -4,10 +4,10 @@ import sys import cv2 import gradio -import facefusion.globals -from facefusion import metadata, wording -from facefusion.typing import Frame -from facefusion.uis.typing import Component, ComponentName +import DeepFakeAI.globals +from DeepFakeAI import metadata, wording +from DeepFakeAI.typing import Frame +from DeepFakeAI.uis.typing import Component, ComponentName COMPONENTS: Dict[ComponentName, Component] = {} UI_LAYOUT_METHODS =\ @@ -20,7 +20,7 @@ UI_LAYOUT_METHODS =\ def launch() -> None: with gradio.Blocks(theme = get_theme(), title = metadata.get('name') + ' ' + metadata.get('version')) as ui: - for ui_layout in facefusion.globals.ui_layouts: + for ui_layout in DeepFakeAI.globals.ui_layouts: ui_layout_module = load_ui_layout_module(ui_layout) ui_layout_module.pre_check() ui_layout_module.render() @@ -30,7 +30,7 @@ def launch() -> None: def load_ui_layout_module(ui_layout : str) -> Any: try: - ui_layout_module = importlib.import_module('facefusion.uis.layouts.' + ui_layout) + ui_layout_module = importlib.import_module('DeepFakeAI.uis.layouts.' + ui_layout) for method_name in UI_LAYOUT_METHODS: if not hasattr(ui_layout_module, method_name): raise NotImplementedError diff --git a/DeepFakeAI/uis/layouts/__pycache__/default.cpython-310.pyc b/DeepFakeAI/uis/layouts/__pycache__/default.cpython-310.pyc index bd06555a33a4c193a68ccc505433e7f3685c93cd..a47c8220cc142ae407724422cb31edb0c686ee7f 100644 Binary files a/DeepFakeAI/uis/layouts/__pycache__/default.cpython-310.pyc and b/DeepFakeAI/uis/layouts/__pycache__/default.cpython-310.pyc differ diff --git a/DeepFakeAI/uis/layouts/benchmark.py b/DeepFakeAI/uis/layouts/benchmark.py index f7ddf370d2632c93f30ae2dd4429e71ad36faf68..f58e47a7a0dc5b681fa78a0276df1b482c8c532d 100644 --- a/DeepFakeAI/uis/layouts/benchmark.py +++ b/DeepFakeAI/uis/layouts/benchmark.py @@ -1,20 +1,20 @@ import gradio -from facefusion.uis.components import about, processors, execution, benchmark -from facefusion.utilities import conditional_download +from DeepFakeAI.uis.components import about, processors, execution, benchmark +from DeepFakeAI.utilities import conditional_download def pre_check() -> bool: conditional_download('.assets/examples', [ - 'https://github.com/facefusion/facefusion-assets/releases/download/examples/source.jpg', - 'https://github.com/facefusion/facefusion-assets/releases/download/examples/target-240p.mp4', - 'https://github.com/facefusion/facefusion-assets/releases/download/examples/target-360p.mp4', - 'https://github.com/facefusion/facefusion-assets/releases/download/examples/target-540p.mp4', - 'https://github.com/facefusion/facefusion-assets/releases/download/examples/target-720p.mp4', - 'https://github.com/facefusion/facefusion-assets/releases/download/examples/target-1080p.mp4', - 'https://github.com/facefusion/facefusion-assets/releases/download/examples/target-1440p.mp4', - 'https://github.com/facefusion/facefusion-assets/releases/download/examples/target-2160p.mp4' + 'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/examples/source.jpg', + 'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/examples/target-240p.mp4', + 'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/examples/target-360p.mp4', + 'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/examples/target-540p.mp4', + 'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/examples/target-720p.mp4', + 'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/examples/target-1080p.mp4', + 'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/examples/target-1440p.mp4', + 'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/examples/target-2160p.mp4' ]) return True diff --git a/DeepFakeAI/uis/layouts/default.py b/DeepFakeAI/uis/layouts/default.py index 0eb2baa8311c042a23ff2e8fbdf160ad658e745c..5c147a8a8efce384e8131034f9e448c5b877b9b3 100644 --- a/DeepFakeAI/uis/layouts/default.py +++ b/DeepFakeAI/uis/layouts/default.py @@ -1,6 +1,6 @@ import gradio -from facefusion.uis.components import about, processors, execution, temp_frame, settings, source, target, preview, trim_frame, face_analyser, face_selector, output_settings, output +from DeepFakeAI.uis.components import about, processors, execution, temp_frame, settings, source, target, preview, trim_frame, face_analyser, face_selector, output_settings, output def pre_check() -> bool: diff --git a/DeepFakeAI/utilities.py b/DeepFakeAI/utilities.py index 97d55481d2fde0e4c11a27e981111f03f2409572..dd33cf157f684dc1bad324bca4d9326b8e3f82f2 100644 --- a/DeepFakeAI/utilities.py +++ b/DeepFakeAI/utilities.py @@ -13,10 +13,10 @@ from typing import List, Optional import onnxruntime from tqdm import tqdm -import facefusion.globals -from facefusion import wording +import DeepFakeAI.globals +from DeepFakeAI import wording -TEMP_DIRECTORY_PATH = os.path.join(tempfile.gettempdir(), 'facefusion') +TEMP_DIRECTORY_PATH = os.path.join(tempfile.gettempdir(), 'DeepFakeAI') TEMP_OUTPUT_NAME = 'temp.mp4' # monkey patch ssl @@ -46,9 +46,9 @@ def detect_fps(target_path : str) -> Optional[float]: def extract_frames(target_path : str, fps : float) -> bool: temp_directory_path = get_temp_directory_path(target_path) - temp_frame_quality = round(31 - (facefusion.globals.temp_frame_quality * 0.31)) - trim_frame_start = facefusion.globals.trim_frame_start - trim_frame_end = facefusion.globals.trim_frame_end + temp_frame_quality = round(31 - (DeepFakeAI.globals.temp_frame_quality * 0.31)) + trim_frame_start = DeepFakeAI.globals.trim_frame_start + trim_frame_end = DeepFakeAI.globals.trim_frame_end commands = [ '-hwaccel', 'auto', '-i', target_path, '-q:v', str(temp_frame_quality), '-pix_fmt', 'rgb24', ] if trim_frame_start is not None and trim_frame_end is not None: commands.extend([ '-vf', 'trim=start_frame=' + str(trim_frame_start) + ':end_frame=' + str(trim_frame_end) + ',fps=' + str(fps) ]) @@ -58,18 +58,18 @@ def extract_frames(target_path : str, fps : float) -> bool: commands.extend([ '-vf', 'trim=end_frame=' + str(trim_frame_end) + ',fps=' + str(fps) ]) else: commands.extend([ '-vf', 'fps=' + str(fps) ]) - commands.extend([os.path.join(temp_directory_path, '%04d.' + facefusion.globals.temp_frame_format)]) + commands.extend([os.path.join(temp_directory_path, '%04d.' + DeepFakeAI.globals.temp_frame_format)]) return run_ffmpeg(commands) def create_video(target_path : str, fps : float) -> bool: temp_output_path = get_temp_output_path(target_path) temp_directory_path = get_temp_directory_path(target_path) - output_video_quality = round(51 - (facefusion.globals.output_video_quality * 0.5)) - commands = [ '-hwaccel', 'auto', '-r', str(fps), '-i', os.path.join(temp_directory_path, '%04d.' + facefusion.globals.temp_frame_format), '-c:v', facefusion.globals.output_video_encoder ] - if facefusion.globals.output_video_encoder in [ 'libx264', 'libx265', 'libvpx' ]: + output_video_quality = round(51 - (DeepFakeAI.globals.output_video_quality * 0.5)) + commands = [ '-hwaccel', 'auto', '-r', str(fps), '-i', os.path.join(temp_directory_path, '%04d.' + DeepFakeAI.globals.temp_frame_format), '-c:v', DeepFakeAI.globals.output_video_encoder ] + if DeepFakeAI.globals.output_video_encoder in [ 'libx264', 'libx265', 'libvpx' ]: commands.extend([ '-crf', str(output_video_quality) ]) - if facefusion.globals.output_video_encoder in [ 'h264_nvenc', 'hevc_nvenc' ]: + if DeepFakeAI.globals.output_video_encoder in [ 'h264_nvenc', 'hevc_nvenc' ]: commands.extend([ '-cq', str(output_video_quality) ]) commands.extend([ '-pix_fmt', 'yuv420p', '-vf', 'colorspace=bt709:iall=bt601-6-625', '-y', temp_output_path ]) return run_ffmpeg(commands) @@ -77,8 +77,8 @@ def create_video(target_path : str, fps : float) -> bool: def restore_audio(target_path : str, output_path : str) -> None: fps = detect_fps(target_path) - trim_frame_start = facefusion.globals.trim_frame_start - trim_frame_end = facefusion.globals.trim_frame_end + trim_frame_start = DeepFakeAI.globals.trim_frame_start + trim_frame_end = DeepFakeAI.globals.trim_frame_end temp_output_path = get_temp_output_path(target_path) commands = [ '-hwaccel', 'auto', '-i', temp_output_path, '-i', target_path ] if trim_frame_start is None and trim_frame_end is None: @@ -101,7 +101,7 @@ def restore_audio(target_path : str, output_path : str) -> None: def get_temp_frame_paths(target_path : str) -> List[str]: temp_directory_path = get_temp_directory_path(target_path) - return glob.glob((os.path.join(glob.escape(temp_directory_path), '*.' + facefusion.globals.temp_frame_format))) + return glob.glob((os.path.join(glob.escape(temp_directory_path), '*.' + DeepFakeAI.globals.temp_frame_format))) def get_temp_directory_path(target_path : str) -> str: @@ -139,7 +139,7 @@ def move_temp(target_path : str, output_path : str) -> None: def clear_temp(target_path : str) -> None: temp_directory_path = get_temp_directory_path(target_path) parent_directory_path = os.path.dirname(temp_directory_path) - if not facefusion.globals.keep_temp and os.path.isdir(temp_directory_path): + if not DeepFakeAI.globals.keep_temp and os.path.isdir(temp_directory_path): shutil.rmtree(temp_directory_path) if os.path.exists(parent_directory_path) and not os.listdir(parent_directory_path): os.rmdir(parent_directory_path) diff --git a/tests/test_cli.py b/tests/test_cli.py index 8a48a028ebf8a6a07abb4c5d834e849c051a599d..266116e302e19dd4602df71cbe4bd2440cf2513c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,16 +1,16 @@ import subprocess import pytest -from facefusion import wording -from facefusion.utilities import conditional_download +from DeepFakeAI import wording +from DeepFakeAI.utilities import conditional_download @pytest.fixture(scope = 'module', autouse = True) def before_all() -> None: conditional_download('.assets/examples', [ - 'https://github.com/facefusion/facefusion-assets/releases/download/examples/source.jpg', - 'https://github.com/facefusion/facefusion-assets/releases/download/examples/target-1080p.mp4' + 'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/examples/source.jpg', + 'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/examples/target-1080p.mp4' ]) subprocess.run([ 'ffmpeg', '-i', '.assets/examples/target-1080p.mp4', '-vframes', '1', '.assets/examples/target-1080p.jpg' ]) diff --git a/tests/test_utilities.py b/tests/test_utilities.py index 4dcb8e25247f029bcf0e3c587be151f8165b33ae..e503e74378796c8bf9c4d9d2f6bc077c4e593b39 100644 --- a/tests/test_utilities.py +++ b/tests/test_utilities.py @@ -2,19 +2,19 @@ import glob import subprocess import pytest -import facefusion.globals -from facefusion.utilities import conditional_download, detect_fps, extract_frames, create_temp, get_temp_directory_path, clear_temp +import DeepFakeAI.globals +from DeepFakeAI.utilities import conditional_download, detect_fps, extract_frames, create_temp, get_temp_directory_path, clear_temp @pytest.fixture(scope = 'module', autouse = True) def before_all() -> None: - facefusion.globals.temp_frame_quality = 100 - facefusion.globals.trim_frame_start = None - facefusion.globals.trim_frame_end = None - facefusion.globals.temp_frame_format = 'png' + DeepFakeAI.globals.temp_frame_quality = 100 + DeepFakeAI.globals.trim_frame_start = None + DeepFakeAI.globals.trim_frame_end = None + DeepFakeAI.globals.temp_frame_format = 'png' conditional_download('.assets/examples', [ - 'https://github.com/facefusion/facefusion-assets/releases/download/examples/target-240p.mp4' + 'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/examples/target-240p.mp4' ]) subprocess.run([ 'ffmpeg', '-i', '.assets/examples/target-240p.mp4', '-vf', 'fps=25', '.assets/examples/target-240p-25fps.mp4' ]) subprocess.run([ 'ffmpeg', '-i', '.assets/examples/target-240p.mp4', '-vf', 'fps=30', '.assets/examples/target-240p-30fps.mp4' ]) @@ -23,10 +23,10 @@ def before_all() -> None: @pytest.fixture(scope = 'function', autouse = True) def before_each() -> None: - facefusion.globals.trim_frame_start = None - facefusion.globals.trim_frame_end = None - facefusion.globals.temp_frame_quality = 90 - facefusion.globals.temp_frame_format = 'jpg' + DeepFakeAI.globals.trim_frame_start = None + DeepFakeAI.globals.trim_frame_end = None + DeepFakeAI.globals.temp_frame_quality = 90 + DeepFakeAI.globals.temp_frame_format = 'jpg' def test_detect_fps() -> None: @@ -53,7 +53,7 @@ def test_extract_frames() -> None: def test_extract_frames_with_trim_start() -> None: - facefusion.globals.trim_frame_start = 224 + DeepFakeAI.globals.trim_frame_start = 224 data_provider =\ [ ('.assets/examples/target-240p-25fps.mp4', 55), @@ -71,8 +71,8 @@ def test_extract_frames_with_trim_start() -> None: def test_extract_frames_with_trim_start_and_trim_end() -> None: - facefusion.globals.trim_frame_start = 124 - facefusion.globals.trim_frame_end = 224 + DeepFakeAI.globals.trim_frame_start = 124 + DeepFakeAI.globals.trim_frame_end = 224 data_provider =\ [ ('.assets/examples/target-240p-25fps.mp4', 120), @@ -90,7 +90,7 @@ def test_extract_frames_with_trim_start_and_trim_end() -> None: def test_extract_frames_with_trim_end() -> None: - facefusion.globals.trim_frame_end = 100 + DeepFakeAI.globals.trim_frame_end = 100 data_provider =\ [ ('.assets/examples/target-240p-25fps.mp4', 120),