diff --git a/facefusion/core.py b/facefusion/core.py index d0e90103..88ca094e 100755 --- a/facefusion/core.py +++ b/facefusion/core.py @@ -75,10 +75,10 @@ def route(args : Args) -> None: hard_exit(1) error_core = process_headless(args) hard_exit(error_core) - if state_manager.get_item('command') == 'bulk-run': + if state_manager.get_item('command') == 'batch-run': if not job_manager.init_jobs(state_manager.get_item('jobs_path')): hard_exit(1) - error_core = process_bulk(args) + error_core = process_batch(args) hard_exit(error_core) if state_manager.get_item('command') in [ 'job-run', 'job-run-all', 'job-retry', 'job-retry-all' ]: if not job_manager.init_jobs(state_manager.get_item('jobs_path')): @@ -310,8 +310,8 @@ def process_headless(args : Args) -> ErrorCode: return 1 -def process_bulk(args : Args) -> ErrorCode: - job_id = job_helper.suggest_job_id('bulk') +def process_batch(args : Args) -> ErrorCode: + job_id = job_helper.suggest_job_id('batch') step_args = reduce_step_args(args) job_args = reduce_job_args(args) source_paths = resolve_file_pattern(job_args.get('source_pattern')) diff --git a/facefusion/program.py b/facefusion/program.py index f9e729de..abe36128 100755 --- a/facefusion/program.py +++ b/facefusion/program.py @@ -260,7 +260,7 @@ def create_program() -> ArgumentParser: # general 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('bulk-run', help = wording.get('help.bulk_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('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_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) diff --git a/facefusion/wording.py b/facefusion/wording.py index 8210ef74..bb0b0659 100755 --- a/facefusion/wording.py +++ b/facefusion/wording.py @@ -192,6 +192,7 @@ WORDING : Dict[str, Any] =\ # run 'run': 'run the program', 'headless_run': 'run the program in headless mode', + 'batch_run': 'run the program in batch mode', 'force_download': 'force automate downloads and exit', # jobs 'job_id': 'specify the job id', diff --git a/tests/test_cli_batch_runner.py b/tests/test_cli_batch_runner.py new file mode 100644 index 00000000..963e5a95 --- /dev/null +++ b/tests/test_cli_batch_runner.py @@ -0,0 +1,45 @@ +import subprocess +import sys + +import pytest + +from facefusion.download import conditional_download +from facefusion.jobs.job_manager import clear_jobs, init_jobs +from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory + + +@pytest.fixture(scope = 'module', autouse = True) +def before_all() -> None: + conditional_download(get_test_examples_directory(), + [ + 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' + ]) + subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p-batch-1.jpg') ]) + subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '2', get_test_example_file('target-240p-batch-2.jpg') ]) + + +@pytest.fixture(scope = 'function', autouse = True) +def before_each() -> None: + clear_jobs(get_test_jobs_directory()) + init_jobs(get_test_jobs_directory()) + prepare_test_output_directory() + + +def test_batch_run_targets() -> None: + commands = [ sys.executable, 'facefusion.py', 'batch-run', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p-batch-*.jpg'), '-o', get_test_output_file('test-batch-run-targets-{index}.jpg') ] + + assert subprocess.run(commands).returncode == 0 + assert is_test_output_file('test-batch-run-targets-0.jpg') is True + assert is_test_output_file('test-batch-run-targets-1.jpg') is True + assert is_test_output_file('test-batch-run-targets-2.jpg') is False + + +def test_batch_run_sources_to_targets() -> None: + commands = [ sys.executable, 'facefusion.py', 'batch-run', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('target-240p-batch-*.jpg'), '-t', get_test_example_file('target-240p-batch-*.jpg'), '-o', get_test_output_file('test-batch-run-sources-to-targets-{index}.jpg') ] + + assert subprocess.run(commands).returncode == 0 + assert is_test_output_file('test-batch-run-sources-to-targets-0.jpg') is True + assert is_test_output_file('test-batch-run-sources-to-targets-1.jpg') is True + assert is_test_output_file('test-batch-run-sources-to-targets-2.jpg') is True + assert is_test_output_file('test-batch-run-sources-to-targets-3.jpg') is True + assert is_test_output_file('test-batch-run-sources-to-targets-4.jpg') is False diff --git a/tests/test_cli_bulk_runner.py b/tests/test_cli_bulk_runner.py deleted file mode 100644 index a82b0980..00000000 --- a/tests/test_cli_bulk_runner.py +++ /dev/null @@ -1,45 +0,0 @@ -import subprocess -import sys - -import pytest - -from facefusion.download import conditional_download -from facefusion.jobs.job_manager import clear_jobs, init_jobs -from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory - - -@pytest.fixture(scope = 'module', autouse = True) -def before_all() -> None: - conditional_download(get_test_examples_directory(), - [ - 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' - ]) - subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p-bulk-1.jpg') ]) - subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '2', get_test_example_file('target-240p-bulk-2.jpg') ]) - - -@pytest.fixture(scope = 'function', autouse = True) -def before_each() -> None: - clear_jobs(get_test_jobs_directory()) - init_jobs(get_test_jobs_directory()) - prepare_test_output_directory() - - -def test_bulk_run_targets() -> None: - commands = [ sys.executable, 'facefusion.py', 'bulk-run', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p-bulk-*.jpg'), '-o', get_test_output_file('test-bulk-run-targets-{index}.jpg') ] - - assert subprocess.run(commands).returncode == 0 - assert is_test_output_file('test-bulk-run-targets-0.jpg') is True - assert is_test_output_file('test-bulk-run-targets-1.jpg') is True - assert is_test_output_file('test-bulk-run-targets-2.jpg') is False - - -def test_bulk_run_sources_to_targets() -> None: - commands = [ sys.executable, 'facefusion.py', 'bulk-run', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('target-240p-bulk-*.jpg'), '-t', get_test_example_file('target-240p-bulk-*.jpg'), '-o', get_test_output_file('test-bulk-run-sources-to-targets-{index}.jpg') ] - - assert subprocess.run(commands).returncode == 0 - assert is_test_output_file('test-bulk-run-sources-to-targets-0.jpg') is True - assert is_test_output_file('test-bulk-run-sources-to-targets-1.jpg') is True - assert is_test_output_file('test-bulk-run-sources-to-targets-2.jpg') is True - assert is_test_output_file('test-bulk-run-sources-to-targets-3.jpg') is True - assert is_test_output_file('test-bulk-run-sources-to-targets-4.jpg') is False