Spaces:
Running
Running
Upload folder using huggingface_hub
#2
by imseldrith - opened
This view is limited to 50 files because it contains too many changes. See the raw diff here.
Files changed (50)
- DeepFakeAI/__pycache__/__init__.cpython-310.pyc
- DeepFakeAI/__pycache__/capturer.cpython-310.pyc
- DeepFakeAI/__pycache__/choices.cpython-310.pyc
- DeepFakeAI/__pycache__/core.cpython-310.pyc
- DeepFakeAI/__pycache__/face_analyser.cpython-310.pyc
- DeepFakeAI/__pycache__/face_reference.cpython-310.pyc
- DeepFakeAI/__pycache__/globals.cpython-310.pyc
- DeepFakeAI/__pycache__/metadata.cpython-310.pyc
- DeepFakeAI/__pycache__/predictor.cpython-310.pyc
- DeepFakeAI/__pycache__/typing.cpython-310.pyc
- DeepFakeAI/__pycache__/utilities.cpython-310.pyc
- DeepFakeAI/__pycache__/wording.cpython-310.pyc
- DeepFakeAI/capturer.py+1-1
- DeepFakeAI/choices.py+1-1
- DeepFakeAI/core.py+69-69
- DeepFakeAI/face_analyser.py+9-9
- DeepFakeAI/face_reference.py+1-1
- DeepFakeAI/globals.py+1-1
- DeepFakeAI/metadata.py+1-1
- DeepFakeAI/predictor.py+1-1
- DeepFakeAI/processors/__pycache__/__init__.cpython-310.pyc
- DeepFakeAI/processors/frame/__pycache__/__init__.cpython-310.pyc
- DeepFakeAI/processors/frame/__pycache__/core.cpython-310.pyc
- DeepFakeAI/processors/frame/core.py+11-11
- DeepFakeAI/processors/frame/modules/__pycache__/__init__.cpython-310.pyc
- DeepFakeAI/processors/frame/modules/__pycache__/face_swapper.cpython-310.pyc
- DeepFakeAI/processors/frame/modules/face_enhancer.py+10-10
- DeepFakeAI/processors/frame/modules/face_swapper.py+21-21
- DeepFakeAI/processors/frame/modules/frame_enhancer.py+4-4
- DeepFakeAI/uis/__pycache__/__init__.cpython-310.pyc
- DeepFakeAI/uis/__pycache__/core.cpython-310.pyc
- DeepFakeAI/uis/__pycache__/typing.cpython-310.pyc
- DeepFakeAI/uis/components/__pycache__/__init__.cpython-310.pyc
- DeepFakeAI/uis/components/__pycache__/about.cpython-310.pyc
- DeepFakeAI/uis/components/__pycache__/execution.cpython-310.pyc
- DeepFakeAI/uis/components/__pycache__/face_analyser.cpython-310.pyc
- DeepFakeAI/uis/components/__pycache__/face_selector.cpython-310.pyc
- DeepFakeAI/uis/components/__pycache__/output.cpython-310.pyc
- DeepFakeAI/uis/components/__pycache__/output_settings.cpython-310.pyc
- DeepFakeAI/uis/components/__pycache__/preview.cpython-310.pyc
- DeepFakeAI/uis/components/__pycache__/processors.cpython-310.pyc
- DeepFakeAI/uis/components/__pycache__/settings.cpython-310.pyc
- DeepFakeAI/uis/components/__pycache__/source.cpython-310.pyc
- DeepFakeAI/uis/components/__pycache__/target.cpython-310.pyc
- DeepFakeAI/uis/components/__pycache__/temp_frame.cpython-310.pyc
- DeepFakeAI/uis/components/__pycache__/trim_frame.cpython-310.pyc
- DeepFakeAI/uis/components/about.py+1-1
- DeepFakeAI/uis/components/benchmark.py+13-13
- DeepFakeAI/uis/components/execution.py+12-12
- DeepFakeAI/uis/components/face_analyser.py+13-13
1234567from typing import Optionalimport cv2from facefusion.typing import Framedef get_video_frame(video_path : str, frame_number : int = 0) -> Optional[Frame]:1234567from typing import Optionalimport cv2from DeepFakeAI.typing import Framedef get_video_frame(video_path : str, frame_number : int = 0) -> Optional[Frame]:
123456from typing import Listfrom facefusion.typing import FaceRecognition, FaceAnalyserDirection, FaceAnalyserAge, FaceAnalyserGender, TempFrameFormat, OutputVideoEncoderface_recognition : List[FaceRecognition] = [ 'reference', 'many' ]face_analyser_direction : List[FaceAnalyserDirection] = [ 'left-right', 'right-left', 'top-bottom', 'bottom-top', 'small-large', 'large-small']123456from typing import Listfrom DeepFakeAI.typing import FaceRecognition, FaceAnalyserDirection, FaceAnalyserAge, FaceAnalyserGender, TempFrameFormat, OutputVideoEncoderface_recognition : List[FaceRecognition] = [ 'reference', 'many' ]face_analyser_direction : List[FaceAnalyserDirection] = [ 'left-right', 'right-left', 'top-bottom', 'bottom-top', 'small-large', 'large-small']
14 unmodified lines1516171819202122232425265 unmodified lines32333435363738394041424344454647484950515253543 unmodified lines585960616263646566676869707172737475767778798081828384858687888914 unmodified lines10410510610710810911011111211318 unmodified lines1321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992003 unmodified lines20420520620720820921021121221321421521621721821922022122214 unmodified linesimport onnxruntimeimport tensorflowimport facefusion.choicesimport facefusion.globalsfrom facefusion import wording, metadatafrom facefusion.predictor import predict_image, predict_videofrom facefusion.processors.frame.core import get_frame_processors_modulesfrom 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_providerswarnings.filterwarnings('ignore', category = FutureWarning, module = 'insightface')warnings.filterwarnings('ignore', category = UserWarning, module = 'torchvision')5 unmodified linesprogram.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('--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('--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-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-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='+')3 unmodified linesargs = program.parse_args()facefusion.globals.source_path = args.source_pathfacefusion.globals.target_path = args.target_pathfacefusion.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 Nonefacefusion.globals.frame_processors = args.frame_processorsfacefusion.globals.ui_layouts = args.ui_layoutsfacefusion.globals.keep_fps = args.keep_fpsfacefusion.globals.keep_temp = args.keep_tempfacefusion.globals.skip_audio = args.skip_audiofacefusion.globals.face_recognition = args.face_recognitionfacefusion.globals.face_analyser_direction = args.face_analyser_directionfacefusion.globals.face_analyser_age = args.face_analyser_agefacefusion.globals.face_analyser_gender = args.face_analyser_genderfacefusion.globals.reference_face_position = args.reference_face_positionfacefusion.globals.reference_frame_number = args.reference_frame_numberfacefusion.globals.reference_face_distance = args.reference_face_distancefacefusion.globals.trim_frame_start = args.trim_frame_startfacefusion.globals.trim_frame_end = args.trim_frame_endfacefusion.globals.temp_frame_format = args.temp_frame_formatfacefusion.globals.temp_frame_quality = args.temp_frame_qualityfacefusion.globals.output_video_encoder = args.output_video_encoderfacefusion.globals.output_video_quality = args.output_video_qualityfacefusion.globals.max_memory = args.max_memoryfacefusion.globals.execution_providers = decode_execution_providers(args.execution_providers)facefusion.globals.execution_thread_count = args.execution_thread_countfacefusion.globals.execution_queue_count = args.execution_queue_countdef suggest_execution_providers_choices() -> List[str]:14 unmodified linestensorflow.config.experimental.VirtualDeviceConfiguration(memory_limit = 1024)])# limit memory usageif facefusion.globals.max_memory:memory = facefusion.globals.max_memory * 1024 ** 3if platform.system().lower() == 'darwin':memory = facefusion.globals.max_memory * 1024 ** 6if platform.system().lower() == 'windows':import ctypeskernel32 = ctypes.windll.kernel32 # type: ignore[attr-defined]18 unmodified linesdef process_image() -> None:if predict_image(facefusion.globals.target_path):returnshutil.copy2(facefusion.globals.target_path, facefusion.globals.output_path)# process framefor frame_processor_module in get_frame_processors_modules(facefusion.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.post_process()# validate imageif is_image(facefusion.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):returnfps = detect_fps(facefusion.globals.target_path) if facefusion.globals.keep_fps else 25.0update_status(wording.get('creating_temp'))create_temp(facefusion.globals.target_path)# extract framesupdate_status(wording.get('extracting_frames_fps').format(fps = fps))extract_frames(facefusion.globals.target_path, fps)# process frametemp_frame_paths = get_temp_frame_paths(facefusion.globals.target_path)if temp_frame_paths:for frame_processor_module in get_frame_processors_modules(facefusion.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.post_process()else:update_status(wording.get('temp_frames_not_found'))return# create videoupdate_status(wording.get('creating_video_fps').format(fps = fps))if not create_video(facefusion.globals.target_path, fps):update_status(wording.get('creating_video_failed'))return# handle audioif facefusion.globals.skip_audio:update_status(wording.get('skipping_audio'))move_temp(facefusion.globals.target_path, facefusion.globals.output_path)else:update_status(wording.get('restoring_audio'))restore_audio(facefusion.globals.target_path, facefusion.globals.output_path)# clear tempupdate_status(wording.get('clearing_temp'))clear_temp(facefusion.globals.target_path)# validate videoif is_video(facefusion.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):if not frame_processor_module.pre_process():returnif is_image(facefusion.globals.target_path):process_image()if is_video(facefusion.globals.target_path):process_video()3 unmodified lines# pre checkif not pre_check():returnfor frame_processor in get_frame_processors_modules(facefusion.globals.frame_processors):if not frame_processor.pre_check():return# process or launchif facefusion.globals.headless:conditional_process()else:import facefusion.uis.core as uiui.launch()def destroy() -> None:if facefusion.globals.target_path:clear_temp(facefusion.globals.target_path)sys.exit()14 unmodified lines1516171819202122232425265 unmodified lines32333435363738394041424344454647484950515253543 unmodified lines585960616263646566676869707172737475767778798081828384858687888914 unmodified lines10410510610710810911011111211318 unmodified lines1321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992003 unmodified lines20420520620720820921021121221321421521621721821922022122214 unmodified linesimport onnxruntimeimport tensorflowimport DeepFakeAI.choicesimport DeepFakeAI.globalsfrom DeepFakeAI import wording, metadatafrom DeepFakeAI.predictor import predict_image, predict_videofrom DeepFakeAI.processors.frame.core import get_frame_processors_modulesfrom 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_providerswarnings.filterwarnings('ignore', category = FutureWarning, module = 'insightface')warnings.filterwarnings('ignore', category = UserWarning, module = 'torchvision')5 unmodified linesprogram.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('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 = 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 = 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 = 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='+')3 unmodified linesargs = program.parse_args()DeepFakeAI.globals.source_path = args.source_pathDeepFakeAI.globals.target_path = args.target_pathDeepFakeAI.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 NoneDeepFakeAI.globals.frame_processors = args.frame_processorsDeepFakeAI.globals.ui_layouts = args.ui_layoutsDeepFakeAI.globals.keep_fps = args.keep_fpsDeepFakeAI.globals.keep_temp = args.keep_tempDeepFakeAI.globals.skip_audio = args.skip_audioDeepFakeAI.globals.face_recognition = args.face_recognitionDeepFakeAI.globals.face_analyser_direction = args.face_analyser_directionDeepFakeAI.globals.face_analyser_age = args.face_analyser_ageDeepFakeAI.globals.face_analyser_gender = args.face_analyser_genderDeepFakeAI.globals.reference_face_position = args.reference_face_positionDeepFakeAI.globals.reference_frame_number = args.reference_frame_numberDeepFakeAI.globals.reference_face_distance = args.reference_face_distanceDeepFakeAI.globals.trim_frame_start = args.trim_frame_startDeepFakeAI.globals.trim_frame_end = args.trim_frame_endDeepFakeAI.globals.temp_frame_format = args.temp_frame_formatDeepFakeAI.globals.temp_frame_quality = args.temp_frame_qualityDeepFakeAI.globals.output_video_encoder = args.output_video_encoderDeepFakeAI.globals.output_video_quality = args.output_video_qualityDeepFakeAI.globals.max_memory = args.max_memoryDeepFakeAI.globals.execution_providers = decode_execution_providers(args.execution_providers)DeepFakeAI.globals.execution_thread_count = args.execution_thread_countDeepFakeAI.globals.execution_queue_count = args.execution_queue_countdef suggest_execution_providers_choices() -> List[str]:14 unmodified linestensorflow.config.experimental.VirtualDeviceConfiguration(memory_limit = 1024)])# limit memory usageif DeepFakeAI.globals.max_memory:memory = DeepFakeAI.globals.max_memory * 1024 ** 3if platform.system().lower() == 'darwin':memory = DeepFakeAI.globals.max_memory * 1024 ** 6if platform.system().lower() == 'windows':import ctypeskernel32 = ctypes.windll.kernel32 # type: ignore[attr-defined]18 unmodified linesdef process_image() -> None:if predict_image(DeepFakeAI.globals.target_path):returnshutil.copy2(DeepFakeAI.globals.target_path, DeepFakeAI.globals.output_path)# process framefor 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(DeepFakeAI.globals.source_path, DeepFakeAI.globals.output_path, DeepFakeAI.globals.output_path)frame_processor_module.post_process()# validate imageif 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(DeepFakeAI.globals.target_path):returnfps = detect_fps(DeepFakeAI.globals.target_path) if DeepFakeAI.globals.keep_fps else 25.0update_status(wording.get('creating_temp'))create_temp(DeepFakeAI.globals.target_path)# extract framesupdate_status(wording.get('extracting_frames_fps').format(fps = fps))extract_frames(DeepFakeAI.globals.target_path, fps)# process frametemp_frame_paths = get_temp_frame_paths(DeepFakeAI.globals.target_path)if temp_frame_paths: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(DeepFakeAI.globals.source_path, temp_frame_paths)frame_processor_module.post_process()else:update_status(wording.get('temp_frames_not_found'))return# create videoupdate_status(wording.get('creating_video_fps').format(fps = fps))if not create_video(DeepFakeAI.globals.target_path, fps):update_status(wording.get('creating_video_failed'))return# handle audioif DeepFakeAI.globals.skip_audio:update_status(wording.get('skipping_audio'))move_temp(DeepFakeAI.globals.target_path, DeepFakeAI.globals.output_path)else:update_status(wording.get('restoring_audio'))restore_audio(DeepFakeAI.globals.target_path, DeepFakeAI.globals.output_path)# clear tempupdate_status(wording.get('clearing_temp'))clear_temp(DeepFakeAI.globals.target_path)# validate videoif 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(DeepFakeAI.globals.frame_processors):if not frame_processor_module.pre_process():returnif is_image(DeepFakeAI.globals.target_path):process_image()if is_video(DeepFakeAI.globals.target_path):process_video()3 unmodified lines# pre checkif not pre_check():returnfor frame_processor in get_frame_processors_modules(DeepFakeAI.globals.frame_processors):if not frame_processor.pre_check():return# process or launchif DeepFakeAI.globals.headless:conditional_process()else:import DeepFakeAI.uis.core as uiui.launch()def destroy() -> None:if DeepFakeAI.globals.target_path:clear_temp(DeepFakeAI.globals.target_path)sys.exit()
2 unmodified lines3456789104 unmodified lines1516171819202117 unmodified lines3940414243444546474849502 unmodified linesimport insightfaceimport numpyimport facefusion.globalsfrom facefusion.typing import Frame, Face, FaceAnalyserDirection, FaceAnalyserAge, FaceAnalyserGenderFACE_ANALYSER = NoneTHREAD_LOCK = threading.Lock()4 unmodified lineswith THREAD_LOCK:if FACE_ANALYSER is None:FACE_ANALYSER = insightface.app.FaceAnalysis(name = 'buffalo_l', providers = facefusion.globals.execution_providers)FACE_ANALYSER.prepare(ctx_id = 0)return FACE_ANALYSER17 unmodified linesdef 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)return facesexcept (AttributeError, ValueError):return []2 unmodified lines3456789104 unmodified lines1516171819202117 unmodified lines3940414243444546474849502 unmodified linesimport insightfaceimport numpyimport DeepFakeAI.globalsfrom DeepFakeAI.typing import Frame, Face, FaceAnalyserDirection, FaceAnalyserAge, FaceAnalyserGenderFACE_ANALYSER = NoneTHREAD_LOCK = threading.Lock()4 unmodified lineswith THREAD_LOCK:if FACE_ANALYSER is None:FACE_ANALYSER = insightface.app.FaceAnalysis(name = 'buffalo_l', providers = DeepFakeAI.globals.execution_providers)FACE_ANALYSER.prepare(ctx_id = 0)return FACE_ANALYSER17 unmodified linesdef get_many_faces(frame : Frame) -> List[Face]:try:faces = get_face_analyser().get(frame)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 facesexcept (AttributeError, ValueError):return []
123456from typing import Optionalfrom facefusion.typing import FaceFACE_REFERENCE = None123456from typing import Optionalfrom DeepFakeAI.typing import FaceFACE_REFERENCE = None
123456from typing import List, Optionalfrom facefusion.typing import FaceRecognition, FaceAnalyserDirection, FaceAnalyserAge, FaceAnalyserGender, TempFrameFormatsource_path : Optional[str] = Nonetarget_path : Optional[str] = None123456from typing import List, Optionalfrom DeepFakeAI.typing import FaceRecognition, FaceAnalyserDirection, FaceAnalyserAge, FaceAnalyserGender, TempFrameFormatsource_path : Optional[str] = Nonetarget_path : Optional[str] = None
4 unmodified lines5678910114 unmodified lines'version': '1.0.0','license': 'MIT','author': 'Henry Ruhs','url': 'https://facefusion.io'}4 unmodified lines5678910114 unmodified lines'version': '1.0.0','license': 'MIT','author': 'Henry Ruhs','url': 'https://DeepFakeAI.io'}
3 unmodified lines456789103 unmodified linesfrom PIL import Imagefrom keras import Modelfrom facefusion.typing import FramePREDICTOR = NoneTHREAD_LOCK = threading.Lock()3 unmodified lines456789103 unmodified linesfrom PIL import Imagefrom keras import Modelfrom DeepFakeAI.typing import FramePREDICTOR = NoneTHREAD_LOCK = threading.Lock()
7 unmodified lines8910111213141512 unmodified lines2829303132333417 unmodified lines5253545556575859606162636465666729 unmodified lines9798991001011021031041051061071081091101111121137 unmodified linesfrom typing import Any, List, Callablefrom tqdm import tqdmimport facefusion.globalsfrom facefusion import wordingFRAME_PROCESSORS_MODULES : List[ModuleType] = []FRAME_PROCESSORS_METHODS =\12 unmodified linesdef load_frame_processor_module(frame_processor : str) -> Any:try:frame_processor_module = importlib.import_module('facefusion.processors.frame.modules.' + frame_processor)for method_name in FRAME_PROCESSORS_METHODS:if not hasattr(frame_processor_module, method_name):raise NotImplementedError17 unmodified linesdef clear_frame_processors_modules() -> None:global FRAME_PROCESSORS_MODULESfor frame_processor_module in get_frame_processors_modules(facefusion.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: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)while not queue.empty():future = executor.submit(process_frames, source_path, pick_queue(queue, queue_per_future), update)futures.append(future)29 unmodified linesprogress.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})progress.refresh()progress.update(1)def get_device() -> str:if 'CUDAExecutionProvider' in facefusion.globals.execution_providers:return 'cuda'if 'CoreMLExecutionProvider' in facefusion.globals.execution_providers:return 'mps'return 'cpu'7 unmodified lines8910111213141512 unmodified lines2829303132333417 unmodified lines5253545556575859606162636465666729 unmodified lines9798991001011021031041051061071081091101111121137 unmodified linesfrom typing import Any, List, Callablefrom tqdm import tqdmimport DeepFakeAI.globalsfrom DeepFakeAI import wordingFRAME_PROCESSORS_MODULES : List[ModuleType] = []FRAME_PROCESSORS_METHODS =\12 unmodified linesdef load_frame_processor_module(frame_processor : str) -> Any:try: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 NotImplementedError17 unmodified linesdef clear_frame_processors_modules() -> None:global FRAME_PROCESSORS_MODULESfor 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 = DeepFakeAI.globals.execution_thread_count) as executor:futures = []queue = create_queue(temp_frame_paths)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)29 unmodified linesprogress.set_postfix({'memory_usage': '{:.2f}'.format(memory_usage).zfill(5) + 'GB','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 DeepFakeAI.globals.execution_providers:return 'cuda'if 'CoreMLExecutionProvider' in DeepFakeAI.globals.execution_providers:return 'mps'return 'cpu'
2 unmodified lines345678910111213141523 unmodified lines39404142434445464748495046 unmodified lines9798991002 unmodified linesimport threadingfrom gfpgan.utils import GFPGANerimport facefusion.globalsimport facefusion.processors.frame.core as frame_processorsfrom facefusion import wordingfrom facefusion.core import update_statusfrom facefusion.face_analyser import get_many_facesfrom facefusion.typing import Frame, Facefrom facefusion.utilities import conditional_download, resolve_relative_path, is_image, is_videoFRAME_PROCESSOR = NoneTHREAD_SEMAPHORE = threading.Semaphore()23 unmodified linesdef 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'])return Truedef pre_process() -> bool:if not is_image(facefusion.globals.target_path) and not is_video(facefusion.globals.target_path):update_status(wording.get('select_image_or_video_target') + wording.get('exclamation_mark'), NAME)return Falsereturn True46 unmodified linesdef process_video(source_path : str, temp_frame_paths : List[str]) -> None:facefusion.processors.frame.core.process_video(None, temp_frame_paths, process_frames)2 unmodified lines345678910111213141523 unmodified lines39404142434445464748495046 unmodified lines9798991002 unmodified linesimport threadingfrom gfpgan.utils import GFPGANerimport DeepFakeAI.globalsimport DeepFakeAI.processors.frame.core as frame_processorsfrom DeepFakeAI import wordingfrom DeepFakeAI.core import update_statusfrom DeepFakeAI.face_analyser import get_many_facesfrom DeepFakeAI.typing import Frame, Facefrom DeepFakeAI.utilities import conditional_download, resolve_relative_path, is_image, is_videoFRAME_PROCESSOR = NoneTHREAD_SEMAPHORE = threading.Semaphore()23 unmodified linesdef pre_check() -> bool:download_directory_path = resolve_relative_path('../.assets/models')conditional_download(download_directory_path, ['https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/models/GFPGANv1.4.pth'])return Truedef pre_process() -> bool: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 Falsereturn True46 unmodified linesdef process_video(source_path : str, temp_frame_paths : List[str]) -> None:DeepFakeAI.processors.frame.core.process_video(None, temp_frame_paths, process_frames)
2 unmodified lines3456789101112131415166 unmodified lines232425262728295 unmodified lines3536373839404142434445464748495051528 unmodified lines6162636465666768697071723 unmodified lines767778798081825 unmodified lines888990919293944 unmodified lines991001011021031041052 unmodified linesimport insightfaceimport threadingimport facefusion.globalsimport facefusion.processors.frame.core as frame_processorsfrom facefusion import wordingfrom facefusion.core import update_statusfrom facefusion.face_analyser import get_one_face, get_many_faces, find_similar_facesfrom facefusion.face_reference import get_face_reference, set_face_referencefrom facefusion.typing import Face, Framefrom facefusion.utilities import conditional_download, resolve_relative_path, is_image, is_videoFRAME_PROCESSOR = NoneTHREAD_LOCK = threading.Lock()6 unmodified lineswith 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)return FRAME_PROCESSOR5 unmodified linesdef 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'])return Truedef pre_process() -> bool:if not is_image(facefusion.globals.source_path):update_status(wording.get('select_image_source') + wording.get('exclamation_mark'), NAME)return Falseelif not get_one_face(cv2.imread(facefusion.globals.source_path)):update_status(wording.get('no_source_face_detected') + wording.get('exclamation_mark'), NAME)return Falseif not is_image(facefusion.globals.target_path) and not is_video(facefusion.globals.target_path):update_status(wording.get('select_image_or_video_target') + wording.get('exclamation_mark'), NAME)return Falsereturn True8 unmodified linesdef 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 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:many_faces = get_many_faces(temp_frame)if many_faces:for target_face in many_faces:3 unmodified linesdef 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 Nonefor temp_frame_path in temp_frame_paths:temp_frame = cv2.imread(temp_frame_path)result_frame = process_frame(source_face, reference_face, temp_frame)5 unmodified linesdef 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 Noneresult_frame = process_frame(source_face, reference_face, target_frame)cv2.imwrite(output_path, result_frame)4 unmodified linesdef 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)set_face_reference(reference_face)2 unmodified lines3456789101112131415166 unmodified lines232425262728295 unmodified lines3536373839404142434445464748495051528 unmodified lines6162636465666768697071723 unmodified lines767778798081825 unmodified lines888990919293944 unmodified lines991001011021031041052 unmodified linesimport insightfaceimport threadingimport DeepFakeAI.globalsimport DeepFakeAI.processors.frame.core as frame_processorsfrom DeepFakeAI import wordingfrom DeepFakeAI.core import update_statusfrom DeepFakeAI.face_analyser import get_one_face, get_many_faces, find_similar_facesfrom DeepFakeAI.face_reference import get_face_reference, set_face_referencefrom DeepFakeAI.typing import Face, Framefrom DeepFakeAI.utilities import conditional_download, resolve_relative_path, is_image, is_videoFRAME_PROCESSOR = NoneTHREAD_LOCK = threading.Lock()6 unmodified lineswith 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 = DeepFakeAI.globals.execution_providers)return FRAME_PROCESSOR5 unmodified linesdef pre_check() -> bool:download_directory_path = resolve_relative_path('../.assets/models')conditional_download(download_directory_path, ['https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/models/inswapper_128.onnx'])return Truedef pre_process() -> bool:if not is_image(DeepFakeAI.globals.source_path):update_status(wording.get('select_image_source') + wording.get('exclamation_mark'), NAME)return Falseelif not get_one_face(cv2.imread(DeepFakeAI.globals.source_path)):update_status(wording.get('no_source_face_detected') + wording.get('exclamation_mark'), NAME)return Falseif 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 Falsereturn True8 unmodified linesdef process_frame(source_face : Face, reference_face : Face, temp_frame : Frame) -> Frame: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 DeepFakeAI.globals.face_recognition:many_faces = get_many_faces(temp_frame)if many_faces:for target_face in many_faces:3 unmodified linesdef 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 DeepFakeAI.globals.face_recognition else Nonefor temp_frame_path in temp_frame_paths:temp_frame = cv2.imread(temp_frame_path)result_frame = process_frame(source_face, reference_face, temp_frame)5 unmodified linesdef 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, DeepFakeAI.globals.reference_face_position) if 'reference' in DeepFakeAI.globals.face_recognition else Noneresult_frame = process_frame(source_face, reference_face, target_frame)cv2.imwrite(output_path, result_frame)4 unmodified linesdef conditional_set_face_reference(temp_frame_paths : List[str]) -> None: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)
3 unmodified lines45678910111234 unmodified lines474849505152533 unmodified linesfrom basicsr.archs.rrdbnet_arch import RRDBNetfrom realesrgan import RealESRGANerimport facefusion.processors.frame.core as frame_processorsfrom facefusion.typing import Frame, Facefrom facefusion.utilities import conditional_download, resolve_relative_pathFRAME_PROCESSOR = NoneTHREAD_SEMAPHORE = threading.Semaphore()34 unmodified linesdef 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'])return True3 unmodified lines45678910111234 unmodified lines474849505152533 unmodified linesfrom basicsr.archs.rrdbnet_arch import RRDBNetfrom realesrgan import RealESRGANerimport DeepFakeAI.processors.frame.core as frame_processorsfrom DeepFakeAI.typing import Frame, Facefrom DeepFakeAI.utilities import conditional_download, resolve_relative_pathFRAME_PROCESSOR = NoneTHREAD_SEMAPHORE = threading.Semaphore()34 unmodified linesdef pre_check() -> bool:download_directory_path = resolve_relative_path('../.assets/models')conditional_download(download_directory_path, ['https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/models/RealESRGAN_x4plus.pth'])return True
1234567from typing import Optionalimport gradiofrom facefusion import metadataABOUT_HTML : Optional[gradio.HTML] = None1234567from typing import Optionalimport gradiofrom DeepFakeAI import metadataABOUT_HTML : Optional[gradio.HTML] = None
3 unmodified lines45678910111213141549 unmodified lines6566676869707112 unmodified lines8485868788899091928 unmodified lines1011021031041051061073 unmodified lines1111121131141151163 unmodified linesimport statisticsimport gradioimport facefusion.globalsfrom facefusion import wordingfrom facefusion.capturer import get_video_frame_totalfrom facefusion.core import conditional_processfrom facefusion.uis.typing import Updatefrom facefusion.utilities import normalize_output_path, clear_tempBENCHMARK_RESULT_DATAFRAME : Optional[gradio.Dataframe] = NoneBENCHMARK_CYCLES_SLIDER : Optional[gradio.Button] = None49 unmodified linesdef update(benchmark_cycles : int) -> Update:facefusion.globals.source_path = '.assets/examples/source.jpg'target_paths =\['.assets/examples/target-240p.mp4',12 unmodified linesprocess_times = []total_fps = 0.0for i in range(benchmark_cycles + 1):facefusion.globals.target_path = target_pathfacefusion.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)start_time = time.perf_counter()conditional_process()end_time = time.perf_counter()8 unmodified linesrelative_fps = round(total_fps / benchmark_cycles, 2)return\[facefusion.globals.target_path,benchmark_cycles,average_run,fastest_run,3 unmodified linesdef clear() -> Update:if facefusion.globals.target_path:clear_temp(facefusion.globals.target_path)return gradio.update(value = None)3 unmodified lines45678910111213141549 unmodified lines6566676869707112 unmodified lines8485868788899091928 unmodified lines1011021031041051061073 unmodified lines1111121131141151163 unmodified linesimport statisticsimport gradioimport DeepFakeAI.globalsfrom DeepFakeAI import wordingfrom DeepFakeAI.capturer import get_video_frame_totalfrom DeepFakeAI.core import conditional_processfrom DeepFakeAI.uis.typing import Updatefrom DeepFakeAI.utilities import normalize_output_path, clear_tempBENCHMARK_RESULT_DATAFRAME : Optional[gradio.Dataframe] = NoneBENCHMARK_CYCLES_SLIDER : Optional[gradio.Button] = None49 unmodified linesdef update(benchmark_cycles : int) -> Update:DeepFakeAI.globals.source_path = '.assets/examples/source.jpg'target_paths =\['.assets/examples/target-240p.mp4',12 unmodified linesprocess_times = []total_fps = 0.0for i in range(benchmark_cycles + 1):DeepFakeAI.globals.target_path = target_pathDeepFakeAI.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()8 unmodified linesrelative_fps = round(total_fps / benchmark_cycles, 2)return\[DeepFakeAI.globals.target_path,benchmark_cycles,average_run,fastest_run,3 unmodified linesdef clear() -> Update:if DeepFakeAI.globals.target_path:clear_temp(DeepFakeAI.globals.target_path)return gradio.update(value = None)
1 unmodified line23456789101112139 unmodified lines2324252627282930313233343536373839409 unmodified lines5051525354555657585960616263641 unmodified lineimport gradioimport onnxruntimeimport facefusion.globalsfrom facefusion import wordingfrom facefusion.face_analyser import clear_face_analyserfrom facefusion.processors.frame.core import clear_frame_processors_modulesfrom facefusion.uis.typing import Updatefrom facefusion.utilities import encode_execution_providers, decode_execution_providersEXECUTION_PROVIDERS_CHECKBOX_GROUP : Optional[gradio.CheckboxGroup] = NoneEXECUTION_THREAD_COUNT_SLIDER : Optional[gradio.Slider] = None9 unmodified linesEXECUTION_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))EXECUTION_THREAD_COUNT_SLIDER = gradio.Slider(label = wording.get('execution_thread_count_slider_label'),value = facefusion.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,step = 1,minimum = 1,maximum = 169 unmodified linesdef update_execution_providers(execution_providers : List[str]) -> Update:clear_face_analyser()clear_frame_processors_modules()facefusion.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_countreturn gradio.update(value = execution_thread_count)def update_execution_queue_count(execution_queue_count : int = 1) -> Update:facefusion.globals.execution_queue_count = execution_queue_countreturn gradio.update(value = execution_queue_count)1 unmodified line23456789101112139 unmodified lines2324252627282930313233343536373839409 unmodified lines5051525354555657585960616263641 unmodified lineimport gradioimport onnxruntimeimport DeepFakeAI.globalsfrom DeepFakeAI import wordingfrom DeepFakeAI.face_analyser import clear_face_analyserfrom DeepFakeAI.processors.frame.core import clear_frame_processors_modulesfrom DeepFakeAI.uis.typing import Updatefrom DeepFakeAI.utilities import encode_execution_providers, decode_execution_providersEXECUTION_PROVIDERS_CHECKBOX_GROUP : Optional[gradio.CheckboxGroup] = NoneEXECUTION_THREAD_COUNT_SLIDER : Optional[gradio.Slider] = None9 unmodified linesEXECUTION_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(DeepFakeAI.globals.execution_providers))EXECUTION_THREAD_COUNT_SLIDER = gradio.Slider(label = wording.get('execution_thread_count_slider_label'),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 = DeepFakeAI.globals.execution_queue_count,step = 1,minimum = 1,maximum = 169 unmodified linesdef update_execution_providers(execution_providers : List[str]) -> Update:clear_face_analyser()clear_frame_processors_modules()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:DeepFakeAI.globals.execution_thread_count = execution_thread_countreturn gradio.update(value = execution_thread_count)def update_execution_queue_count(execution_queue_count : int = 1) -> Update:DeepFakeAI.globals.execution_queue_count = execution_queue_countreturn gradio.update(value = execution_queue_count)
1 unmodified line234567891011129 unmodified lines2223242526272829303132333435363738398 unmodified lines484950515253541 unmodified lineimport gradioimport facefusion.choicesimport facefusion.globalsfrom facefusion import wordingfrom facefusion.uis import core as uifrom facefusion.uis.typing import UpdateFACE_ANALYSER_DIRECTION_DROPDOWN : Optional[gradio.Dropdown] = NoneFACE_ANALYSER_AGE_DROPDOWN : Optional[gradio.Dropdown] = None9 unmodified lineswith 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)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')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')ui.register_component('face_analyser_direction_dropdown', FACE_ANALYSER_DIRECTION_DROPDOWN)ui.register_component('face_analyser_age_dropdown', FACE_ANALYSER_AGE_DROPDOWN)8 unmodified linesdef update_dropdown(name : str, value : str) -> Update:if value == 'none':setattr(facefusion.globals, name, None)else:setattr(facefusion.globals, name, value)return gradio.update(value = value)1 unmodified line234567891011129 unmodified lines2223242526272829303132333435363738398 unmodified lines484950515253541 unmodified lineimport gradioimport DeepFakeAI.choicesimport DeepFakeAI.globalsfrom DeepFakeAI import wordingfrom DeepFakeAI.uis import core as uifrom DeepFakeAI.uis.typing import UpdateFACE_ANALYSER_DIRECTION_DROPDOWN : Optional[gradio.Dropdown] = NoneFACE_ANALYSER_AGE_DROPDOWN : Optional[gradio.Dropdown] = None9 unmodified lineswith gradio.Row():FACE_ANALYSER_DIRECTION_DROPDOWN = gradio.Dropdown(label = wording.get('face_analyser_direction_dropdown_label'),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'] + 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'] + 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)8 unmodified linesdef update_dropdown(name : str, value : str) -> Update:if value == 'none':setattr(DeepFakeAI.globals, name, None)else:setattr(DeepFakeAI.globals, name, value)return gradio.update(value = value)
DeepFakeAI/__pycache__/__init__.cpython-310.pyc
DeepFakeAI/__pycache__/capturer.cpython-310.pyc
DeepFakeAI/__pycache__/choices.cpython-310.pyc
DeepFakeAI/__pycache__/core.cpython-310.pyc
DeepFakeAI/__pycache__/face_analyser.cpython-310.pyc
DeepFakeAI/__pycache__/face_reference.cpython-310.pyc
DeepFakeAI/__pycache__/globals.cpython-310.pyc
DeepFakeAI/__pycache__/metadata.cpython-310.pyc
DeepFakeAI/__pycache__/predictor.cpython-310.pyc
DeepFakeAI/__pycache__/typing.cpython-310.pyc
DeepFakeAI/__pycache__/utilities.cpython-310.pyc
DeepFakeAI/__pycache__/wording.cpython-310.pyc
DeepFakeAI/capturer.py+1-1
DeepFakeAI/choices.py+1-1
DeepFakeAI/core.py+69-69
DeepFakeAI/face_analyser.py+9-9
DeepFakeAI/face_reference.py+1-1
DeepFakeAI/globals.py+1-1
DeepFakeAI/metadata.py+1-1
DeepFakeAI/predictor.py+1-1
DeepFakeAI/processors/__pycache__/__init__.cpython-310.pyc
DeepFakeAI/processors/frame/__pycache__/__init__.cpython-310.pyc
DeepFakeAI/processors/frame/__pycache__/core.cpython-310.pyc
DeepFakeAI/processors/frame/core.py+11-11
DeepFakeAI/processors/frame/modules/__pycache__/__init__.cpython-310.pyc
DeepFakeAI/processors/frame/modules/__pycache__/face_swapper.cpython-310.pyc
DeepFakeAI/processors/frame/modules/face_enhancer.py+10-10
DeepFakeAI/processors/frame/modules/face_swapper.py+21-21
DeepFakeAI/processors/frame/modules/frame_enhancer.py+4-4
DeepFakeAI/uis/__pycache__/__init__.cpython-310.pyc
DeepFakeAI/uis/__pycache__/core.cpython-310.pyc
DeepFakeAI/uis/__pycache__/typing.cpython-310.pyc
DeepFakeAI/uis/components/__pycache__/__init__.cpython-310.pyc
DeepFakeAI/uis/components/__pycache__/about.cpython-310.pyc
DeepFakeAI/uis/components/__pycache__/execution.cpython-310.pyc
DeepFakeAI/uis/components/__pycache__/face_analyser.cpython-310.pyc
DeepFakeAI/uis/components/__pycache__/face_selector.cpython-310.pyc
DeepFakeAI/uis/components/__pycache__/output.cpython-310.pyc
DeepFakeAI/uis/components/__pycache__/output_settings.cpython-310.pyc
DeepFakeAI/uis/components/__pycache__/preview.cpython-310.pyc
DeepFakeAI/uis/components/__pycache__/processors.cpython-310.pyc
DeepFakeAI/uis/components/__pycache__/settings.cpython-310.pyc
DeepFakeAI/uis/components/__pycache__/source.cpython-310.pyc
DeepFakeAI/uis/components/__pycache__/target.cpython-310.pyc
DeepFakeAI/uis/components/__pycache__/temp_frame.cpython-310.pyc
DeepFakeAI/uis/components/__pycache__/trim_frame.cpython-310.pyc
DeepFakeAI/uis/components/about.py+1-1
DeepFakeAI/uis/components/benchmark.py+13-13
DeepFakeAI/uis/components/execution.py+12-12
DeepFakeAI/uis/components/face_analyser.py+13-13