From 19400a92bd38d01e3ffacad0f06d8eb4fd708aa1 Mon Sep 17 00:00:00 2001 From: henryruhs Date: Sat, 14 Jun 2025 11:00:52 +0200 Subject: [PATCH] Vibe coded benchmark command part2 --- README.md | 2 +- facefusion.ini | 4 ++++ facefusion/args.py | 2 +- facefusion/benchmarker.py | 4 ++-- facefusion/program.py | 7 +++---- facefusion/types.py | 4 ++-- facefusion/uis/components/benchmark.py | 10 +++++----- facefusion/uis/components/benchmark_options.py | 10 +++++----- facefusion/uis/types.py | 2 +- facefusion/wording.py | 6 +++--- 10 files changed, 27 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 15e9de4..d16935e 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,8 @@ commands: run run the program headless-run run the program in headless mode batch-run run the program in batch mode - benchmark run performance benchmarks and exit force-download force automate downloads and exit + benchmark run performance benchmarks and exit job-list list jobs by status job-create create a drafted job job-submit submit a drafted job to become a queued job diff --git a/facefusion.ini b/facefusion.ini index 172ecaf..42c6e94 100644 --- a/facefusion.ini +++ b/facefusion.ini @@ -110,6 +110,10 @@ execution_queue_count = download_providers = download_scope = +[benchmark] +benchmark_resolutions = +benchmark_cycles = + [memory] video_memory_strategy = system_memory_limit = diff --git a/facefusion/args.py b/facefusion/args.py index 4acae27..560b6ac 100644 --- a/facefusion/args.py +++ b/facefusion/args.py @@ -126,7 +126,7 @@ def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None: apply_state_item('download_providers', args.get('download_providers')) apply_state_item('download_scope', args.get('download_scope')) # benchmark - apply_state_item('benchmark_runs', args.get('benchmark_runs')) + apply_state_item('benchmark_resolutions', args.get('benchmark_resolutions')) apply_state_item('benchmark_cycles', args.get('benchmark_cycles')) # memory apply_state_item('video_memory_strategy', args.get('video_memory_strategy')) diff --git a/facefusion/benchmarker.py b/facefusion/benchmarker.py index 3bfc2d7..99f75fd 100644 --- a/facefusion/benchmarker.py +++ b/facefusion/benchmarker.py @@ -84,7 +84,7 @@ def benchmark_target(benchmark_cycles : int) -> List[Any]: def run() -> None: - benchmark_runs = state_manager.get_item('benchmark_runs') + benchmark_resolutions = state_manager.get_item('benchmark_resolutions') benchmark_cycles = state_manager.get_item('benchmark_cycles') state_manager.set_item('source_paths', [ '.assets/examples/source.jpg', '.assets/examples/source.mp3' ]) @@ -95,7 +95,7 @@ def run() -> None: state_manager.set_item('video_memory_strategy', 'tolerant') benchmark_results = [] - target_paths = [ BENCHMARKS[benchmark_run] for benchmark_run in benchmark_runs if benchmark_run in BENCHMARKS ] + target_paths = [ BENCHMARKS[benchmark_resolution] for benchmark_resolution in benchmark_resolutions if benchmark_resolution in BENCHMARKS ] if target_paths: pre_process() diff --git a/facefusion/program.py b/facefusion/program.py index 335cac7..6f0d487 100755 --- a/facefusion/program.py +++ b/facefusion/program.py @@ -218,9 +218,8 @@ def create_benchmark_program() -> ArgumentParser: from facefusion.benchmarker import BENCHMARKS program = ArgumentParser(add_help = False) group_benchmark = program.add_argument_group('benchmark') - group_benchmark.add_argument('--benchmark-runs', help = wording.get('help.benchmark_runs'), default = [ '240p' ], choices = list(BENCHMARKS.keys()), nargs = '+') - group_benchmark.add_argument('--benchmark-cycles', help = wording.get('help.benchmark_cycles'), type = int, default = 5, choices = range(1, 11)) - job_store.register_job_keys([ 'benchmark_runs', 'benchmark_cycles' ]) + group_benchmark.add_argument('--benchmark-resolutions', help = wording.get('help.benchmark_resolutions'), default = config.get_str_list('benchmark', 'benchmark_resolutions', '240p'), choices = list(BENCHMARKS.keys()), nargs = '+') + group_benchmark.add_argument('--benchmark-cycles', help = wording.get('help.benchmark_cycles'), type = int, default = config.get_int_value('benchmark', 'benchmark_cycles', '5'), choices = range(1, 11)) return program @@ -293,8 +292,8 @@ 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('benchmark', help = wording.get('help.benchmark'), parents = [ create_config_path_program(), create_temp_path_program(), create_jobs_path_program(), create_benchmark_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_download_scope_program(), create_log_level_program() ], formatter_class = create_help_formatter_large) + sub_program.add_parser('benchmark', help = wording.get('help.benchmark'), parents = [ create_config_path_program(), create_temp_path_program(), create_jobs_path_program(), create_benchmark_program(), collect_step_program(), collect_job_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/types.py b/facefusion/types.py index 44a4b6b..15978ce 100755 --- a/facefusion/types.py +++ b/facefusion/types.py @@ -283,7 +283,7 @@ StateKey = Literal\ 'execution_thread_count', 'execution_queue_count', 'download_providers', - 'benchmark_runs', + 'benchmark_resolutions', 'benchmark_cycles', 'download_scope', 'video_memory_strategy', @@ -351,7 +351,7 @@ State = TypedDict('State', 'execution_thread_count' : int, 'execution_queue_count' : int, 'download_providers' : List[DownloadProvider], - 'benchmark_runs' : List[str], + 'benchmark_resolutions' : List[str], 'benchmark_cycles' : int, 'download_scope' : DownloadScope, 'video_memory_strategy' : VideoMemoryStrategy, diff --git a/facefusion/uis/components/benchmark.py b/facefusion/uis/components/benchmark.py index 123fa49..ed17710 100644 --- a/facefusion/uis/components/benchmark.py +++ b/facefusion/uis/components/benchmark.py @@ -43,14 +43,14 @@ def render() -> None: def listen() -> None: - benchmark_runs_checkbox_group = get_ui_component('benchmark_runs_checkbox_group') + benchmark_resolutions_checkbox_group = get_ui_component('benchmark_resolutions_checkbox_group') benchmark_cycles_slider = get_ui_component('benchmark_cycles_slider') - if benchmark_runs_checkbox_group and benchmark_cycles_slider: - BENCHMARK_START_BUTTON.click(start, inputs = [ benchmark_runs_checkbox_group, benchmark_cycles_slider ], outputs = BENCHMARK_BENCHMARKS_DATAFRAME) + if benchmark_resolutions_checkbox_group and benchmark_cycles_slider: + BENCHMARK_START_BUTTON.click(start, inputs = [ benchmark_resolutions_checkbox_group, benchmark_cycles_slider ], outputs = BENCHMARK_BENCHMARKS_DATAFRAME) -def start(benchmark_runs : List[str], benchmark_cycles : int) -> Generator[List[Any], None, None]: +def start(benchmark_resolutions : List[str], benchmark_cycles : int) -> Generator[List[Any], None, None]: state_manager.set_item('source_paths', [ '.assets/examples/source.jpg', '.assets/examples/source.mp3' ]) state_manager.set_item('face_landmarker_score', 0) state_manager.set_item('temp_frame_format', 'bmp') @@ -62,7 +62,7 @@ def start(benchmark_runs : List[str], benchmark_cycles : int) -> Generator[List[ state_manager.sync_item('execution_queue_count') state_manager.sync_item('system_memory_limit') benchmark_results = [] - target_paths = [ BENCHMARKS[benchmark_run] for benchmark_run in benchmark_runs if benchmark_run in BENCHMARKS ] + target_paths = [ BENCHMARKS[benchmark_resolution] for benchmark_resolution in benchmark_resolutions if benchmark_resolution in BENCHMARKS ] if target_paths: pre_process() diff --git a/facefusion/uis/components/benchmark_options.py b/facefusion/uis/components/benchmark_options.py index 4e981cf..a7f07cf 100644 --- a/facefusion/uis/components/benchmark_options.py +++ b/facefusion/uis/components/benchmark_options.py @@ -6,16 +6,16 @@ from facefusion import wording from facefusion.benchmarker import BENCHMARKS from facefusion.uis.core import register_ui_component -BENCHMARK_RUNS_CHECKBOX_GROUP : Optional[gradio.CheckboxGroup] = None +BENCHMARK_RESOLUTIONS_CHECKBOX_GROUP : Optional[gradio.CheckboxGroup] = None BENCHMARK_CYCLES_SLIDER : Optional[gradio.Button] = None def render() -> None: - global BENCHMARK_RUNS_CHECKBOX_GROUP + global BENCHMARK_RESOLUTIONS_CHECKBOX_GROUP global BENCHMARK_CYCLES_SLIDER - BENCHMARK_RUNS_CHECKBOX_GROUP = gradio.CheckboxGroup( - label = wording.get('uis.benchmark_runs_checkbox_group'), + BENCHMARK_RESOLUTIONS_CHECKBOX_GROUP = gradio.CheckboxGroup( + label = wording.get('uis.benchmark_resolutions_checkbox_group'), choices = list(BENCHMARKS.keys()), value = list(BENCHMARKS.keys()) ) @@ -26,5 +26,5 @@ def render() -> None: minimum = 1, maximum = 10 ) - register_ui_component('benchmark_runs_checkbox_group', BENCHMARK_RUNS_CHECKBOX_GROUP) + register_ui_component('benchmark_resolutions_checkbox_group', BENCHMARK_RESOLUTIONS_CHECKBOX_GROUP) register_ui_component('benchmark_cycles_slider', BENCHMARK_CYCLES_SLIDER) diff --git a/facefusion/uis/types.py b/facefusion/uis/types.py index 52c5015..32a6080 100644 --- a/facefusion/uis/types.py +++ b/facefusion/uis/types.py @@ -6,7 +6,7 @@ ComponentName = Literal\ 'age_modifier_direction_slider', 'age_modifier_model_dropdown', 'benchmark_cycles_slider', - 'benchmark_runs_checkbox_group', + 'benchmark_resolutions_checkbox_group', 'deep_swapper_model_dropdown', 'deep_swapper_morph_slider', 'expression_restorer_factor_slider', diff --git a/facefusion/wording.py b/facefusion/wording.py index c176a23..fde5ae8 100755 --- a/facefusion/wording.py +++ b/facefusion/wording.py @@ -207,10 +207,10 @@ WORDING : Dict[str, Any] =\ 'run': 'run the program', 'headless_run': 'run the program in headless mode', 'batch_run': 'run the program in batch mode', - 'benchmark': 'run performance benchmarks and exit', 'force_download': 'force automate downloads and exit', + 'benchmark': 'run performance benchmarks and exit', # benchmark - 'benchmark_runs': 'choose the resolution for the benchmark runs (choices: {choices}, ...)', + 'benchmark_resolutions': 'choose the resolution for the benchmark runs (choices: {choices}, ...)', 'benchmark_cycles': 'specify the number of benchmark cycles', # jobs 'job_id': 'specify the job id', @@ -245,7 +245,7 @@ WORDING : Dict[str, Any] =\ 'age_modifier_model_dropdown': 'AGE MODIFIER MODEL', 'apply_button': 'APPLY', 'benchmark_cycles_slider': 'BENCHMARK CYCLES', - 'benchmark_runs_checkbox_group': 'BENCHMARK RUNS', + 'benchmark_resolutions_checkbox_group': 'BENCHMARK RESOLUTIONS', 'clear_button': 'CLEAR', 'common_options_checkbox_group': 'OPTIONS', 'download_providers_checkbox_group': 'DOWNLOAD PROVIDERS',