allow register_arguments to be nested, fix types, adjust processors

This commit is contained in:
henryruhs
2026-02-17 12:16:11 +01:00
parent f36ae318fd
commit 2b447503d5
16 changed files with 945 additions and 559 deletions
+30 -30
View File
@@ -1,7 +1,7 @@
from argparse import Action
from typing import List
from facefusion.types import Args, ArgsStore, ArgumentSet, Scope
from facefusion.types import Args, ArgsStore, Scope
ARGS_STORE : ArgsStore =\
@@ -12,15 +12,15 @@ ARGS_STORE : ArgsStore =\
}
def get_api_set() -> ArgumentSet:
def get_api_set() -> Args:
return ARGS_STORE.get('api')
def get_cli_set() -> ArgumentSet:
def get_cli_set() -> Args:
return ARGS_STORE.get('cli')
def get_sys_set() -> ArgumentSet:
def get_sys_set() -> Args:
return ARGS_STORE.get('sys')
@@ -36,45 +36,37 @@ def get_sys_args() -> List[str]:
return list(get_cli_set().keys())
def register_argument(action : Action, scopes : List[Scope]) -> None:
key = action.dest
value =\
{
'default': action.default
}
def register_arguments(actions : List[Action], scopes : List[Scope]) -> None:
for action in actions:
value =\
{
'default': action.default
}
if action.choices:
value['choices'] = list(action.choices)
if action.choices:
value['choices'] = list(action.choices)
for scope in scopes:
if scope == 'api':
ARGS_STORE['api'][key] = value
if scope == 'cli':
ARGS_STORE['cli'][key] = value
if scope == 'sys':
ARGS_STORE['sys'][key] = value
for scope in scopes:
if scope == 'api':
ARGS_STORE['api'][action.dest] = value
if scope == 'cli':
ARGS_STORE['cli'][action.dest] = value
if scope == 'sys':
ARGS_STORE['sys'][action.dest] = value
def filter_api_args(args : Args) -> Args:
api_args =\
{
key: args.get(key) for key in args if key in ARGS_STORE.get('api') #type:ignore[literal-required]
key: args.get(key) for key in args if key in get_api_set() #type:ignore[literal-required]
}
return api_args
def filter_sys_args(args : Args) -> Args:
sys_args =\
{
key: args.get(key) for key in args if key in ARGS_STORE.get('sys') #type:ignore[literal-required]
}
return sys_args
def filter_cli_args(args : Args) -> Args:
cli_args =\
{
key: args.get(key) for key in args if key in ARGS_STORE.get('cli') #type:ignore[literal-required]
key: args.get(key) for key in args if key in get_cli_args() #type:ignore[literal-required]
}
return cli_args
@@ -82,6 +74,14 @@ def filter_cli_args(args : Args) -> Args:
def filter_step_args(args : Args) -> Args:
step_args =\
{
key: args.get(key) for key in args if key in ARGS_STORE.get('cli') and key not in ARGS_STORE.get('sys') #type:ignore[literal-required]
key: args.get(key) for key in args if key in get_cli_args() and key not in get_sys_set() #type:ignore[literal-required]
}
return step_args
def filter_sys_args(args : Args) -> Args:
sys_args =\
{
key: args.get(key) for key in args if key in get_sys_set() #type:ignore[literal-required]
}
return sys_args
@@ -87,10 +87,25 @@ def get_model_options() -> ModelOptions:
def register_args(program : ArgumentParser) -> None:
group_processors = find_argument_group(program, 'processors')
if group_processors:
age_modifier_model_action = group_processors.add_argument('--age-modifier-model', help = translator.get('help.model', __package__), default = config.get_str_value('processors', 'age_modifier_model', 'styleganex_age'), choices = age_modifier_choices.age_modifier_models)
age_modifier_direction_action = group_processors.add_argument('--age-modifier-direction', help = translator.get('help.direction', __package__), type = int, default = config.get_int_value('processors', 'age_modifier_direction', '0'), choices = age_modifier_choices.age_modifier_direction_range, metavar = create_int_metavar(age_modifier_choices.age_modifier_direction_range))
facefusion.args_store.register_argument(age_modifier_model_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(age_modifier_direction_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_arguments(
[
group_processors.add_argument(
'--age-modifier-model',
help = translator.get('help.model', __package__),
default = config.get_str_value('processors', 'age_modifier_model', 'styleganex_age'),
choices = age_modifier_choices.age_modifier_models
),
group_processors.add_argument(
'--age-modifier-direction',
help = translator.get('help.direction', __package__),
type = int,
default = config.get_int_value('processors', 'age_modifier_direction', '0'),
choices = age_modifier_choices.age_modifier_direction_range,
metavar = create_int_metavar(age_modifier_choices.age_modifier_direction_range)
)
],
scopes = [ 'api', 'cli' ]
)
def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None:
@@ -420,10 +420,24 @@ def get_model_options() -> ModelOptions:
def register_args(program : ArgumentParser) -> None:
group_processors = find_argument_group(program, 'processors')
if group_processors:
background_remover_model_action = group_processors.add_argument('--background-remover-model', help = translator.get('help.model', __package__), default = config.get_str_value('processors', 'background_remover_model', 'rmbg_2.0'), choices = background_remover_choices.background_remover_models)
background_remover_color_action = group_processors.add_argument('--background-remover-color', help = translator.get('help.color', __package__), type = partial(sanitize_int_range, int_range = background_remover_choices.background_remover_color_range), default = config.get_int_list('processors', 'background_remover_color', '0 0 0 0'), nargs = '+')
facefusion.args_store.register_argument(background_remover_model_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(background_remover_color_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_arguments(
[
group_processors.add_argument(
'--background-remover-model',
help = translator.get('help.model', __package__),
default = config.get_str_value('processors', 'background_remover_model', 'rmbg_2.0'),
choices = background_remover_choices.background_remover_models
),
group_processors.add_argument(
'--background-remover-color',
help = translator.get('help.color', __package__),
type = partial(sanitize_int_range, int_range = background_remover_choices.background_remover_color_range),
default = config.get_int_list('processors', 'background_remover_color', '0 0 0 0'),
nargs = '+'
)
],
scopes = [ 'api', 'cli' ]
)
def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None:
@@ -276,10 +276,25 @@ def get_model_size() -> Size:
def register_args(program : ArgumentParser) -> None:
group_processors = find_argument_group(program, 'processors')
if group_processors:
deep_swapper_model_action = group_processors.add_argument('--deep-swapper-model', help = translator.get('help.model', __package__), default = config.get_str_value('processors', 'deep_swapper_model', 'iperov/elon_musk_224'), choices = deep_swapper_choices.deep_swapper_models)
deep_swapper_morph_action = group_processors.add_argument('--deep-swapper-morph', help = translator.get('help.morph', __package__), type = int, default = config.get_int_value('processors', 'deep_swapper_morph', '100'), choices = deep_swapper_choices.deep_swapper_morph_range, metavar = create_int_metavar(deep_swapper_choices.deep_swapper_morph_range))
facefusion.args_store.register_argument(deep_swapper_model_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(deep_swapper_morph_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_arguments(
[
group_processors.add_argument(
'--deep-swapper-model',
help = translator.get('help.model', __package__),
default = config.get_str_value('processors', 'deep_swapper_model', 'iperov/elon_musk_224'),
choices = deep_swapper_choices.deep_swapper_models
),
group_processors.add_argument(
'--deep-swapper-morph',
help = translator.get('help.morph', __package__),
type = int,
default = config.get_int_value('processors', 'deep_swapper_morph', '100'),
choices = deep_swapper_choices.deep_swapper_morph_range,
metavar = create_int_metavar(deep_swapper_choices.deep_swapper_morph_range)
)
],
scopes = [ 'api', 'cli' ]
)
def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None:
@@ -99,12 +99,33 @@ def get_model_options() -> ModelOptions:
def register_args(program : ArgumentParser) -> None:
group_processors = find_argument_group(program, 'processors')
if group_processors:
expression_restorer_model_action = group_processors.add_argument('--expression-restorer-model', help = translator.get('help.model', __package__), default = config.get_str_value('processors', 'expression_restorer_model', 'live_portrait'), choices = expression_restorer_choices.expression_restorer_models)
expression_restorer_factor_action = group_processors.add_argument('--expression-restorer-factor', help = translator.get('help.factor', __package__), type = int, default = config.get_int_value('processors', 'expression_restorer_factor', '80'), choices = expression_restorer_choices.expression_restorer_factor_range, metavar = create_int_metavar(expression_restorer_choices.expression_restorer_factor_range))
expression_restorer_areas_action = group_processors.add_argument('--expression-restorer-areas', help = translator.get('help.areas', __package__).format(choices = ', '.join(expression_restorer_choices.expression_restorer_areas)), default = config.get_str_list('processors', 'expression_restorer_areas', ' '.join(expression_restorer_choices.expression_restorer_areas)), choices = expression_restorer_choices.expression_restorer_areas, nargs = '+', metavar = 'EXPRESSION_RESTORER_AREAS')
facefusion.args_store.register_argument(expression_restorer_model_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(expression_restorer_factor_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(expression_restorer_areas_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_arguments(
[
group_processors.add_argument(
'--expression-restorer-model',
help = translator.get('help.model', __package__),
default = config.get_str_value('processors', 'expression_restorer_model', 'live_portrait'),
choices = expression_restorer_choices.expression_restorer_models
),
group_processors.add_argument(
'--expression-restorer-factor',
help = translator.get('help.factor', __package__),
type = int,
default = config.get_int_value('processors', 'expression_restorer_factor', '80'),
choices = expression_restorer_choices.expression_restorer_factor_range,
metavar = create_int_metavar(expression_restorer_choices.expression_restorer_factor_range)
),
group_processors.add_argument(
'--expression-restorer-areas',
help = translator.get('help.areas', __package__).format(choices = ', '.join(expression_restorer_choices.expression_restorer_areas)),
default = config.get_str_list('processors', 'expression_restorer_areas', ' '.join(expression_restorer_choices.expression_restorer_areas)),
choices = expression_restorer_choices.expression_restorer_areas,
nargs = '+',
metavar = 'EXPRESSION_RESTORER_AREAS'
)
],
scopes = [ 'api', 'cli' ]
)
def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None:
@@ -30,8 +30,19 @@ def clear_inference_pool() -> None:
def register_args(program : ArgumentParser) -> None:
group_processors = find_argument_group(program, 'processors')
if group_processors:
face_debugger_items_action = group_processors.add_argument('--face-debugger-items', help = translator.get('help.items', __package__).format(choices = ', '.join(face_debugger_choices.face_debugger_items)), default = config.get_str_list('processors', 'face_debugger_items', 'face-landmark-5/68 face-mask'), choices = face_debugger_choices.face_debugger_items, nargs = '+', metavar = 'FACE_DEBUGGER_ITEMS')
facefusion.args_store.register_argument(face_debugger_items_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_arguments(
[
group_processors.add_argument(
'--face-debugger-items',
help = translator.get('help.items', __package__).format(choices = ', '.join(face_debugger_choices.face_debugger_items)),
default = config.get_str_list('processors', 'face_debugger_items', 'face-landmark-5/68 face-mask'),
choices = face_debugger_choices.face_debugger_items,
nargs = '+',
metavar = 'FACE_DEBUGGER_ITEMS'
)
],
scopes = [ 'api', 'cli' ]
)
def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None:
+123 -30
View File
@@ -129,36 +129,129 @@ def get_model_options() -> ModelOptions:
def register_args(program : ArgumentParser) -> None:
group_processors = find_argument_group(program, 'processors')
if group_processors:
face_editor_model_action = group_processors.add_argument('--face-editor-model', help = translator.get('help.model', __package__), default = config.get_str_value('processors', 'face_editor_model', 'live_portrait'), choices = face_editor_choices.face_editor_models)
face_editor_eyebrow_direction_action = group_processors.add_argument('--face-editor-eyebrow-direction', help = translator.get('help.eyebrow_direction', __package__), type = float, default = config.get_float_value('processors', 'face_editor_eyebrow_direction', '0'), choices = face_editor_choices.face_editor_eyebrow_direction_range, metavar = create_float_metavar(face_editor_choices.face_editor_eyebrow_direction_range))
face_editor_eye_gaze_horizontal_action = group_processors.add_argument('--face-editor-eye-gaze-horizontal', help = translator.get('help.eye_gaze_horizontal', __package__), type = float, default = config.get_float_value('processors', 'face_editor_eye_gaze_horizontal', '0'), choices = face_editor_choices.face_editor_eye_gaze_horizontal_range, metavar = create_float_metavar(face_editor_choices.face_editor_eye_gaze_horizontal_range))
face_editor_eye_gaze_vertical_action = group_processors.add_argument('--face-editor-eye-gaze-vertical', help = translator.get('help.eye_gaze_vertical', __package__), type = float, default = config.get_float_value('processors', 'face_editor_eye_gaze_vertical', '0'), choices = face_editor_choices.face_editor_eye_gaze_vertical_range, metavar = create_float_metavar(face_editor_choices.face_editor_eye_gaze_vertical_range))
face_editor_eye_open_ratio_action = group_processors.add_argument('--face-editor-eye-open-ratio', help = translator.get('help.eye_open_ratio', __package__), type = float, default = config.get_float_value('processors', 'face_editor_eye_open_ratio', '0'), choices = face_editor_choices.face_editor_eye_open_ratio_range, metavar = create_float_metavar(face_editor_choices.face_editor_eye_open_ratio_range))
face_editor_lip_open_ratio_action = group_processors.add_argument('--face-editor-lip-open-ratio', help = translator.get('help.lip_open_ratio', __package__), type = float, default = config.get_float_value('processors', 'face_editor_lip_open_ratio', '0'), choices = face_editor_choices.face_editor_lip_open_ratio_range, metavar = create_float_metavar(face_editor_choices.face_editor_lip_open_ratio_range))
face_editor_mouth_grim_action = group_processors.add_argument('--face-editor-mouth-grim', help = translator.get('help.mouth_grim', __package__), type = float, default = config.get_float_value('processors', 'face_editor_mouth_grim', '0'), choices = face_editor_choices.face_editor_mouth_grim_range, metavar = create_float_metavar(face_editor_choices.face_editor_mouth_grim_range))
face_editor_mouth_pout_action = group_processors.add_argument('--face-editor-mouth-pout', help = translator.get('help.mouth_pout', __package__), type = float, default = config.get_float_value('processors', 'face_editor_mouth_pout', '0'), choices = face_editor_choices.face_editor_mouth_pout_range, metavar = create_float_metavar(face_editor_choices.face_editor_mouth_pout_range))
face_editor_mouth_purse_action = group_processors.add_argument('--face-editor-mouth-purse', help = translator.get('help.mouth_purse', __package__), type = float, default = config.get_float_value('processors', 'face_editor_mouth_purse', '0'), choices = face_editor_choices.face_editor_mouth_purse_range, metavar = create_float_metavar(face_editor_choices.face_editor_mouth_purse_range))
face_editor_mouth_smile_action = group_processors.add_argument('--face-editor-mouth-smile', help = translator.get('help.mouth_smile', __package__), type = float, default = config.get_float_value('processors', 'face_editor_mouth_smile', '0'), choices = face_editor_choices.face_editor_mouth_smile_range, metavar = create_float_metavar(face_editor_choices.face_editor_mouth_smile_range))
face_editor_mouth_position_horizontal_action = group_processors.add_argument('--face-editor-mouth-position-horizontal', help = translator.get('help.mouth_position_horizontal', __package__), type = float, default = config.get_float_value('processors', 'face_editor_mouth_position_horizontal', '0'), choices = face_editor_choices.face_editor_mouth_position_horizontal_range, metavar = create_float_metavar(face_editor_choices.face_editor_mouth_position_horizontal_range))
face_editor_mouth_position_vertical_action = group_processors.add_argument('--face-editor-mouth-position-vertical', help = translator.get('help.mouth_position_vertical', __package__), type = float, default = config.get_float_value('processors', 'face_editor_mouth_position_vertical', '0'), choices = face_editor_choices.face_editor_mouth_position_vertical_range, metavar = create_float_metavar(face_editor_choices.face_editor_mouth_position_vertical_range))
face_editor_head_pitch_action = group_processors.add_argument('--face-editor-head-pitch', help = translator.get('help.head_pitch', __package__), type = float, default = config.get_float_value('processors', 'face_editor_head_pitch', '0'), choices = face_editor_choices.face_editor_head_pitch_range, metavar = create_float_metavar(face_editor_choices.face_editor_head_pitch_range))
face_editor_head_yaw_action = group_processors.add_argument('--face-editor-head-yaw', help = translator.get('help.head_yaw', __package__), type = float, default = config.get_float_value('processors', 'face_editor_head_yaw', '0'), choices = face_editor_choices.face_editor_head_yaw_range, metavar = create_float_metavar(face_editor_choices.face_editor_head_yaw_range))
face_editor_head_roll_action = group_processors.add_argument('--face-editor-head-roll', help = translator.get('help.head_roll', __package__), type = float, default = config.get_float_value('processors', 'face_editor_head_roll', '0'), choices = face_editor_choices.face_editor_head_roll_range, metavar = create_float_metavar(face_editor_choices.face_editor_head_roll_range))
facefusion.args_store.register_argument(face_editor_model_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_editor_eyebrow_direction_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_editor_eye_gaze_horizontal_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_editor_eye_gaze_vertical_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_editor_eye_open_ratio_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_editor_lip_open_ratio_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_editor_mouth_grim_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_editor_mouth_pout_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_editor_mouth_purse_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_editor_mouth_smile_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_editor_mouth_position_horizontal_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_editor_mouth_position_vertical_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_editor_head_pitch_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_editor_head_yaw_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_editor_head_roll_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_arguments(
[
group_processors.add_argument(
'--face-editor-model',
help = translator.get('help.model', __package__),
default = config.get_str_value('processors', 'face_editor_model', 'live_portrait'),
choices = face_editor_choices.face_editor_models
),
group_processors.add_argument(
'--face-editor-eyebrow-direction',
help = translator.get('help.eyebrow_direction', __package__),
type = float,
default = config.get_float_value('processors', 'face_editor_eyebrow_direction', '0'),
choices = face_editor_choices.face_editor_eyebrow_direction_range,
metavar = create_float_metavar(face_editor_choices.face_editor_eyebrow_direction_range)
),
group_processors.add_argument(
'--face-editor-eye-gaze-horizontal',
help = translator.get('help.eye_gaze_horizontal', __package__),
type = float,
default = config.get_float_value('processors', 'face_editor_eye_gaze_horizontal', '0'),
choices = face_editor_choices.face_editor_eye_gaze_horizontal_range,
metavar = create_float_metavar(face_editor_choices.face_editor_eye_gaze_horizontal_range)
),
group_processors.add_argument(
'--face-editor-eye-gaze-vertical',
help = translator.get('help.eye_gaze_vertical', __package__),
type = float,
default = config.get_float_value('processors', 'face_editor_eye_gaze_vertical', '0'),
choices = face_editor_choices.face_editor_eye_gaze_vertical_range,
metavar = create_float_metavar(face_editor_choices.face_editor_eye_gaze_vertical_range)
),
group_processors.add_argument(
'--face-editor-eye-open-ratio',
help = translator.get('help.eye_open_ratio', __package__),
type = float,
default = config.get_float_value('processors', 'face_editor_eye_open_ratio', '0'),
choices = face_editor_choices.face_editor_eye_open_ratio_range,
metavar = create_float_metavar(face_editor_choices.face_editor_eye_open_ratio_range)
),
group_processors.add_argument(
'--face-editor-lip-open-ratio',
help = translator.get('help.lip_open_ratio', __package__),
type = float,
default = config.get_float_value('processors', 'face_editor_lip_open_ratio', '0'),
choices = face_editor_choices.face_editor_lip_open_ratio_range,
metavar = create_float_metavar(face_editor_choices.face_editor_lip_open_ratio_range)
),
group_processors.add_argument(
'--face-editor-mouth-grim',
help = translator.get('help.mouth_grim', __package__),
type = float,
default = config.get_float_value('processors', 'face_editor_mouth_grim', '0'),
choices = face_editor_choices.face_editor_mouth_grim_range,
metavar = create_float_metavar(face_editor_choices.face_editor_mouth_grim_range)
),
group_processors.add_argument(
'--face-editor-mouth-pout',
help = translator.get('help.mouth_pout', __package__),
type = float,
default = config.get_float_value('processors', 'face_editor_mouth_pout', '0'),
choices = face_editor_choices.face_editor_mouth_pout_range,
metavar = create_float_metavar(face_editor_choices.face_editor_mouth_pout_range)
),
group_processors.add_argument(
'--face-editor-mouth-purse',
help = translator.get('help.mouth_purse', __package__),
type = float,
default = config.get_float_value('processors', 'face_editor_mouth_purse', '0'),
choices = face_editor_choices.face_editor_mouth_purse_range,
metavar = create_float_metavar(face_editor_choices.face_editor_mouth_purse_range)
),
group_processors.add_argument(
'--face-editor-mouth-smile',
help = translator.get('help.mouth_smile', __package__),
type = float,
default = config.get_float_value('processors', 'face_editor_mouth_smile', '0'),
choices = face_editor_choices.face_editor_mouth_smile_range,
metavar = create_float_metavar(face_editor_choices.face_editor_mouth_smile_range)
),
group_processors.add_argument(
'--face-editor-mouth-position-horizontal',
help = translator.get('help.mouth_position_horizontal', __package__),
type = float,
default = config.get_float_value('processors', 'face_editor_mouth_position_horizontal', '0'),
choices = face_editor_choices.face_editor_mouth_position_horizontal_range,
metavar = create_float_metavar(face_editor_choices.face_editor_mouth_position_horizontal_range)
),
group_processors.add_argument(
'--face-editor-mouth-position-vertical',
help = translator.get('help.mouth_position_vertical', __package__),
type = float,
default = config.get_float_value('processors', 'face_editor_mouth_position_vertical', '0'),
choices = face_editor_choices.face_editor_mouth_position_vertical_range,
metavar = create_float_metavar(face_editor_choices.face_editor_mouth_position_vertical_range)
),
group_processors.add_argument(
'--face-editor-head-pitch',
help = translator.get('help.head_pitch', __package__),
type = float,
default = config.get_float_value('processors', 'face_editor_head_pitch', '0'),
choices = face_editor_choices.face_editor_head_pitch_range,
metavar = create_float_metavar(face_editor_choices.face_editor_head_pitch_range)
),
group_processors.add_argument(
'--face-editor-head-yaw',
help = translator.get('help.head_yaw', __package__),
type = float,
default = config.get_float_value('processors', 'face_editor_head_yaw', '0'),
choices = face_editor_choices.face_editor_head_yaw_range,
metavar = create_float_metavar(face_editor_choices.face_editor_head_yaw_range)
),
group_processors.add_argument(
'--face-editor-head-roll',
help = translator.get('help.head_roll', __package__),
type = float,
default = config.get_float_value('processors', 'face_editor_head_roll', '0'),
choices = face_editor_choices.face_editor_head_roll_range,
metavar = create_float_metavar(face_editor_choices.face_editor_head_roll_range)
)
],
scopes = [ 'api', 'cli' ]
)
def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None:
@@ -292,12 +292,33 @@ def get_model_options() -> ModelOptions:
def register_args(program : ArgumentParser) -> None:
group_processors = find_argument_group(program, 'processors')
if group_processors:
face_enhancer_model_action = group_processors.add_argument('--face-enhancer-model', help = translator.get('help.model', __package__), default = config.get_str_value('processors', 'face_enhancer_model', 'gfpgan_1.4'), choices = face_enhancer_choices.face_enhancer_models)
face_enhancer_blend_action = group_processors.add_argument('--face-enhancer-blend', help = translator.get('help.blend', __package__), type = int, default = config.get_int_value('processors', 'face_enhancer_blend', '80'), choices = face_enhancer_choices.face_enhancer_blend_range, metavar = create_int_metavar(face_enhancer_choices.face_enhancer_blend_range))
face_enhancer_weight_action = group_processors.add_argument('--face-enhancer-weight', help = translator.get('help.weight', __package__), type = float, default = config.get_float_value('processors', 'face_enhancer_weight', '0.5'), choices = face_enhancer_choices.face_enhancer_weight_range, metavar = create_float_metavar(face_enhancer_choices.face_enhancer_weight_range))
facefusion.args_store.register_argument(face_enhancer_model_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_enhancer_blend_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_enhancer_weight_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_arguments(
[
group_processors.add_argument(
'--face-enhancer-model',
help = translator.get('help.model', __package__),
default = config.get_str_value('processors', 'face_enhancer_model', 'gfpgan_1.4'),
choices = face_enhancer_choices.face_enhancer_models
),
group_processors.add_argument(
'--face-enhancer-blend',
help = translator.get('help.blend', __package__),
type = int,
default = config.get_int_value('processors', 'face_enhancer_blend', '80'),
choices = face_enhancer_choices.face_enhancer_blend_range,
metavar = create_int_metavar(face_enhancer_choices.face_enhancer_blend_range)
),
group_processors.add_argument(
'--face-enhancer-weight',
help = translator.get('help.weight', __package__),
type = float,
default = config.get_float_value('processors', 'face_enhancer_weight', '0.5'),
choices = face_enhancer_choices.face_enhancer_weight_range,
metavar = create_float_metavar(face_enhancer_choices.face_enhancer_weight_range)
)
],
scopes = [ 'api', 'cli' ]
)
def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None:
@@ -513,14 +513,37 @@ def get_model_name() -> str:
def register_args(program : ArgumentParser) -> None:
group_processors = find_argument_group(program, 'processors')
if group_processors:
face_swapper_model_action = group_processors.add_argument('--face-swapper-model', help = translator.get('help.model', __package__), default = config.get_str_value('processors', 'face_swapper_model', 'hyperswap_1a_256'), choices = face_swapper_choices.face_swapper_models)
facefusion.args_store.register_arguments(
[
group_processors.add_argument(
'--face-swapper-model',
help = translator.get('help.model', __package__),
default = config.get_str_value('processors', 'face_swapper_model', 'hyperswap_1a_256'),
choices = face_swapper_choices.face_swapper_models
)
],
scopes = [ 'api', 'cli' ]
)
known_args, _ = program.parse_known_args()
face_swapper_pixel_boost_choices = face_swapper_choices.face_swapper_set.get(known_args.face_swapper_model)
face_swapper_pixel_boost_action = group_processors.add_argument('--face-swapper-pixel-boost', help = translator.get('help.pixel_boost', __package__), default = config.get_str_value('processors', 'face_swapper_pixel_boost', get_first(face_swapper_pixel_boost_choices)), choices = face_swapper_pixel_boost_choices)
face_swapper_weight_action = group_processors.add_argument('--face-swapper-weight', help = translator.get('help.weight', __package__), type = float, default = config.get_float_value('processors', 'face_swapper_weight', '0.5'), choices = face_swapper_choices.face_swapper_weight_range)
facefusion.args_store.register_argument(face_swapper_model_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_swapper_pixel_boost_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(face_swapper_weight_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_arguments(
[
group_processors.add_argument(
'--face-swapper-pixel-boost',
help = translator.get('help.pixel_boost', __package__),
default = config.get_str_value('processors', 'face_swapper_pixel_boost', get_first(face_swapper_pixel_boost_choices)),
choices = face_swapper_pixel_boost_choices
),
group_processors.add_argument(
'--face-swapper-weight',
help = translator.get('help.weight', __package__),
type = float,
default = config.get_float_value('processors', 'face_swapper_weight', '0.5'),
choices = face_swapper_choices.face_swapper_weight_range
)
],
scopes = [ 'api', 'cli' ]
)
def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None:
@@ -184,12 +184,32 @@ def get_model_options() -> ModelOptions:
def register_args(program : ArgumentParser) -> None:
group_processors = find_argument_group(program, 'processors')
if group_processors:
frame_colorizer_model_action = group_processors.add_argument('--frame-colorizer-model', help = translator.get('help.model', __package__), default = config.get_str_value('processors', 'frame_colorizer_model', 'ddcolor'), choices = frame_colorizer_choices.frame_colorizer_models)
frame_colorizer_size_action = group_processors.add_argument('--frame-colorizer-size', help = translator.get('help.size', __package__), type = str, default = config.get_str_value('processors', 'frame_colorizer_size', '256x256'), choices = frame_colorizer_choices.frame_colorizer_sizes)
frame_colorizer_blend_action = group_processors.add_argument('--frame-colorizer-blend', help = translator.get('help.blend', __package__), type = int, default = config.get_int_value('processors', 'frame_colorizer_blend', '100'), choices = frame_colorizer_choices.frame_colorizer_blend_range, metavar = create_int_metavar(frame_colorizer_choices.frame_colorizer_blend_range))
facefusion.args_store.register_argument(frame_colorizer_model_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(frame_colorizer_size_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(frame_colorizer_blend_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_arguments(
[
group_processors.add_argument(
'--frame-colorizer-model',
help = translator.get('help.model', __package__),
default = config.get_str_value('processors', 'frame_colorizer_model', 'ddcolor'),
choices = frame_colorizer_choices.frame_colorizer_models
),
group_processors.add_argument(
'--frame-colorizer-size',
help = translator.get('help.size', __package__),
type = str,
default = config.get_str_value('processors', 'frame_colorizer_size', '256x256'),
choices = frame_colorizer_choices.frame_colorizer_sizes
),
group_processors.add_argument(
'--frame-colorizer-blend',
help = translator.get('help.blend', __package__),
type = int,
default = config.get_int_value('processors', 'frame_colorizer_blend', '100'),
choices = frame_colorizer_choices.frame_colorizer_blend_range,
metavar = create_int_metavar(frame_colorizer_choices.frame_colorizer_blend_range)
)
],
scopes = [ 'api', 'cli' ]
)
def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None:
@@ -573,10 +573,25 @@ def get_frame_enhancer_model() -> str:
def register_args(program : ArgumentParser) -> None:
group_processors = find_argument_group(program, 'processors')
if group_processors:
frame_enhancer_model_action = group_processors.add_argument('--frame-enhancer-model', help = translator.get('help.model', __package__), default = config.get_str_value('processors', 'frame_enhancer_model', 'span_kendata_x4'), choices = frame_enhancer_choices.frame_enhancer_models)
frame_enhancer_blend_action = group_processors.add_argument('--frame-enhancer-blend', help = translator.get('help.blend', __package__), type = int, default = config.get_int_value('processors', 'frame_enhancer_blend', '80'), choices = frame_enhancer_choices.frame_enhancer_blend_range, metavar = create_int_metavar(frame_enhancer_choices.frame_enhancer_blend_range))
facefusion.args_store.register_argument(frame_enhancer_model_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(frame_enhancer_blend_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_arguments(
[
group_processors.add_argument(
'--frame-enhancer-model',
help = translator.get('help.model', __package__),
default = config.get_str_value('processors', 'frame_enhancer_model', 'span_kendata_x4'),
choices = frame_enhancer_choices.frame_enhancer_models
),
group_processors.add_argument(
'--frame-enhancer-blend',
help = translator.get('help.blend', __package__),
type = int,
default = config.get_int_value('processors', 'frame_enhancer_blend', '80'),
choices = frame_enhancer_choices.frame_enhancer_blend_range,
metavar = create_int_metavar(frame_enhancer_choices.frame_enhancer_blend_range)
)
],
scopes = [ 'api', 'cli' ]
)
def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None:
@@ -132,10 +132,25 @@ def get_model_options() -> ModelOptions:
def register_args(program : ArgumentParser) -> None:
group_processors = find_argument_group(program, 'processors')
if group_processors:
lip_syncer_model_action = group_processors.add_argument('--lip-syncer-model', help = translator.get('help.model', __package__), default = config.get_str_value('processors', 'lip_syncer_model', 'wav2lip_gan_96'), choices = lip_syncer_choices.lip_syncer_models)
lip_syncer_weight_action = group_processors.add_argument('--lip-syncer-weight', help = translator.get('help.weight', __package__), type = float, default = config.get_float_value('processors', 'lip_syncer_weight', '0.5'), choices = lip_syncer_choices.lip_syncer_weight_range, metavar = create_float_metavar(lip_syncer_choices.lip_syncer_weight_range))
facefusion.args_store.register_argument(lip_syncer_model_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_argument(lip_syncer_weight_action, scopes = [ 'api', 'cli' ])
facefusion.args_store.register_arguments(
[
group_processors.add_argument(
'--lip-syncer-model',
help = translator.get('help.model', __package__),
default = config.get_str_value('processors', 'lip_syncer_model', 'wav2lip_gan_96'),
choices = lip_syncer_choices.lip_syncer_models
),
group_processors.add_argument(
'--lip-syncer-weight',
help = translator.get('help.weight', __package__),
type = float,
default = config.get_float_value('processors', 'lip_syncer_weight', '0.5'),
choices = lip_syncer_choices.lip_syncer_weight_range,
metavar = create_float_metavar(lip_syncer_choices.lip_syncer_weight_range)
)
],
scopes = [ 'api', 'cli' ]
)
def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None:
+538 -426
View File
File diff suppressed because it is too large Load Diff
+3 -7
View File
@@ -99,17 +99,13 @@ Resolution : TypeAlias = Tuple[int, int]
Args : TypeAlias = Dict[str, Any]
Scope : TypeAlias = Literal['api', 'cli', 'sys']
ArgumentValue : TypeAlias = Dict[str, Any]
ArgumentSet : TypeAlias = Dict[str, ArgumentValue]
ArgsStore = TypedDict('ArgsStore',
{
'api' : ArgumentSet,
'cli' : ArgumentSet,
'sys' : ArgumentSet
'api' : Args,
'cli' : Args,
'sys' : Args
})
ProcessState = Literal['checking', 'processing', 'stopping', 'pending']
UpdateProgress : TypeAlias = Callable[[int], None]
ProcessStep : TypeAlias = Callable[[str, int, Args], bool]
+15 -9
View File
@@ -11,17 +11,23 @@ from facefusion.apis.core import create_api
@pytest.fixture(scope = 'module')
def test_client() -> Iterator[TestClient]:
program = ArgumentParser()
args_store.register_argument(
program.add_argument(
'--source-paths',
nargs = '+'),
args_store.register_arguments(
[
program.add_argument(
'--source-paths',
nargs = '+'
)
],
scopes = [ 'api' ]
)
args_store.register_argument(
program.add_argument(
'--output-format',
default = 'mp4',
choices = [ 'mp4', 'mkv', 'webm' ]),
args_store.register_arguments(
[
program.add_argument(
'--output-format',
default = 'mp4',
choices = [ 'mp4', 'mkv', 'webm' ]
)
],
scopes = [ 'api' ]
)
+20 -11
View File
@@ -25,21 +25,30 @@ def before_all() -> None:
@pytest.fixture(scope = 'module')
def test_client() -> Iterator[TestClient]:
program = ArgumentParser()
args_store.register_argument(
program.add_argument(
'--source-paths',
nargs = '+'),
args_store.register_arguments(
[
program.add_argument(
'--source-paths',
nargs = '+'
)
],
scopes = [ 'api' ]
)
args_store.register_argument(
program.add_argument(
'--target-path'),
args_store.register_arguments(
[
program.add_argument(
'--target-path'
)
],
scopes = [ 'api' ]
)
args_store.register_argument(
program.add_argument(
'--execution-providers',
nargs = '+'),
args_store.register_arguments(
[
program.add_argument(
'--execution-providers',
nargs = '+'
)
],
scopes = [ 'api' ]
)
state_manager.init_item('execution_providers', [ 'cpu' ])