From 33db393af9549948217daa32d93890fbdd904a2f Mon Sep 17 00:00:00 2001 From: Henry Ruhs Date: Tue, 26 Nov 2024 18:21:11 +0100 Subject: [PATCH] Introduce download scopes (#826) * Introduce download scopes * Limit download scopes to force-download command --- facefusion.ini | 1 + facefusion/args.py | 1 + facefusion/choices.py | 3 +- facefusion/content_analyser.py | 6 +- facefusion/core.py | 2 +- facefusion/face_classifier.py | 6 +- facefusion/face_detector.py | 6 +- facefusion/face_landmarker.py | 10 +- facefusion/face_masker.py | 10 +- facefusion/face_recognizer.py | 6 +- facefusion/processors/modules/age_modifier.py | 6 +- facefusion/processors/modules/deep_swapper.py | 315 +++++++++--------- .../processors/modules/expression_restorer.py | 6 +- facefusion/processors/modules/face_editor.py | 6 +- .../processors/modules/face_enhancer.py | 6 +- facefusion/processors/modules/face_swapper.py | 6 +- .../processors/modules/frame_colorizer.py | 6 +- .../processors/modules/frame_enhancer.py | 6 +- facefusion/processors/modules/lip_syncer.py | 6 +- facefusion/program.py | 10 +- facefusion/typing.py | 3 + facefusion/uis/components/face_detector.py | 4 +- facefusion/voice_extractor.py | 6 +- facefusion/wording.py | 1 + 24 files changed, 232 insertions(+), 206 deletions(-) diff --git a/facefusion.ini b/facefusion.ini index 52b2328a..e0bd2044 100644 --- a/facefusion.ini +++ b/facefusion.ini @@ -103,6 +103,7 @@ execution_queue_count = [download] download_providers = +download_scope = [memory] video_memory_strategy = diff --git a/facefusion/args.py b/facefusion/args.py index 266be649..98c67f43 100644 --- a/facefusion/args.py +++ b/facefusion/args.py @@ -120,6 +120,7 @@ def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None: apply_state_item('execution_queue_count', args.get('execution_queue_count')) # download apply_state_item('download_providers', args.get('download_providers')) + apply_state_item('download_scope', args.get('download_scope')) # memory apply_state_item('video_memory_strategy', args.get('video_memory_strategy')) apply_state_item('system_memory_limit', args.get('system_memory_limit')) diff --git a/facefusion/choices.py b/facefusion/choices.py index f22b6ab0..8476643b 100755 --- a/facefusion/choices.py +++ b/facefusion/choices.py @@ -2,7 +2,7 @@ import logging from typing import List, Sequence from facefusion.common_helper import create_float_range, create_int_range -from facefusion.typing import Angle, DownloadProviderSet, ExecutionProviderSet, FaceDetectorSet, FaceLandmarkerModel, FaceMaskRegion, FaceMaskType, FaceSelectorMode, FaceSelectorOrder, Gender, JobStatus, LogLevelSet, OutputAudioEncoder, OutputVideoEncoder, OutputVideoPreset, Race, Score, TempFrameFormat, UiWorkflow, VideoMemoryStrategy +from facefusion.typing import Angle, DownloadProviderSet, DownloadScope, ExecutionProviderSet, FaceDetectorSet, FaceLandmarkerModel, FaceMaskRegion, FaceMaskType, FaceSelectorMode, FaceSelectorOrder, Gender, JobStatus, LogLevelSet, OutputAudioEncoder, OutputVideoEncoder, OutputVideoPreset, Race, Score, TempFrameFormat, UiWorkflow, VideoMemoryStrategy video_memory_strategies : List[VideoMemoryStrategy] = [ 'strict', 'moderate', 'tolerant' ] @@ -43,6 +43,7 @@ download_provider_set : DownloadProviderSet =\ 'github': 'https://github.com/facefusion/facefusion-assets/releases/download/{base_name}/{file_name}', 'huggingface': 'https://huggingface.co/facefusion/{base_name}/resolve/main/{file_name}' } +download_scopes : List[DownloadScope] = [ 'lite', 'full' ] log_level_set : LogLevelSet =\ { diff --git a/facefusion/content_analyser.py b/facefusion/content_analyser.py index 34346283..5d1c7ce6 100644 --- a/facefusion/content_analyser.py +++ b/facefusion/content_analyser.py @@ -8,7 +8,7 @@ from facefusion import inference_manager, state_manager, wording from facefusion.download import conditional_download_hashes, conditional_download_sources, resolve_download_url from facefusion.filesystem import resolve_relative_path from facefusion.thread_helper import conditional_thread_semaphore -from facefusion.typing import Fps, InferencePool, ModelOptions, ModelSet, VisionFrame +from facefusion.typing import DownloadScope, Fps, InferencePool, ModelOptions, ModelSet, VisionFrame from facefusion.vision import count_video_frame_total, detect_video_fps, get_video_frame, read_image PROBABILITY_LIMIT = 0.80 @@ -17,7 +17,7 @@ STREAM_COUNTER = 0 @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { 'open_nsfw': @@ -54,7 +54,7 @@ def clear_inference_pool() -> None: def get_model_options() -> ModelOptions: - return create_static_model_set().get('open_nsfw') + return create_static_model_set('full').get('open_nsfw') def pre_check() -> bool: diff --git a/facefusion/core.py b/facefusion/core.py index 19b9393a..5775ef6a 100755 --- a/facefusion/core.py +++ b/facefusion/core.py @@ -138,7 +138,7 @@ def force_download() -> ErrorCode: for module in common_modules + processor_modules: if hasattr(module, 'create_static_model_set'): - for model in module.create_static_model_set().values(): + for model in module.create_static_model_set(state_manager.get_item('download_scope')).values(): model_hashes = model.get('hashes') model_sources = model.get('sources') diff --git a/facefusion/face_classifier.py b/facefusion/face_classifier.py index cd49c8a8..186a4aeb 100644 --- a/facefusion/face_classifier.py +++ b/facefusion/face_classifier.py @@ -8,11 +8,11 @@ from facefusion.download import conditional_download_hashes, conditional_downloa from facefusion.face_helper import warp_face_by_face_landmark_5 from facefusion.filesystem import resolve_relative_path from facefusion.thread_helper import conditional_thread_semaphore -from facefusion.typing import Age, FaceLandmark5, Gender, InferencePool, ModelOptions, ModelSet, Race, VisionFrame +from facefusion.typing import Age, DownloadScope, FaceLandmark5, Gender, InferencePool, ModelOptions, ModelSet, Race, VisionFrame @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { 'fairface': @@ -51,7 +51,7 @@ def clear_inference_pool() -> None: def get_model_options() -> ModelOptions: - return create_static_model_set().get('fairface') + return create_static_model_set('full').get('fairface') def pre_check() -> bool: diff --git a/facefusion/face_detector.py b/facefusion/face_detector.py index 4c82220b..61323149 100644 --- a/facefusion/face_detector.py +++ b/facefusion/face_detector.py @@ -9,12 +9,12 @@ from facefusion.download import conditional_download_hashes, conditional_downloa from facefusion.face_helper import create_rotated_matrix_and_size, create_static_anchors, distance_to_bounding_box, distance_to_face_landmark_5, normalize_bounding_box, transform_bounding_box, transform_points from facefusion.filesystem import resolve_relative_path from facefusion.thread_helper import thread_semaphore -from facefusion.typing import Angle, BoundingBox, Detection, DownloadSet, FaceLandmark5, InferencePool, ModelSet, Score, VisionFrame +from facefusion.typing import Angle, BoundingBox, Detection, DownloadScope, DownloadSet, FaceLandmark5, InferencePool, ModelSet, Score, VisionFrame from facefusion.vision import resize_frame_resolution, unpack_resolution @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { 'retinaface': @@ -91,7 +91,7 @@ def clear_inference_pool() -> None: def collect_model_downloads() -> Tuple[DownloadSet, DownloadSet]: model_hashes = {} model_sources = {} - model_set = create_static_model_set() + model_set = create_static_model_set('full') if state_manager.get_item('face_detector_model') in [ 'many', 'retinaface' ]: model_hashes['retinaface'] = model_set.get('retinaface').get('hashes').get('retinaface') diff --git a/facefusion/face_landmarker.py b/facefusion/face_landmarker.py index dd9a8933..56b6645e 100644 --- a/facefusion/face_landmarker.py +++ b/facefusion/face_landmarker.py @@ -9,11 +9,11 @@ from facefusion.download import conditional_download_hashes, conditional_downloa from facefusion.face_helper import create_rotated_matrix_and_size, estimate_matrix_by_face_landmark_5, transform_points, warp_face_by_translation from facefusion.filesystem import resolve_relative_path from facefusion.thread_helper import conditional_thread_semaphore -from facefusion.typing import Angle, BoundingBox, DownloadSet, FaceLandmark5, FaceLandmark68, InferencePool, ModelSet, Prediction, Score, VisionFrame +from facefusion.typing import Angle, BoundingBox, DownloadScope, DownloadSet, FaceLandmark5, FaceLandmark68, InferencePool, ModelSet, Prediction, Score, VisionFrame @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { '2dfan4': @@ -90,7 +90,7 @@ def clear_inference_pool() -> None: def collect_model_downloads() -> Tuple[DownloadSet, DownloadSet]: - model_set = create_static_model_set() + model_set = create_static_model_set('full') model_hashes =\ { 'fan_68_5': model_set.get('fan_68_5').get('hashes').get('fan_68_5') @@ -132,7 +132,7 @@ def detect_face_landmarks(vision_frame : VisionFrame, bounding_box : BoundingBox def detect_with_2dfan4(temp_vision_frame: VisionFrame, bounding_box: BoundingBox, face_angle: Angle) -> Tuple[FaceLandmark68, Score]: - model_size = create_static_model_set().get('2dfan4').get('size') + model_size = create_static_model_set('full').get('2dfan4').get('size') scale = 195 / numpy.subtract(bounding_box[2:], bounding_box[:2]).max().clip(1, None) translation = (model_size[0] - numpy.add(bounding_box[2:], bounding_box[:2]) * scale) * 0.5 rotated_matrix, rotated_size = create_rotated_matrix_and_size(face_angle, model_size) @@ -151,7 +151,7 @@ def detect_with_2dfan4(temp_vision_frame: VisionFrame, bounding_box: BoundingBox def detect_with_peppa_wutz(temp_vision_frame : VisionFrame, bounding_box : BoundingBox, face_angle : Angle) -> Tuple[FaceLandmark68, Score]: - model_size = create_static_model_set().get('peppa_wutz').get('size') + model_size = create_static_model_set('full').get('peppa_wutz').get('size') scale = 195 / numpy.subtract(bounding_box[2:], bounding_box[:2]).max().clip(1, None) translation = (model_size[0] - numpy.add(bounding_box[2:], bounding_box[:2]) * scale) * 0.5 rotated_matrix, rotated_size = create_rotated_matrix_and_size(face_angle, model_size) diff --git a/facefusion/face_masker.py b/facefusion/face_masker.py index 7aa51373..52d3198b 100755 --- a/facefusion/face_masker.py +++ b/facefusion/face_masker.py @@ -9,7 +9,7 @@ from facefusion import inference_manager from facefusion.download import conditional_download_hashes, conditional_download_sources, resolve_download_url from facefusion.filesystem import resolve_relative_path from facefusion.thread_helper import conditional_thread_semaphore -from facefusion.typing import DownloadSet, FaceLandmark68, FaceMaskRegion, InferencePool, Mask, ModelSet, Padding, VisionFrame +from facefusion.typing import DownloadScope, DownloadSet, FaceLandmark68, FaceMaskRegion, InferencePool, Mask, ModelSet, Padding, VisionFrame FACE_MASK_REGIONS : Dict[FaceMaskRegion, int] =\ { @@ -27,7 +27,7 @@ FACE_MASK_REGIONS : Dict[FaceMaskRegion, int] =\ @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { 'face_occluder': @@ -83,7 +83,7 @@ def clear_inference_pool() -> None: def collect_model_downloads() -> Tuple[DownloadSet, DownloadSet]: - model_set = create_static_model_set() + model_set = create_static_model_set('full') model_hashes =\ { 'face_occluder': model_set.get('face_occluder').get('hashes').get('face_occluder'), @@ -118,7 +118,7 @@ def create_static_box_mask(crop_size : Size, face_mask_blur : float, face_mask_p def create_occlusion_mask(crop_vision_frame : VisionFrame) -> Mask: - model_size = create_static_model_set().get('face_occluder').get('size') + model_size = create_static_model_set('full').get('face_occluder').get('size') prepare_vision_frame = cv2.resize(crop_vision_frame, model_size) prepare_vision_frame = numpy.expand_dims(prepare_vision_frame, axis = 0).astype(numpy.float32) / 255 prepare_vision_frame = prepare_vision_frame.transpose(0, 1, 2, 3) @@ -130,7 +130,7 @@ def create_occlusion_mask(crop_vision_frame : VisionFrame) -> Mask: def create_region_mask(crop_vision_frame : VisionFrame, face_mask_regions : List[FaceMaskRegion]) -> Mask: - model_size = create_static_model_set().get('face_parser').get('size') + model_size = create_static_model_set('full').get('face_parser').get('size') prepare_vision_frame = cv2.resize(crop_vision_frame, model_size) prepare_vision_frame = prepare_vision_frame[:, :, ::-1].astype(numpy.float32) / 255 prepare_vision_frame = numpy.subtract(prepare_vision_frame, numpy.array([ 0.485, 0.456, 0.406 ]).astype(numpy.float32)) diff --git a/facefusion/face_recognizer.py b/facefusion/face_recognizer.py index df4f46c5..9bcd703b 100644 --- a/facefusion/face_recognizer.py +++ b/facefusion/face_recognizer.py @@ -8,11 +8,11 @@ from facefusion.download import conditional_download_hashes, conditional_downloa from facefusion.face_helper import warp_face_by_face_landmark_5 from facefusion.filesystem import resolve_relative_path from facefusion.thread_helper import conditional_thread_semaphore -from facefusion.typing import Embedding, FaceLandmark5, InferencePool, ModelOptions, ModelSet, VisionFrame +from facefusion.typing import DownloadScope, Embedding, FaceLandmark5, InferencePool, ModelOptions, ModelSet, VisionFrame @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { 'arcface': @@ -49,7 +49,7 @@ def clear_inference_pool() -> None: def get_model_options() -> ModelOptions: - return create_static_model_set().get('arcface') + return create_static_model_set('full').get('arcface') def pre_check() -> bool: diff --git a/facefusion/processors/modules/age_modifier.py b/facefusion/processors/modules/age_modifier.py index b5888280..bc254951 100755 --- a/facefusion/processors/modules/age_modifier.py +++ b/facefusion/processors/modules/age_modifier.py @@ -23,12 +23,12 @@ from facefusion.processors import choices as processors_choices from facefusion.processors.typing import AgeModifierDirection, AgeModifierInputs from facefusion.program_helper import find_argument_group from facefusion.thread_helper import thread_semaphore -from facefusion.typing import ApplyStateItem, Args, Face, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame +from facefusion.typing import ApplyStateItem, Args, DownloadScope, Face, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame from facefusion.vision import match_frame_color, read_image, read_static_image, write_image @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { 'styleganex_age': @@ -76,7 +76,7 @@ def clear_inference_pool() -> None: def get_model_options() -> ModelOptions: age_modifier_model = state_manager.get_item('age_modifier_model') - return create_static_model_set().get(age_modifier_model) + return create_static_model_set('full').get(age_modifier_model) def register_args(program : ArgumentParser) -> None: diff --git a/facefusion/processors/modules/deep_swapper.py b/facefusion/processors/modules/deep_swapper.py index dc9d034f..fdb988eb 100755 --- a/facefusion/processors/modules/deep_swapper.py +++ b/facefusion/processors/modules/deep_swapper.py @@ -21,161 +21,172 @@ from facefusion.processors import choices as processors_choices from facefusion.processors.typing import DeepSwapperInputs, DeepSwapperMorph from facefusion.program_helper import find_argument_group from facefusion.thread_helper import thread_semaphore -from facefusion.typing import ApplyStateItem, Args, Face, InferencePool, Mask, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame +from facefusion.typing import ApplyStateItem, Args, DownloadScope, Face, InferencePool, Mask, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame from facefusion.vision import conditional_match_frame_color, read_image, read_static_image, write_image @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: - model_config =\ - [ - ('druuzil', 'adrianne_palicki_384', (384, 384)), - ('druuzil', 'agnetha_falskog_224', (224, 224)), - ('druuzil', 'alan_ritchson_320', (320, 320)), - ('druuzil', 'alicia_vikander_320', (320, 320)), - ('druuzil', 'amber_midthunder_320', (320, 320)), - ('druuzil', 'andras_arato_384', (384, 384)), - ('druuzil', 'andrew_tate_320', (320, 320)), - ('druuzil', 'anne_hathaway_320', (320, 320)), - ('druuzil', 'anya_chalotra_320', (320, 320)), - ('druuzil', 'arnold_schwarzenegger_320', (320, 320)), - ('druuzil', 'benjamin_affleck_320', (320, 320)), - ('druuzil', 'benjamin_stiller_384', (384, 384)), - ('druuzil', 'bradley_pitt_224', (224, 224)), - ('druuzil', 'bryan_cranston_320', (320, 320)), - ('druuzil', 'catherine_blanchett_352', (352, 352)), - ('druuzil', 'christian_bale_320', (320, 320)), - ('druuzil', 'christopher_hemsworth_320', (320, 320)), - ('druuzil', 'christoph_waltz_384', (384, 384)), - ('druuzil', 'cillian_murphy_320', (320, 320)), - ('druuzil', 'cobie_smulders_256', (256, 256)), - ('druuzil', 'dwayne_johnson_384', (384, 384)), - ('druuzil', 'edward_norton_320', (320, 320)), - ('druuzil', 'elisabeth_shue_320', (320, 320)), - ('druuzil', 'elizabeth_olsen_384', (384, 384)), - ('druuzil', 'elon_musk_320', (320, 320)), - ('druuzil', 'emily_blunt_320', (320, 320)), - ('druuzil', 'emma_stone_384', (384, 384)), - ('druuzil', 'emma_watson_320', (320, 320)), - ('druuzil', 'erin_moriarty_384', (384, 384)), - ('druuzil', 'eva_green_320', (320, 320)), - ('druuzil', 'ewan_mcgregor_320', (320, 320)), - ('druuzil', 'florence_pugh_320', (320, 320)), - ('druuzil', 'freya_allan_320', (320, 320)), - ('druuzil', 'gary_cole_224', (224, 224)), - ('druuzil', 'gigi_hadid_224', (224, 224)), - ('druuzil', 'harrison_ford_384', (384, 384)), - ('druuzil', 'hayden_christensen_320', (320, 320)), - ('druuzil', 'heath_ledger_320', (320, 320)), - ('druuzil', 'henry_cavill_448', (448, 448)), - ('druuzil', 'hugh_jackman_384', (384, 384)), - ('druuzil', 'idris_elba_320', (320, 320)), - ('druuzil', 'jack_nicholson_320', (320, 320)), - ('druuzil', 'james_mcavoy_320', (320, 320)), - ('druuzil', 'james_varney_320', (320, 320)), - ('druuzil', 'jason_momoa_320', (320, 320)), - ('druuzil', 'jason_statham_320', (320, 320)), - ('druuzil', 'jennifer_connelly_384', (384, 384)), - ('druuzil', 'jimmy_donaldson_320', (320, 320)), - ('druuzil', 'jordan_peterson_384', (384, 384)), - ('druuzil', 'karl_urban_224', (224, 224)), - ('druuzil', 'kate_beckinsale_384', (384, 384)), - ('druuzil', 'laurence_fishburne_384', (384, 384)), - ('druuzil', 'lili_reinhart_320', (320, 320)), - ('druuzil', 'mads_mikkelsen_384', (384, 384)), - ('druuzil', 'mary_winstead_320', (320, 320)), - ('druuzil', 'melina_juergens_320', (320, 320)), - ('druuzil', 'michael_fassbender_320', (320, 320)), - ('druuzil', 'michael_fox_320', (320, 320)), - ('druuzil', 'millie_bobby_brown_320', (320, 320)), - ('druuzil', 'morgan_freeman_320', (320, 320)), - ('druuzil', 'patrick_stewart_320', (320, 320)), - ('druuzil', 'rebecca_ferguson_320', (320, 320)), - ('druuzil', 'scarlett_johansson_320', (320, 320)), - ('druuzil', 'seth_macfarlane_384', (384, 384)), - ('druuzil', 'thomas_cruise_320', (320, 320)), - ('druuzil', 'thomas_hanks_384', (384, 384)), - ('edel', 'emma_roberts_224', (224, 224)), - ('edel', 'ivanka_trump_224', (224, 224)), - ('edel', 'lize_dzjabrailova_224', (224, 224)), - ('edel', 'sidney_sweeney_224', (224, 224)), - ('edel', 'winona_ryder_224', (224, 224)), - ('iperov', 'alexandra_daddario_224', (224, 224)), - ('iperov', 'alexei_navalny_224', (224, 224)), - ('iperov', 'amber_heard_224', (224, 224)), - ('iperov', 'dilraba_dilmurat_224', (224, 224)), - ('iperov', 'elon_musk_224', (224, 224)), - ('iperov', 'emilia_clarke_224', (224, 224)), - ('iperov', 'emma_watson_224', (224, 224)), - ('iperov', 'erin_moriarty_224', (224, 224)), - ('iperov', 'jackie_chan_224', (224, 224)), - ('iperov', 'james_carrey_224', (224, 224)), - ('iperov', 'jason_statham_320', (320, 320)), - ('iperov', 'keanu_reeves_320', (320, 320)), - ('iperov', 'margot_robbie_224', (224, 224)), - ('iperov', 'natalie_dormer_224', (224, 224)), - ('iperov', 'nicolas_coppola_224', (224, 224)), - ('iperov', 'robert_downey_224', (224, 224)), - ('iperov', 'rowan_atkinson_224', (224, 224)), - ('iperov', 'ryan_reynolds_224', (224, 224)), - ('iperov', 'scarlett_johansson_224', (224, 224)), - ('iperov', 'sylvester_stallone_224', (224, 224)), - ('iperov', 'thomas_cruise_224', (224, 224)), - ('iperov', 'thomas_holland_224', (224, 224)), - ('iperov', 'vin_diesel_224', (224, 224)), - ('iperov', 'vladimir_putin_224', (224, 224)), - ('jen', 'angelica_trae_288', (288, 288)), - ('jen', 'ella_freya_224', (224, 224)), - ('jen', 'emma_myers_320', (320, 320)), - ('jen', 'evie_pickerill_224', (224, 224)), - ('jen', 'kang_hyewon_320', (320, 320)), - ('jen', 'maddie_mead_224', (224, 224)), - ('jen', 'nicole_turnbull_288', (288, 288)), - ('mats', 'alica_schmidt_320', (320, 320)), - ('mats', 'ashley_alexiss_224', (224, 224)), - ('mats', 'billie_eilish_224', (224, 224)), - ('mats', 'brie_larson_224', (224, 224)), - ('mats', 'cara_delevingne_224', (224, 224)), - ('mats', 'carolin_kebekus_224', (224, 224)), - ('mats', 'chelsea_clinton_224', (224, 224)), - ('mats', 'claire_boucher_224', (224, 224)), - ('mats', 'corinna_kopf_224', (224, 224)), - ('mats', 'florence_pugh_224', (224, 224)), - ('mats', 'hillary_clinton_224', (224, 224)), - ('mats', 'jenna_fischer_224', (224, 224)), - ('mats', 'kim_jisoo_320', (320, 320)), - ('mats', 'mica_suarez_320', (320, 320)), - ('mats', 'shailene_woodley_224', (224, 224)), - ('mats', 'shraddha_kapoor_320', (320, 320)), - ('mats', 'yu_jimin_352', (352, 352)), - ('rumateus', 'alison_brie_224', (224, 224)), - ('rumateus', 'amber_heard_224', (224, 224)), - ('rumateus', 'angelina_jolie_224', (224, 224)), - ('rumateus', 'aubrey_plaza_224', (224, 224)), - ('rumateus', 'bridget_regan_224', (224, 224)), - ('rumateus', 'cobie_smulders_224', (224, 224)), - ('rumateus', 'deborah_woll_224', (224, 224)), - ('rumateus', 'dua_lipa_224', (224, 224)), - ('rumateus', 'emma_stone_224', (224, 224)), - ('rumateus', 'hailee_steinfeld_224', (224, 224)), - ('rumateus', 'hilary_duff_224', (224, 224)), - ('rumateus', 'jessica_alba_224', (224, 224)), - ('rumateus', 'jessica_biel_224', (224, 224)), - ('rumateus', 'john_cena_224', (224, 224)), - ('rumateus', 'kim_kardashian_224', (224, 224)), - ('rumateus', 'kristen_bell_224', (224, 224)), - ('rumateus', 'lucy_liu_224', (224, 224)), - ('rumateus', 'margot_robbie_224', (224, 224)), - ('rumateus', 'megan_fox_224', (224, 224)), - ('rumateus', 'meghan_markle_224', (224, 224)), - ('rumateus', 'millie_bobby_brown_224', (224, 224)), - ('rumateus', 'natalie_portman_224', (224, 224)), - ('rumateus', 'nicki_minaj_224', (224, 224)), - ('rumateus', 'olivia_wilde_224', (224, 224)), - ('rumateus', 'shay_mitchell_224', (224, 224)), - ('rumateus', 'sophie_turner_224', (224, 224)), - ('rumateus', 'taylor_swift_224', (224, 224)) - ] +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: + model_config = [] + + if download_scope == 'full': + model_config.extend( + [ + ('druuzil', 'adrianne_palicki_384', (384, 384)), + ('druuzil', 'agnetha_falskog_224', (224, 224)), + ('druuzil', 'alan_ritchson_320', (320, 320)), + ('druuzil', 'alicia_vikander_320', (320, 320)), + ('druuzil', 'amber_midthunder_320', (320, 320)), + ('druuzil', 'andras_arato_384', (384, 384)), + ('druuzil', 'andrew_tate_320', (320, 320)), + ('druuzil', 'anne_hathaway_320', (320, 320)), + ('druuzil', 'anya_chalotra_320', (320, 320)), + ('druuzil', 'arnold_schwarzenegger_320', (320, 320)), + ('druuzil', 'benjamin_affleck_320', (320, 320)), + ('druuzil', 'benjamin_stiller_384', (384, 384)), + ('druuzil', 'bradley_pitt_224', (224, 224)), + ('druuzil', 'bryan_cranston_320', (320, 320)), + ('druuzil', 'catherine_blanchett_352', (352, 352)), + ('druuzil', 'christian_bale_320', (320, 320)), + ('druuzil', 'christopher_hemsworth_320', (320, 320)), + ('druuzil', 'christoph_waltz_384', (384, 384)), + ('druuzil', 'cillian_murphy_320', (320, 320)), + ('druuzil', 'cobie_smulders_256', (256, 256)), + ('druuzil', 'dwayne_johnson_384', (384, 384)), + ('druuzil', 'edward_norton_320', (320, 320)), + ('druuzil', 'elisabeth_shue_320', (320, 320)), + ('druuzil', 'elizabeth_olsen_384', (384, 384)), + ('druuzil', 'elon_musk_320', (320, 320)), + ('druuzil', 'emily_blunt_320', (320, 320)), + ('druuzil', 'emma_stone_384', (384, 384)), + ('druuzil', 'emma_watson_320', (320, 320)), + ('druuzil', 'erin_moriarty_384', (384, 384)), + ('druuzil', 'eva_green_320', (320, 320)), + ('druuzil', 'ewan_mcgregor_320', (320, 320)), + ('druuzil', 'florence_pugh_320', (320, 320)), + ('druuzil', 'freya_allan_320', (320, 320)), + ('druuzil', 'gary_cole_224', (224, 224)), + ('druuzil', 'gigi_hadid_224', (224, 224)), + ('druuzil', 'harrison_ford_384', (384, 384)), + ('druuzil', 'hayden_christensen_320', (320, 320)), + ('druuzil', 'heath_ledger_320', (320, 320)), + ('druuzil', 'henry_cavill_448', (448, 448)), + ('druuzil', 'hugh_jackman_384', (384, 384)), + ('druuzil', 'idris_elba_320', (320, 320)), + ('druuzil', 'jack_nicholson_320', (320, 320)), + ('druuzil', 'james_mcavoy_320', (320, 320)), + ('druuzil', 'james_varney_320', (320, 320)), + ('druuzil', 'jason_momoa_320', (320, 320)), + ('druuzil', 'jason_statham_320', (320, 320)), + ('druuzil', 'jennifer_connelly_384', (384, 384)), + ('druuzil', 'jimmy_donaldson_320', (320, 320)), + ('druuzil', 'jordan_peterson_384', (384, 384)), + ('druuzil', 'karl_urban_224', (224, 224)), + ('druuzil', 'kate_beckinsale_384', (384, 384)), + ('druuzil', 'laurence_fishburne_384', (384, 384)), + ('druuzil', 'lili_reinhart_320', (320, 320)), + ('druuzil', 'mads_mikkelsen_384', (384, 384)), + ('druuzil', 'mary_winstead_320', (320, 320)), + ('druuzil', 'melina_juergens_320', (320, 320)), + ('druuzil', 'michael_fassbender_320', (320, 320)), + ('druuzil', 'michael_fox_320', (320, 320)), + ('druuzil', 'millie_bobby_brown_320', (320, 320)), + ('druuzil', 'morgan_freeman_320', (320, 320)), + ('druuzil', 'patrick_stewart_320', (320, 320)), + ('druuzil', 'rebecca_ferguson_320', (320, 320)), + ('druuzil', 'scarlett_johansson_320', (320, 320)), + ('druuzil', 'seth_macfarlane_384', (384, 384)), + ('druuzil', 'thomas_cruise_320', (320, 320)), + ('druuzil', 'thomas_hanks_384', (384, 384)), + ('edel', 'emma_roberts_224', (224, 224)), + ('edel', 'ivanka_trump_224', (224, 224)), + ('edel', 'lize_dzjabrailova_224', (224, 224)), + ('edel', 'sidney_sweeney_224', (224, 224)), + ('edel', 'winona_ryder_224', (224, 224)) + ]) + if download_scope in [ 'lite', 'full' ]: + model_config.extend( + [ + ('iperov', 'alexandra_daddario_224', (224, 224)), + ('iperov', 'alexei_navalny_224', (224, 224)), + ('iperov', 'amber_heard_224', (224, 224)), + ('iperov', 'dilraba_dilmurat_224', (224, 224)), + ('iperov', 'elon_musk_224', (224, 224)), + ('iperov', 'emilia_clarke_224', (224, 224)), + ('iperov', 'emma_watson_224', (224, 224)), + ('iperov', 'erin_moriarty_224', (224, 224)), + ('iperov', 'jackie_chan_224', (224, 224)), + ('iperov', 'james_carrey_224', (224, 224)), + ('iperov', 'jason_statham_320', (320, 320)), + ('iperov', 'keanu_reeves_320', (320, 320)), + ('iperov', 'margot_robbie_224', (224, 224)), + ('iperov', 'natalie_dormer_224', (224, 224)), + ('iperov', 'nicolas_coppola_224', (224, 224)), + ('iperov', 'robert_downey_224', (224, 224)), + ('iperov', 'rowan_atkinson_224', (224, 224)), + ('iperov', 'ryan_reynolds_224', (224, 224)), + ('iperov', 'scarlett_johansson_224', (224, 224)), + ('iperov', 'sylvester_stallone_224', (224, 224)), + ('iperov', 'thomas_cruise_224', (224, 224)), + ('iperov', 'thomas_holland_224', (224, 224)), + ('iperov', 'vin_diesel_224', (224, 224)), + ('iperov', 'vladimir_putin_224', (224, 224)) + ]) + if download_scope == 'full': + model_config.extend( + [ + ('jen', 'angelica_trae_288', (288, 288)), + ('jen', 'ella_freya_224', (224, 224)), + ('jen', 'emma_myers_320', (320, 320)), + ('jen', 'evie_pickerill_224', (224, 224)), + ('jen', 'kang_hyewon_320', (320, 320)), + ('jen', 'maddie_mead_224', (224, 224)), + ('jen', 'nicole_turnbull_288', (288, 288)), + ('mats', 'alica_schmidt_320', (320, 320)), + ('mats', 'ashley_alexiss_224', (224, 224)), + ('mats', 'billie_eilish_224', (224, 224)), + ('mats', 'brie_larson_224', (224, 224)), + ('mats', 'cara_delevingne_224', (224, 224)), + ('mats', 'carolin_kebekus_224', (224, 224)), + ('mats', 'chelsea_clinton_224', (224, 224)), + ('mats', 'claire_boucher_224', (224, 224)), + ('mats', 'corinna_kopf_224', (224, 224)), + ('mats', 'florence_pugh_224', (224, 224)), + ('mats', 'hillary_clinton_224', (224, 224)), + ('mats', 'jenna_fischer_224', (224, 224)), + ('mats', 'kim_jisoo_320', (320, 320)), + ('mats', 'mica_suarez_320', (320, 320)), + ('mats', 'shailene_woodley_224', (224, 224)), + ('mats', 'shraddha_kapoor_320', (320, 320)), + ('mats', 'yu_jimin_352', (352, 352)), + ('rumateus', 'alison_brie_224', (224, 224)), + ('rumateus', 'amber_heard_224', (224, 224)), + ('rumateus', 'angelina_jolie_224', (224, 224)), + ('rumateus', 'aubrey_plaza_224', (224, 224)), + ('rumateus', 'bridget_regan_224', (224, 224)), + ('rumateus', 'cobie_smulders_224', (224, 224)), + ('rumateus', 'deborah_woll_224', (224, 224)), + ('rumateus', 'dua_lipa_224', (224, 224)), + ('rumateus', 'emma_stone_224', (224, 224)), + ('rumateus', 'hailee_steinfeld_224', (224, 224)), + ('rumateus', 'hilary_duff_224', (224, 224)), + ('rumateus', 'jessica_alba_224', (224, 224)), + ('rumateus', 'jessica_biel_224', (224, 224)), + ('rumateus', 'john_cena_224', (224, 224)), + ('rumateus', 'kim_kardashian_224', (224, 224)), + ('rumateus', 'kristen_bell_224', (224, 224)), + ('rumateus', 'lucy_liu_224', (224, 224)), + ('rumateus', 'margot_robbie_224', (224, 224)), + ('rumateus', 'megan_fox_224', (224, 224)), + ('rumateus', 'meghan_markle_224', (224, 224)), + ('rumateus', 'millie_bobby_brown_224', (224, 224)), + ('rumateus', 'natalie_portman_224', (224, 224)), + ('rumateus', 'nicki_minaj_224', (224, 224)), + ('rumateus', 'olivia_wilde_224', (224, 224)), + ('rumateus', 'shay_mitchell_224', (224, 224)), + ('rumateus', 'sophie_turner_224', (224, 224)), + ('rumateus', 'taylor_swift_224', (224, 224)) + ]) model_set : ModelSet = {} for model_creator, model_name, model_size in model_config: @@ -219,7 +230,7 @@ def clear_inference_pool() -> None: def get_model_options() -> ModelOptions: deep_swapper_model = state_manager.get_item('deep_swapper_model') - return create_static_model_set().get(deep_swapper_model) + return create_static_model_set('full').get(deep_swapper_model) def register_args(program : ArgumentParser) -> None: diff --git a/facefusion/processors/modules/expression_restorer.py b/facefusion/processors/modules/expression_restorer.py index 7fe3e9d4..a7770065 100755 --- a/facefusion/processors/modules/expression_restorer.py +++ b/facefusion/processors/modules/expression_restorer.py @@ -23,12 +23,12 @@ from facefusion.processors.typing import ExpressionRestorerInputs from facefusion.processors.typing import LivePortraitExpression, LivePortraitFeatureVolume, LivePortraitMotionPoints, LivePortraitPitch, LivePortraitRoll, LivePortraitScale, LivePortraitTranslation, LivePortraitYaw from facefusion.program_helper import find_argument_group from facefusion.thread_helper import conditional_thread_semaphore, thread_semaphore -from facefusion.typing import ApplyStateItem, Args, Face, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame +from facefusion.typing import ApplyStateItem, Args, DownloadScope, Face, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame from facefusion.vision import get_video_frame, read_image, read_static_image, write_image @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { 'live_portrait': @@ -87,7 +87,7 @@ def clear_inference_pool() -> None: def get_model_options() -> ModelOptions: expression_restorer_model = state_manager.get_item('expression_restorer_model') - return create_static_model_set().get(expression_restorer_model) + return create_static_model_set('full').get(expression_restorer_model) def register_args(program : ArgumentParser) -> None: diff --git a/facefusion/processors/modules/face_editor.py b/facefusion/processors/modules/face_editor.py index 4f9bac95..b82ce174 100755 --- a/facefusion/processors/modules/face_editor.py +++ b/facefusion/processors/modules/face_editor.py @@ -22,12 +22,12 @@ from facefusion.processors.live_portrait import create_rotation, limit_euler_ang from facefusion.processors.typing import FaceEditorInputs, LivePortraitExpression, LivePortraitFeatureVolume, LivePortraitMotionPoints, LivePortraitPitch, LivePortraitRoll, LivePortraitRotation, LivePortraitScale, LivePortraitTranslation, LivePortraitYaw from facefusion.program_helper import find_argument_group from facefusion.thread_helper import conditional_thread_semaphore, thread_semaphore -from facefusion.typing import ApplyStateItem, Args, Face, FaceLandmark68, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame +from facefusion.typing import ApplyStateItem, Args, DownloadScope, Face, FaceLandmark68, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame from facefusion.vision import read_image, read_static_image, write_image @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { 'live_portrait': @@ -117,7 +117,7 @@ def clear_inference_pool() -> None: def get_model_options() -> ModelOptions: face_editor_model = state_manager.get_item('face_editor_model') - return create_static_model_set().get(face_editor_model) + return create_static_model_set('full').get(face_editor_model) def register_args(program : ArgumentParser) -> None: diff --git a/facefusion/processors/modules/face_enhancer.py b/facefusion/processors/modules/face_enhancer.py index d539d0dd..79fb2400 100755 --- a/facefusion/processors/modules/face_enhancer.py +++ b/facefusion/processors/modules/face_enhancer.py @@ -21,12 +21,12 @@ from facefusion.processors import choices as processors_choices from facefusion.processors.typing import FaceEnhancerInputs, FaceEnhancerWeight from facefusion.program_helper import find_argument_group from facefusion.thread_helper import thread_semaphore -from facefusion.typing import ApplyStateItem, Args, Face, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame +from facefusion.typing import ApplyStateItem, Args, DownloadScope, Face, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame from facefusion.vision import read_image, read_static_image, write_image @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { 'codeformer': @@ -234,7 +234,7 @@ def clear_inference_pool() -> None: def get_model_options() -> ModelOptions: face_enhancer_model = state_manager.get_item('face_enhancer_model') - return create_static_model_set().get(face_enhancer_model) + return create_static_model_set('full').get(face_enhancer_model) def register_args(program : ArgumentParser) -> None: diff --git a/facefusion/processors/modules/face_swapper.py b/facefusion/processors/modules/face_swapper.py index 44d63075..30a9873c 100755 --- a/facefusion/processors/modules/face_swapper.py +++ b/facefusion/processors/modules/face_swapper.py @@ -24,12 +24,12 @@ from facefusion.processors.pixel_boost import explode_pixel_boost, implode_pixel from facefusion.processors.typing import FaceSwapperInputs from facefusion.program_helper import find_argument_group from facefusion.thread_helper import conditional_thread_semaphore -from facefusion.typing import ApplyStateItem, Args, Embedding, Face, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame +from facefusion.typing import ApplyStateItem, Args, DownloadScope, Embedding, Face, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame from facefusion.vision import read_image, read_static_image, read_static_images, unpack_resolution, write_image @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { 'blendswap_256': @@ -348,7 +348,7 @@ def clear_inference_pool() -> None: def get_model_options() -> ModelOptions: face_swapper_model = state_manager.get_item('face_swapper_model') - return create_static_model_set().get(face_swapper_model) + return create_static_model_set('full').get(face_swapper_model) def register_args(program : ArgumentParser) -> None: diff --git a/facefusion/processors/modules/frame_colorizer.py b/facefusion/processors/modules/frame_colorizer.py index 521bc474..c09ea555 100644 --- a/facefusion/processors/modules/frame_colorizer.py +++ b/facefusion/processors/modules/frame_colorizer.py @@ -16,12 +16,12 @@ from facefusion.processors import choices as processors_choices from facefusion.processors.typing import FrameColorizerInputs from facefusion.program_helper import find_argument_group from facefusion.thread_helper import thread_semaphore -from facefusion.typing import ApplyStateItem, Args, Face, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame +from facefusion.typing import ApplyStateItem, Args, DownloadScope, Face, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame from facefusion.vision import read_image, read_static_image, unpack_resolution, write_image @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { 'ddcolor': @@ -140,7 +140,7 @@ def clear_inference_pool() -> None: def get_model_options() -> ModelOptions: frame_colorizer_model = state_manager.get_item('frame_colorizer_model') - return create_static_model_set().get(frame_colorizer_model) + return create_static_model_set('full').get(frame_colorizer_model) def register_args(program : ArgumentParser) -> None: diff --git a/facefusion/processors/modules/frame_enhancer.py b/facefusion/processors/modules/frame_enhancer.py index 016fffab..5179ebb4 100644 --- a/facefusion/processors/modules/frame_enhancer.py +++ b/facefusion/processors/modules/frame_enhancer.py @@ -16,12 +16,12 @@ from facefusion.processors import choices as processors_choices from facefusion.processors.typing import FrameEnhancerInputs from facefusion.program_helper import find_argument_group from facefusion.thread_helper import conditional_thread_semaphore -from facefusion.typing import ApplyStateItem, Args, Face, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame +from facefusion.typing import ApplyStateItem, Args, DownloadScope, Face, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame from facefusion.vision import create_tile_frames, merge_tile_frames, read_image, read_static_image, write_image @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { 'clear_reality_x4': @@ -397,7 +397,7 @@ def clear_inference_pool() -> None: def get_model_options() -> ModelOptions: frame_enhancer_model = state_manager.get_item('frame_enhancer_model') - return create_static_model_set().get(frame_enhancer_model) + return create_static_model_set('full').get(frame_enhancer_model) def register_args(program : ArgumentParser) -> None: diff --git a/facefusion/processors/modules/lip_syncer.py b/facefusion/processors/modules/lip_syncer.py index 610cb0e6..db672d10 100755 --- a/facefusion/processors/modules/lip_syncer.py +++ b/facefusion/processors/modules/lip_syncer.py @@ -22,12 +22,12 @@ from facefusion.processors import choices as processors_choices from facefusion.processors.typing import LipSyncerInputs from facefusion.program_helper import find_argument_group from facefusion.thread_helper import conditional_thread_semaphore -from facefusion.typing import ApplyStateItem, Args, AudioFrame, Face, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame +from facefusion.typing import ApplyStateItem, Args, AudioFrame, DownloadScope, Face, InferencePool, ModelOptions, ModelSet, ProcessMode, QueuePayload, UpdateProgress, VisionFrame from facefusion.vision import read_image, read_static_image, restrict_video_fps, write_image @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { 'wav2lip_96': @@ -86,7 +86,7 @@ def clear_inference_pool() -> None: def get_model_options() -> ModelOptions: lip_syncer_model = state_manager.get_item('lip_syncer_model') - return create_static_model_set().get(lip_syncer_model) + return create_static_model_set('full').get(lip_syncer_model) def register_args(program : ArgumentParser) -> None: diff --git a/facefusion/program.py b/facefusion/program.py index 0c8bb08d..efba8e67 100755 --- a/facefusion/program.py +++ b/facefusion/program.py @@ -207,6 +207,14 @@ def create_download_providers_program() -> ArgumentParser: return program +def create_download_scope_program() -> ArgumentParser: + program = ArgumentParser(add_help = False) + group_download = program.add_argument_group('download') + group_download.add_argument('--download-scope', help = wording.get('help.download_scope'), default = config.get_str_value('download.download_scope', 'lite'), choices = list(facefusion.choices.download_scopes)) + job_store.register_job_keys([ 'download_scope' ]) + return program + + def create_memory_program() -> ArgumentParser: program = ArgumentParser(add_help = False) group_memory = program.add_argument_group('memory') @@ -260,7 +268,7 @@ def create_program() -> ArgumentParser: sub_program.add_parser('run', help = wording.get('help.run'), parents = [ create_config_path_program(), create_temp_path_program(), create_jobs_path_program(), create_source_paths_program(), create_target_path_program(), create_output_path_program(), collect_step_program(), create_uis_program(), collect_job_program() ], formatter_class = create_help_formatter_large) sub_program.add_parser('headless-run', help = wording.get('help.headless_run'), parents = [ create_config_path_program(), create_temp_path_program(), create_jobs_path_program(), create_source_paths_program(), create_target_path_program(), create_output_path_program(), collect_step_program(), collect_job_program() ], formatter_class = create_help_formatter_large) sub_program.add_parser('batch-run', help = wording.get('help.batch_run'), parents = [ create_config_path_program(), create_temp_path_program(), create_jobs_path_program(), create_source_pattern_program(), create_target_pattern_program(), create_output_pattern_program(), collect_step_program(), collect_job_program() ], formatter_class = create_help_formatter_large) - sub_program.add_parser('force-download', help = wording.get('help.force_download'), parents = [ create_download_providers_program(), create_log_level_program() ], formatter_class = create_help_formatter_large) + sub_program.add_parser('force-download', help = wording.get('help.force_download'), parents = [ create_download_providers_program(), create_download_scope_program(), create_log_level_program() ], formatter_class = create_help_formatter_large) # job manager sub_program.add_parser('job-list', help = wording.get('help.job_list'), parents = [ create_job_status_program(), create_jobs_path_program(), create_log_level_program() ], formatter_class = create_help_formatter_large) sub_program.add_parser('job-create', help = wording.get('help.job_create'), parents = [ create_job_id_program(), create_jobs_path_program(), create_log_level_program() ], formatter_class = create_help_formatter_large) diff --git a/facefusion/typing.py b/facefusion/typing.py index 5b5525d5..a92c9741 100755 --- a/facefusion/typing.py +++ b/facefusion/typing.py @@ -119,6 +119,7 @@ ExecutionProviderSet = Dict[ExecutionProviderKey, ExecutionProviderValue] DownloadProviderKey = Literal['github', 'huggingface'] DownloadProviderSet = Dict[DownloadProviderKey, str] +DownloadScope = Literal['lite', 'full'] Download = TypedDict('Download', { 'url' : str, @@ -249,6 +250,7 @@ StateKey = Literal\ 'execution_thread_count', 'execution_queue_count', 'download_providers', + 'download_scope', 'video_memory_strategy', 'system_memory_limit', 'log_level', @@ -309,6 +311,7 @@ State = TypedDict('State', 'execution_thread_count' : int, 'execution_queue_count' : int, 'download_providers' : List[DownloadProviderKey], + 'download_scope' : DownloadScope, 'video_memory_strategy' : VideoMemoryStrategy, 'system_memory_limit' : int, 'log_level' : LogLevel, diff --git a/facefusion/uis/components/face_detector.py b/facefusion/uis/components/face_detector.py index 37a2d433..2c672bc9 100644 --- a/facefusion/uis/components/face_detector.py +++ b/facefusion/uis/components/face_detector.py @@ -3,7 +3,7 @@ from typing import Optional, Sequence, Tuple import gradio import facefusion.choices -from facefusion import choices, face_detector, state_manager, wording +from facefusion import face_detector, state_manager, wording from facefusion.common_helper import calc_float_step, get_last from facefusion.typing import Angle, FaceDetectorModel, Score from facefusion.uis.core import register_ui_component @@ -65,7 +65,7 @@ def update_face_detector_model(face_detector_model : FaceDetectorModel) -> Tuple state_manager.set_item('face_detector_model', face_detector_model) if face_detector.pre_check(): - face_detector_size_choices = choices.face_detector_set.get(state_manager.get_item('face_detector_model')) + face_detector_size_choices = facefusion.choices.face_detector_set.get(state_manager.get_item('face_detector_model')) state_manager.set_item('face_detector_size', get_last(face_detector_size_choices)) return gradio.Dropdown(value = state_manager.get_item('face_detector_model')), gradio.Dropdown(value = state_manager.get_item('face_detector_size'), choices = face_detector_size_choices) return gradio.Dropdown(), gradio.Dropdown() diff --git a/facefusion/voice_extractor.py b/facefusion/voice_extractor.py index bd208097..c7c4e922 100644 --- a/facefusion/voice_extractor.py +++ b/facefusion/voice_extractor.py @@ -8,11 +8,11 @@ from facefusion import inference_manager from facefusion.download import conditional_download_hashes, conditional_download_sources, resolve_download_url from facefusion.filesystem import resolve_relative_path from facefusion.thread_helper import thread_semaphore -from facefusion.typing import Audio, AudioChunk, InferencePool, ModelOptions, ModelSet +from facefusion.typing import Audio, AudioChunk, DownloadScope, InferencePool, ModelOptions, ModelSet @lru_cache(maxsize = None) -def create_static_model_set() -> ModelSet: +def create_static_model_set(download_scope : DownloadScope) -> ModelSet: return\ { 'kim_vocal_2': @@ -47,7 +47,7 @@ def clear_inference_pool() -> None: def get_model_options() -> ModelOptions: - return create_static_model_set().get('kim_vocal_2') + return create_static_model_set('full').get('kim_vocal_2') def pre_check() -> bool: diff --git a/facefusion/wording.py b/facefusion/wording.py index ebae1a05..872d628d 100755 --- a/facefusion/wording.py +++ b/facefusion/wording.py @@ -185,6 +185,7 @@ WORDING : Dict[str, Any] =\ 'execution_queue_count': 'specify the amount of frames each thread is processing', # download 'download_providers': 'download using different providers (choices: {choices}, ...)', + 'download_scope': 'specify the download scope', # memory 'video_memory_strategy': 'balance fast processing and low VRAM usage', 'system_memory_limit': 'limit the available RAM that can be used while processing',